What is Deno and will it replace Node.js

Pasindu Thejan
5 min readSep 3, 2020

--

1. What is Deno ?

Deno is a simple, modern, and secure runtime for JavaScript and TypeScript. It is invented by Ryan Dhal, who is an American software engineer. And he is the man who original creator of Node.js. This is a huge reason to search about Deno. It is interesting to read Why Ryan introduce Deno rather than Node.js???

2. Fun and productive system for scripting

When introducing Deno Ryan said that,

“I want a fun and productive system for scripting. A good scripting platform is too useful of a tool to shrug and accept the status quo. I find neither Node nor Python nor Ruby nor any other dynamic language platform satisfactory.”

3. Releases

This is the main releases of Deno. There are four main releases by now. The latest stable release was released before few days ago.

4. Built on top of

Deno is built on top of four main pillars. V8, Rust, Tokio and TypeScript are those.

V8 is an open-source JavaScript engine developed by The Chromium Project for Google Chrome and Chromium web browsers. The project’s creator is Lars Bak and it’s written in C++.

Rust is a multi-paradigm programming language focused on performance and safety. Rust is syntactically similar to C++. But it provides memory safety without using garbage collection.

Tokio is an event-driven, non-blocking I/O platform for writing asynchronous applications with the Rust programming language. At a high level, it provides a few major components: Tools for working with asynchronous tasks, including synchronization primitives and channels and timeouts, delays, and intervals.

TypeScript is an open-source programming language developed and maintained by Microsoft. It is a strict syntactical superset of JavaScript and adds optional static typing to the language. TypeScript is designed for development of large applications and trans compiles to JavaScript.

5. Features of Deno

  1. First-class TypeScript support: To run TypeScript code with Deno does not require a compilation step - Deno does that automatically for you.
  2. No package manager : Having no package manager and having to rely on URLs to host and import packages has pros and cons. Pros are very flexible, we can create packages without publishing them on a repository like npm.
  3. The Deno sandbox : Deno has a sandbox that prevents programs to do anything you do not want to allow.
  4. Formatting code : When run “deno fmt app.ts” and it is automatically formatted the code properly, also adding semicolons where missing.
  5. The standard library : The Deno standard library is extensive despite the project being very young.
  6. Deno provides a built-in fetch implementation that matches the one available in the browser.
  7. Deno has a compatibility layer with the Node.js stdlib in progress.

6. Deno Vs Node

Similarities

  • Both are developed upon the V8 Chromium Engine
  • Both are great for developing server-side with JavaScript Differences
  • Node is written in C++ and JavaScript. Deno is written in Rust and TypeScript.
  • Node has an official package manager called npm. Deno does not, and instead lets you import any ES Module from URLs.
  • Node uses the CommonJS syntax for importing packages. Deno uses ES Modules, the official way.
  • Deno uses modern ECMAScript features in all its API and standard library, while Node.js uses a callbacks-based standard library and has no plans to upgrade it.
  • Deno offers a sandbox security layer through permissions. A program can only access the permissions set to the executable as flags by the user. A Node.js program can access anything the user can access
  • Deno has for a long time envisioned the possibility of compiling a program into an executable that you can run without external dependencies, but it’s still not a thing yet. That would be a game changer.

7. Mistakes on Node

According to the inventor there are some mistakes in Node. Due to the large number of users that Node has, it is difficult and slow to evolve the system. Node has a poorly designed module system with centralized distribution. And lots of legacy APIs that must be supported in Node. Furthermore, there can be occur some security problems in deno as describes in the latter part of this article.

8. Deno attempts to correct design mistakes in Node by radically breaking compatibility

ES modules are the one and only module system. — In Deno HTTP URLs are used to link to third party code. Deno has the ability to fetch resources itself, so it is its own package manager.

Deno is secure by default — Users must give extra permission to access the disk, network, or otherwise do privileged operations.

Deno maintains browser compatibility. — The subset of Deno programs which are written completely in JavaScript and do not use the global Deno object should also run in a modern web browser without any change.

9. Will Deno replace Node

When reading this exactly now you confused about will Deno replace Node.js. According to the inventor the exact answer for this problem is No. Because Node.js is a giant, well established, incredibly well supported technology that is going to stay for decades.

10. Conclusion

Deno is a new way to JavaScript, and it is very similar Nodejs. According to the inventor Deno will not replace Nodejs. Still Deno is good for experiments and is not ready for the production. In near future it will be a best solution.

--

--