Saturday, June 13, 2020

Deno vs NodeJS - Will Deno overtake Node in next few years?


About Deno

Deno is a secure runtime environment for Javascript and TypeScript that addresses Node's shortcomings.
Deno was announced as an open-source project in 2018 by the original creator of the Node.js Ryan Dahl during his talk "10 Things I Regret About Node.js." and aims to fix the Node.js design mistakes and offer a new modern development environment.

The video of the talk is given below.

How is it different from Node.js?


Modules

In 2009, JavaScript lacked several features that would have been useful for Node.js.few of them are added to Js as a part of the new ECMAScript standard (ES), and TypeScript experienced a few more.


When Node.js was created, the de facto standard for the JavaScript modules was Common Js, which is what npm supports. The ES commit committee blessed the Js with some new standards, The ECMAScript modules, which is what jspm supports. Deno Supports ES modules.


So hows Dino handling Dependencies?


Here is the Node.js Example
 const express = require("express");  

Here is the Deno Example
 import { serve } from "https://deno.land/std@0.50.0/http/server.ts";   
At first glance, the Node imports look more straightforward, but there are a few advantages to using the Deno style. By importing code via URL, it's possible to host modules everywhere on the internet. Deno packages can be distributed without a centralized registry. There is also no need for the package.json file and a dependency list, because all modules are downloaded, compiled, and cached on the application run

Security 

By Default Node.js allows you to access everything, meaning you can read and write into the filesystem, make ongoing requests, access environment variables, and so on. This can be considered as an advantage for the developer, but it puts the security into risk sometimes as you can mess up with your own code sometimes. 



Ryan Dahl corrected this mistake by adding a command-line argument to enable-disable access to different security features. For example, if your script wants to access some folder, it can do it as follows.
 deno --allow-read=/folder myscript.ts  

This works similarly to how other platforms handle security exceptions. This will allow you to read the code from the folder, but if you try to access anything else, you will get a security exception.

Integrated TypeScipt

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 JS applications. 


If you are a fan of TypeScript, then Dino got it covered for you, Dino transpilers the typescript to JavaScript internally and then pass it to the V8 engine.




Async Support

Deno is async by default. This means you don't need to create wrapper functions just to use await. Dino is just released, keeping lots of modern javascript in mind.


Will Dino replace node.js anytime soon?

Not really, to be honest, the title is a bit of a clickbait.  I will put my point to support this.
  1. Node is the industry standard-Majority of the companies is using Node, for valid reasons outlined below. So if you're aiming to add one to your CV, it should be Node.
  2. Node is well tested, and stable-Node is used by tons of silicon valley giants. Its well tested in production, and stable. Deno was just barely released, and its undoubtedly filled with bugs.
  3. Node has the package for everything -npm over its 10+ years has created a 3rd party package library of more than 6 mln packages. You indeed can find a package for everything in the Node. Deno doesn't yet have this amount of support, packages for Deno are just in the hundreds.

Should I start with Node.js or Deno as a beginner?

Deno is more secure, more decentralized, and arguably better designed than Node. It's almost a given that it will overtake Node in the next few years. Saying all that your choice -for now- for any software of importance should be Node. Node is stable, well tested, and supported by the giants of the industry. Node is not going away for a long time.

So, According to me, if you are starting from scratch, you should start from Node.js and move to Deno as you gain some experience in  Node.js. I know Deno is promising, and I'm also excited to see where things go. For now, NodeJS is the clear winner in terms of community support, history, developers, and security.

Conclusion

Time to look at what we got to know in this article. Deno is a secure runtime environment for Javascript and TypeScript that addresses Node's shortcomings. Deno is more reliable and supports jspm. It is designed keeping in mind the modern JavaScript requirements and is likely to overtake the popularity of Node.js in the future. However, if you like this article and want to refer to it at any point in time, then consider bookmarking this.

What do you think?
Previous Post
Next Post

post written by:

Hi, Navjyot Singh is a coder, content maker and a freelance developer who's pursuing an undergraduate Engineering degree in Computer Science. He started out as a web developer but later picked up the mobile as his favourite platform to develop applications. A Writer by day and coder by night is loathed to discuss himself as the third person but can be persuaded to do so from time to time.

0 comments: