promise is a returned object representing the eventual completion or failure of an asynchronous operation, to which you can attach callbacks, as opposed to passing callbacks into a function. Declaring a function
async further simplifies the syntax, allowing you to use
await within the function to pause in a non-blocking way until the promise settles.
Typed arrays are an ES6 API for handling binary data, something Node.js could have used; the lack of binary data support led to some Node.js design issues. Deno uses typed arrays when it needs to manipulate raw binary data. Node.js now supports typed arrays for user code.
Node.js design shortcomings
, who after all did design both Node.js and Deno, Node.js suffers from three major design issues:
. In Deno, you load ES modules using the
import keyword and explicitly state the URL. For example:
import * as log from "https://deno.land/std/log/mod.ts";
Deno modules can be hosted anywhere – there is no centralized repository for third-party modules. In addition, modules are always cached and compiled locally, and aren’t updated unless you explicitly ask for a refresh. Therefore, you should be able to run Deno programs that are already on your laptop, as long as all the imports have been resolved once, even if you are on an airplane with no connectivity.
is a loose port of .
There is a little history behind that choice of model for the library. Dahl wrote his prototype of Deno primarily in the , but discovered potential conflicts between the garbage collectors in Go and V8. He and his collaborators then rewrote Deno proper with V8, , and the Rust asynchronous I/O package . They implemented the Deno standard library in TypeScript.
At this point, Deno is a reasonable and fun environment to use for building small private scripting projects in TypeScript. According to Dahl, Deno will never really affect the success of Node.js. Nevertheless, once Deno reaches version 1.0 it may well become a viable choice for building larger projects.
Copyright © 2020 IDG Communications, Inc.