What is Deno? A ‘better’ Node.js

 From the creator of Node.js, Deno is a secure runtime for JavaScript and TypeScript that addresses Node’s shortcomings.




If you like Node.js but not its package manager npm, or you want a more secure JavaScript runtime environment than Node.js, you might find the new open source project Deno of interest (the word Deno is an anagram of Node). On the other hand, if you’re using Node.js in production, there’s nothing to see here, move along – Deno is still “very much under development.”

Deno is a program for running JavaScript and TypeScript code outside of a browser. It’s the most recent effort spearheaded by Ryan Dahl, who founded the Node.js project in 2009, and it is an attempt to reimagine Node.js in light of the advances in JavaScript since 2009, including the TypeScript compiler. Like Node.js, Deno is essentially a shell around the Google V8 JavaScript engine, although unlike Node.js it includes the TypeScript compiler in its executable image.


Deno and advanced JavaScript

In 2009, JavaScript lacked several features that would have been useful for Node.js, according to Dahl. A few of these have been added to JavaScript over the years as part of the ECMAScript (ES) standard, and TypeScript has addressed a few more.

JavaScript has had events and callbacks essentially forever, but they can lead to rather complicated code, especially when you want to chain asynchronous actions. Promises make the syntax a bit more readable. A 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.

When Node.js was created, the de facto standard for JavaScript modules was CommonJS, which is what npm supports. Since then the ECMAScript committee officially blessed a different standard, ES Modules, which is what jspm supports. Deno supports ES Modules.

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.

TypeScript is a typed superset of JavaScript that compiles to plain JavaScript (ES3 or higher; it’s configurable). TypeScript adds optional types, classes, and modules to JavaScript, and supports tools for large-scale JavaScript applications. (Anders Hejlsberg calls it “JavaScript that scales.”) As mentioned earlier, Deno contains an image of the TypeScript compiler as part of its runtime. If you pass Deno a TypeScript file it will first compile it to JavaScript and then pass that to the V8 engine.

Comments

Popular posts from this blog

What Should You Know About the Future of Node.js?

The Good and the Bad of Node.js Web App Development

5 JavaScript Alternatives for Front End Development

Followers