Deno VS Node

What is Deno?

Deno is a new runtime for JavaScript and TypeScript, created by Ryan Dahl – who also created Node.js. The project was in public development for about two years, and the first stable release of Deno, version 1.0, was released on 13th May 2020.

Deno was developed to overcome some of the Node’s limitations, especially security. In short, Deno is an upgraded and secured version of Node. Unlike Node.JS, Deno offers first-class support for Microsoft’s increasingly popular Typescript, a superset of JavaScript designed for complex and large projects. Deno is written in programming language Rust and based on Google’s Chromium V8 JavaScript engine and as opposed to C++ for Node.

In 2018, Ryan revealed Deno in one of the conferences where he was giving a talk about shortcomings of Node, and at the end of that presentation, he revealed a more secure and improved version of Node, i.e. Node V2.

Features of Deno

1. Integrated Typescript

No Need to link typescript externally, Deno has inbuilt support for this popular JavaScript. By default the transpilation into JavaScript is done internally, so no need to worry about that.

Deno has its typescript configuration JSON file called tsconfig.json, but you can override it using the following command:

deno run -c tsconfig.json [your-script.ts]

2. Security

Node.js lagged somehow in security. In Node.JS, you can read and write into the filesystem, make outgoing requests, access environment variables, and so on. It can be an easy bug bounties for security researchers, if you aren’t careful while writing your code.

No worries now, Deno has your back. Deno uses command-line arguments to enable or disable access to different security features. So if you need your script to be able to access the /etc folder, you can do

deno --allow-read=/etc myscript.ts

That would allow your code to read from the folder, and raises security exception if try to access anything else. This is similar to how other platforms handle security. Android users can relate this feature as before installing any application, they are asked to grant permissions to various system applications like camera, microphone, phone, and more. By using these flags as part of the command line that executes your script, you’re providing the permissions required by your code.

3. Improved Dependency Handling

No package.json, no node_modules, So how does Deno handle dependencies? In deno, you can import modules from anywhere. You need to specify the version of the libraries in the URL itself.

The package.json is replaced by deps.ts, which appears like:

export { assert } from "https://deno.land/[email protected]/testing/asserts.ts";
export { green, bold } from "https://deno.land/[email protected]/fmt/colors.ts";

4. Standard Library Features

Deno comes with the tools to add color to terminal text, work with external data structures (such as binary, CSV, YAML, and others), generate UUIDs, and even write WebSockets. There are other, more basic modules available as well, such as file system access, date helper functions, HTTP-related functions, and more.

5. Other Features

Deno has a wide range of features like more oversized tooling out of the box with things such as a test runner, debugger, file watcher, and others.

Ryan Dahl stated, “Deno’s performance on the webserver is about equal to Node, but Deno has better latency than Node.”

“A hello-world Deno HTTP server does about 25k requests per second with a max latency of 1.3 milliseconds. A comparable Node program makes 34k requests per second with a rather erratic max latency between 2 and 300 milliseconds,” he notes.

Deno V/S Node

Many Web Developers are using Node.JS since it was in the production phase as the community was awaiting full-stack JavaScript Web Environment in their application. It was a bit scary to tell you the truth, but we were doing it because there was nothing like it around. Neither PHP, Python or even Ruby (let alone Java or .NET) could compare to having JavaScript and an asynchronous I/O model in the back-end, all in one. And over all these years, Node (and JavaScript and it’s Frameworks) has evolved and developed to meet the industry’s requirements. Thousands of JS Frameworks exist in the market. But Deno is hyped or is notable because it’s the next generation to the most popular Node.JS, which is used by many companies, including Twitter.

Difference between Node & Deno

Deno Node
Engine Chromium V8 Chromium V8
Written In Rust & Typescript C++ & JavaScript
Security Permission-based Access Full Access
Package Management URL’s npm and mode modules
Typescript Support Built-in Not built-in

Conclusion

Deno is no different, simply because right now, it’s just the culmination of around 2 years of work on an idea. It hasn’t been tried and tested in production systems and applications yet. It hasn’t been reviewed and put into weird and unintended use cases to see how it deals with those border situations where node js didn’t. And until it does, it’ll just be a toy for early adopters to explore and play with. As it’s a framework of the most loved language, we’ll start hearing from developers and companies sharing their experiences with Deno and how they’ve solved the newly found shortcomings, and eventually, it will be adapted where it should be to fill the patches of NodeJS.
Will it replace Node then? Who knows! We’ll have to wait and see. Drop your views in the comment section!

Looking to Learn JavaScript & it’s Frameworks, Explore Top Free Udemy JavaScript courses here

Learn more about Deno and its feature here

Want to see Deno in action? Learn to install Deno on your system and develop a simple REST API in Deno. See the complete REST API guide in Deno here.

LEAVE A REPLY

Please enter your comment!
Please enter your name here