Underreacted

What is Deno? Is it gonna replace Node?

May 18, 2020

Deno

Version 1 of Deno was released on 13 May 2020, but what does that mean for you? Is it gonna replace Node? Is all of the hard work that you spent learning node completely wasted? Let’s find out!


Deno is a new runtime for javascript. So think about Deno as an upgraded newer version of node.js. Also interestingly it is created by the exact same person who created node.js — Ryan Dahl

Ryan saw all of the problems with node and the poor design decisions he made during the development but since now millions of Softwares depend on it, it is impossible to make amends to the legacy code. Hence he decided to recreate node.js in a better form and thus Deno was born.

Fun Fact Deno is actually an anagram of Node. Cool right!?

Check out the video below where Ryan shares his regrets about node.js and why he is building Deno.

YTvideoImg

Bottomline — Deno is a new runtime that is built on Rust, which is going to be very similar to node and do a lot of things that node does but with a lot of advantages.

One of the biggest advantages that Deno has over node is that it has built-in TypeScript support! So if you are someone who uses TypeScript when you write JavaScript, you can just use it out of the box with Deno, since it has the compiler and everything built-in, so you don’t have to worry about any TypeScript configuration!

Now allow me to blow your mind in the following two points:

  1. A Deno project* doesn’t need node_modules* to keep 3rd party code.
  2. A Deno project *doesn’t need a package.json *to manage your dependencies.

A popular meme, comparing the weight of node_modules 😂

Amazing right? Now your next question would be then how do we use 3rd party libraries in Deno?

The following line shows the syntax of how you will be importing libraries in Deno.

import { serve } from “https://deno.land/std@0.50.0/http/server.ts”;

That’s right! We will be importing libraries directly from the server! (using the URL) and during the first compilation, the imported library will be cached in your computer so that the subsequent compilations are faster.

All of your dependencies are saved in a central location on your computer, so you don’t have to worry about this massive node_modules folder.

This completely eliminates the use of a package manager like NPM.



https://deno.land/

As soon as you land on Deno’s website the first thing you see is their tagline:

A secure runtime for JavaScript and TypeScript.

And this brings me to the next important feature of Deno. Deno is secure by default. By default, I mean that a Deno project has no permissions by default. You have to provide permissions explicitly for each and every resource that you want Deno to use. For example, even just to start a server on your local machine you have to provide permissions! This means Deno cannot access anything in your machine until you explicitly tell it to.


So is Deno gonna replace Node?

Well, I have to say right now, that is not going to be the case. While Deno is really cool and it has a lot of new features coming to it, it still is in a very early phase, it just hit v1 recently. Deno is still working on a lot of things, for example, the browser compatibility is still not 100%, they are still working on the browser APIs, and it will take them some time to achieve this.

Also, when I mentioned that we don’t use NPM with Deno, that is actually a little bit of a downside right now. Javascript is based around the NPM packages and the downside is that many of these packages are not going to be compatible with Deno right away.

Surely over a certain period of time, people will start writing packages compatible with Deno, but at the time of publishing this article that is not the case.


Vikrant Bhat

Personal blog by Vikrant Bhat.
Documenting my Javascript learning journey in succinct blogs.