• Is Deno a Threat to Node?
  • By KAPIL RAGHUWANSHI
  • The Nuggets translation Project
  • Permanent link to this article: github.com/xitu/gold-m…
  • Translator: ZiXYu
  • Proofread by: X. Zhuo, Tanglie

Does Deno pose a threat to Node?

Deno 1.0 was released on May 13, 2020 by Node creator Ryan Dahl

It’s been almost two years since we first heard the word Deno, and the developer community, especially the JavaScript community, is very excited about it because Deno was created by Ryan Dahl, the father of Node. In this article, we will take a brief look at the history of Deno and Node, along with their main features and popularity.

Deno was announced at the euroJS Conference 2018 by Ryan Dahl during his talk “Ten Things I Regret about Node.js”. In this talk, Ryan mentioned some of his regrets about Node’s initial design decisions.

Watch his excellent speech here (YouTube)

In his JS conference talk, he explained some of his regrets about developing Node, such as not sticking to his ideas like Promises, security, build systems (GYP), package.json, and node_modules. But it was in that same talk, after explaining all his regrets, that he launched a new work called Deno, which was in development at the time.

About two years later, on May 13, 2020, Ryan and his development team (Ryan Dahl, Bert Belder, and Bartek Iwańczuk) released Deno 1.0. Next, let’s take a look at some of Deno’s features.

What is Deno?

Deno is a JavaScript/TypeScript runtime with default security and a great development experience. Deno consists of three pillars:

  1. Chrome V8 – JavaScript runtime engine
  2. Rust – Programming language
  3. Tokio – as written on Github, “a runtime for writing reliable, asynchronous, and lightweight applications

Deno’s goal is to provide an efficient and executable script environment for modern programmers. Like Node, Deno emphasizes an event-driven architecture, providing a non-blocking set of core IO users and their blocking versions.

Installation steps

Deno provides a single executable without any dependencies. You can install it using the following installation method.

Use the Shell:

curl -fsSL https://deno.land/x/install/install.sh | sh
Copy the code

Or use Homebrew:

brew install deno
Copy the code

See the Deno Installation Guide for more installation options.

A basic Hello-world application in Deno (as in Node) looks like this:

console.log("Hello world");
Copy the code

In this article, we’ll try to compare the features of Deno and Node. Finally, we’ll try to find out if Deno really poses a threat to Node.

There is no doubt that Node is a very successful JavaScript runtime environment. Today, tens of thousands of production versions are using Node. Another reason for this success is NPM, the package manager for Node, the JavaScript runtime environment, which provides millions of reusable libraries and packages for every JavaScript developer. Node is ten years old: it was first released on May 27, 2009. Deno, on the other hand, is relatively new and not yet widely used in production versions. It can be used like Node to create Web servers, perform scientific calculations, and more.

The highlight of Deno

  • Security (no file, network, or network access by default)
  • Is a single executable file
  • There is nonode_modulespackage.json
  • TypeScript support out of the box

security

Programs in Deno are executed in a secure sandbox (by default). Scripts cannot access hardware, open network connections, or perform any other potentially malicious operations without permission. For example, the following command line will run the basic Deno script without any read/write/network permissions:

deno run index.ts
Copy the code

You need to add explicit flags on the command line to open the appropriate permissions:

deno run --allow-read --allow-net index.ts
Copy the code

Single executable file

Deno tries to provide a stand-alone tool for writing complex features quickly. Deno is a single file that can define arbitrarily complex behavior without the need for other tools, so each library is explicitly introduced and invoked in the program.

Module system

In Deno, there is no concept of package.json or node_modules at all. You can import a source file using a relative path, an absolute path, or a full valid URL. As follows:

import { serve } from"HTTPS:HTTP / / / deno. Land/[email protected] / server. The ts ";

for await (const req of serve({ port: 8000 })) {
  req.respond({ body: "Hello!fromDeno \ n "}); }Copy the code

TypeScript support

TypeScript is an open source programming language developed and maintained by Microsoft. TypeScript can only be compiled to JavaScript after development. It is another popular language currently used in the Angular framework and the React. Js UI library. Deno doesn’t need other tools to support TypeScript.


Like Node, Deno is a new runtime that executes JavaScript and TypeScript outside of a Web browser. But it’s important to realize that Deno isn’t an extension of Node — it’s a completely new implementation.

Over time, Deno is becoming more and more popular, just like Node. You can see just how popular Deno is from its official Twitter account @deno_land (11,500 followers) and its Github page (50,000 + Star).

Deno restrictions

  • Deno is not compatible with Node (NPM) packages. This is very disappointing for the large JavaScript developer community.
  • Because it uses the TypeScript compiler internally to parse code into pure JavaScript, it is still relatively slow.
  • It lags behind in TERMS of HTTP server performance

Finally, we can conclude that Node and Deno are two completely different JavaScript runtime environments — so it’s best not to compare them side by side. The choice between the two depends on the given requirements. After watching Node grow in popularity among developers over the past decade, I don’t think it’s going to be easy for Deno to achieve that in a shorter period of time. But yes, Deno’s new features make it definitely worth a try. We will continue to monitor Deno’s further development and find more solutions in the coming years. So, today we can come to this conclusion:

In 2020, Deno is not a Node threat at all.


Please leave your suggestions and feedback in the comments section below.

If you find any mistakes in your translation or other areas that need to be improved, you are welcome to the Nuggets Translation Program to revise and PR your translation, and you can also get the corresponding reward points. The permanent link to this article at the beginning of this article is the MarkDown link to this article on GitHub.


The Nuggets Translation Project is a community that translates quality Internet technical articles from English sharing articles on nuggets. The content covers Android, iOS, front-end, back-end, blockchain, products, design, artificial intelligence and other fields. If you want to see more high-quality translation, please continue to pay attention to the Translation plan of Digging Gold, the official Weibo, Zhihu column.