A brief look at Deno – the brand new javascript runtime.

Internet has been buzzing with news about the new kid on the block – Deno 1.0.0, a secure runtime for javascript and typescript which was released last month. Its claim to fame is that the lead for the project is Ryan Dahl – the creator of node.js. The project is interesting in a lot of ways and has potential to be next in line to node’s throne but as with any tech project we can never say for sure (e.g. Dart being hailed as javascript killer?). This is my brief look at demo and what it brings to the table.

Deno was essentially developed out of the things which Dahl thought were missed opportunities in nodejs. In the video below he talks in detail about the design considerations he had while designing node and how certain mistakes just stuck. As node became a hugely popular platform which could not be modified fundamentally, they took these ‘regrets’ and created Deno project to solve them.

That being said let’s see what is deno and why it is relevant to a person like me who is into data-analytics and visualisation.

So what is it?

Deno is essentially something similar to nodejs – a program (runtime) which lets us run javascript/typescript programs outside browsers. You install deno and write a javascript file and run the file with deno. Literally like node (deno is anagram of node). But as we saw in the above video, deno is fundamentally different from node in certain ways,

1. Typescript support

Deno supports typescript as its first class citizen. Since typescript is a superset to javascript, it also supports javascript by extension. Typescript is js with ‘strict types’ which brings loads of improvements in terms of runtime safety, IDE features such as linting etc. while preserving the flexibility and ease of use provided by javascript.

2. Modern EcmaScript features

Javascript has improved a lot since node was released 10 years ago. Though node has changed rapidly to accomodate most of the new features there are lot of things which are pure legacy and won’t exist if node project was started today. For example, deno embraces ES modules. We can import specific parts of modules like we do in python. The other modern features implemented from ground up are promises, async/await (even top level) etc. Overall, deno is a fresh start and has all the modern ES6 features and APIs built in from day one.

3. Security

Node is notorious for having a lot of permissions to the host system by default. For example, node programs have access to the disk by default which is quite dangerous when running arbitrary code. In contrast, deno runs in sandboxed mode by default and every permission has to be explicitly allowed at runtime leading to better security model.

4. No more npm

There is no need for a package manager such as npm for deno as there is resource loading and package management built into it. You can literally include modules from a url! Since it is so simple, there is no need for the deeply nested and heavy node_modules folders.

5. Rust!

Finally, as with any project which is serious about runtime safety, deno is developed in Rust! Hence it also supports better integration with Rust, web assembly etc. I am not entirely sure how exactly this is going to pan out but I think having rust in both front and backend for heavy lifting is going to result in a lot of low-latency, high-performance web applications.

In summary, deno looks like modern nodejs built from scratch to remove legacy design choices and include new developments in web technologies. As I said earlier, it has the potential to be the next node.js but it will be quite sometime before it makes its way into production systems.

Leave a Reply