Before you go, check out these stories!

0
Hackernoon logoDeno🦕 - Is it a threat to Node? by@techygeeky

Deno🦕 - Is it a threat to Node?

Author profile picture

@techygeekyKapil Raghuwanshi

JavaScript Ecosystem Hacker | Machine Learning Enthusiast | Angular, React, Node | Tech Writer.

Deno 1.0 is launched on 13th May 2020 by Ryan Dahl — the original creator of Node.js

It’s been around 2 years now, we are hearing the term “Deno” and developer community especially JavaScript one is quite excited since it is coming from the author of Node.js - Ryan Dahl. In this post, we will discuss a brief history of Deno and Node along with their salient features and popularity.

Deno was announced on JSConf EU 2018 by Ryan Dahl in his talk “10 Things I Regret About Node.js”. In his talk, Ryan mentioned his regrets about the initial design decisions with Node.js.

In his JSConf presentation, he explained the regrets while developing Node.js like Not sticking with Promises, Security, The Build System (GYP), package.json and node_modules, etc. But in the same presentation after explaining all the regret, he launched his new work named Deno.🦕 It was in the process of development then.

But on 13th May 2020, around 2 years later yesterday, Deno 1.0 launched by Ryan and the team (Ryan Dahl, Bert Belder, and Bartek Iwańczuk). So let’s talk about some features of Deno.

First, let’s try to find out what the heck is Deno?

Deno is a JavaScript/TypeScript runtime with secure defaults and great developer experience. Deno is built on 3 pillars -

  1. Chrome V8 — JavaScript Runtime Engine
  2. Rust Programming language
  3. Tokio — A runtime for writing reliable, asynchronous, and slim applications.

Deno aims to be a productive and scripting environment for the modern programmer. Similar to Node.js, Deno emphasize on event-driven architecture, providing a set of non-blocking core IO utilities, along with their blocking versions. 

Installation Steps:

Deno ships as a single executable with no dependencies. You can install it using the installers below-

Using Shell:

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

Or using Homebrew:

brew install deno

See deno_install for more installation options.

A basic Hello-World program in Deno looks like the following (same as in Node.js):

console.log("Hello world");
We will try to compare the features of Deno with Node throughout the post. And in the end, will try to find out is it really a threat or not?

There is no doubt that Node.Js is a huge success JavaScript runtime environment. Today, more than thousands of production build is using Node.js. Another reason for this success is NPM - a package manager for the JavaScript runtime environment Node.js which has millions of reusable libraries and packages for every JavaScript developer out there.

Node is a decade old now since it was initially launched on May 27, 2009. On the other hand, Deno is relatively very new. Still, not used in the production build much. It could be used to create web servers like Node.js, perform scientific computations, etc.

Highlighted features of Deno 🎆

  1. Secure - No file, network, or environment access by default. 👁‍🗨
  2. Ships only a single executable file.1⃣
  3. Say No to node_modules and package.json.❌
  4. TypeScript support out of the box. 🤝

1. Security

The program in Deno is executed in a secure sandbox (by default). Scripts cannot access the hard drive, open network connections, or make any other potentially malicious actions without permission. (E.g) The following runs a basic Deno script without any read/write/network permissions:

deno run index.ts

Explicit flags are required to expose corresponding permission:

deno run --allow-read --allow-net index.ts

2. Single executable file

Deno attempts to provide a standalone tool for quickly scripting complex functionality. Deno is a single file that can define arbitrarily complex behavior without any other tooling. So, every library will be explicitly called and included in the program.

3. Module system

Here, we do not have any package.json or node_modules. Source files can be imported using a relative path, an absolute path or a fully qualified URL of a source file as shown below:

import { serve } from "https://deno.land/std@0.50.0/http/server.ts";
for await (const req of serve({ port: 8000 })) {
  req.respond({ body: "Hello from Deno\n" });
}

4. Typescript Support

TypeScript is an open-source programming language developed and maintained by Microsoft. TypeScript is at the end transcompiles to JavaScript only. It is another popular language of recent times used heavily in Angular Framework and React.js UI library. Deno supports TypeScript without additional tooling.

Deno is a new runtime for executing JavaScript and TypeScript outside of the web browser like Node.js But it’s important to understand that Deno is not an extension of Node — it’s completely a newly written implementation. 

Deno - a secure runtime for JavaScript and TypeScript.

Slowly, Deno is also getting popular like Node.js. You can see the popularity by Deno’s official twitter handle @deno_land with 11.5K Followers and 50k+ stars on Github https://github.com/denoland/deno.

Deno on GitHub

Limitations of Deno 😞

  1. Deno is not compatible with Node (NPM) packages. Huge disappointment for the big JavaScript dev community.
  2. Since it uses Typescript compiler internally to parse the code to plain JavaScript, it is still very slow comparatively.
  3. It lags in HTTP server performance.

In the end, we can conclude that Node and Deno are two different JavaScript runtime environments altogether. So it’s better not to compare both. The choice depends on the given requirements. After looking at the gradually increasing popularity of Node among the developers for a decade, now it will be difficult for Deno to cover that in less time.

But indeed for new features, one can definitely try Deno. We will keep an eye on further development of Deno and figure out more in the coming years. So, today we can make a statement that - 

As in 2020, Deno is not at all a threat to Node.

Write your suggestions and feedbacks in the comment section below, share it with your friends and colleagues.

Tags

The Noonification banner

Subscribe to get your daily round-up of top tech stories!