Node

The rise of Deno : What is Deno and will it replace Nodejs?

What is Deno?

Deno is the brand new JavaScript / TypeScript runtime based on the V8 JavaScript engine and Rust programming language. The Rust programming language delivers similar performance as C++ and has memory security without using garbage collection. Deno is the sibling of NodeJs, created by Ryan Dahl. He has already pointed out some drawbacks of NodeJs earlier, but it is not that easy to cover up the issues due to the way it is built. So he was thinking about a new JS runtime that can overcome the shortcomings of NodeJS. Any developer would feel like that about their code after some time.

What led to the Deno Project?

  • A poorly designed module system of NodeJS, with the centralized distribution.
  • Lots of legacy APIs that must be supported.
  • Less security in NodeJs and some other programming languages.
  • The advances in JavaScript from 2009.
  • The complete details that Ryan had a regret about NodeJS can be found in the video below. 

Features of Deno

  • Built-in TypeScript compiler. It allows you to write JavaScript/ TypeScript right away which is much cooler. If only JS is used in code, the TS compiler will not be invoked and doesn’t bloat the runtime.
  • Secure by default. That means the script should run without a file system or network write access by default; until you explicitly specify those permissions while running the script. You will get the full list of permissions by running deno run -h
  • Decentralized packages. One of the issues with NodeJs is the centralized approach. If you install any package as a dependency via npm in your NodeJs application, all the dependencies for that package are also going to be installed and that makes the node modules bigger and bigger. Deno uses a decentralized approach in package management. If you need any third-party packages, you can import it from the URL. It will be cached to the hard drive once it is loaded. It doesn’t update the cache until you run the code with the reload flag.
  • Single executable file. Deno itself serves as a runtime as well as a package manager. For a NodeJs program to run, all the dependencies have to be installed using a package manager such as npm or yarn.
  • ES modules. The Deno doesn’t support “require()”, instead it uses ES modules for importing which all browsers support. ES module is the new feature added to the JavaScript specification.
  • Top-level Promise. With Deno, we can use await in the global scope without explicitly wrapping it in an async function.
  • Deno has a set of standard modules reviewed by the Deno core team. Each of these modules are written in TypeScript and doesn’t have any other external dependencies.
  • Tokio for asynchronous operations. It doesn’t use callbacks like NodeJS. Also the Tokio is developed and supported by the Rust core team.

Will it replace NodeJS?

Deno is not a replacement for Node. Ryan Dahl has clarified that the NodeJs is not going anywhere. Check the video below;

NodeJS has a huge community and it is still a great programming language. So if you are new to NodeJs, continue with NodeJs as it is pretty stable now and has a lot of tutorials.

Deno has only got its first version as of now, and it will be growing gradually and might compete with NodeJS later on.

Comparison – NodeJS vs Deno

Feature NodeJS Deno
Built using C++ Rust
Dependency package management Centralized Decentralized
Module system CommonJS require() syntax ES module import statement
TypeScript support Possible using TypeScript compiler Supports TypeScript out of the box.
Event loop Libuv Tokio

Bigger refactors on Deno Internals:

Deno Team is working on some major refactors to the internals of Deno. Incremental compile time, separate compilers for build-time and run-time, etc are some of the problems they are looking into. Removing all TS type checking from internal code is one of the solutions they have concluded. This won’t affect any TypeScript support in general; it’s all about the internal code. You can find the details here (https://github.com/denoland/deno/issues/5858)

Summing up

As we have established earlier, Deno won’t replace NodeJS but, the future looks bright for Deno. Deno might not be a perfect programming language; there is no perfect one. But still, it could resolve many of the problems that NodeJS had. Deno has released the first version only and it might reveal some issues later and improve. Anyways, the whole JavaScript community is so excited about Deno. You are even excited that makes you read the blog. Do checkout https://deno.land/ and start learning Deno programming.

Try our app development services and jump ahead of  your competition.

Talk to our experts now and let us be your innovation partner!

Get a tech consultation and a free quote for your solution!

Check out our success stories to know more about it.