Write an article or Share a link

What is Deno & is it time to move on Deno over Node.js?

Hints Staff
4 years ago
What is Deno & is it time to move on Deno over Node.js? by html hints

Deno.js is finally released its 1.0.0. release date on May 13th, 2020. In this article will share you some information about what is Deno & is it time to move on Deno over Node.js.

Let's first know What Deno is?

  • 1. Deno was created by Ryan Dahl, the creator of Node.js.
  • 2. Deno is secure by default. Without permission, it cannot access files, network, or the environment.
  • 3. Deno has TypeScript built-in with no external configuration needed.
  • 4. External packages are pulled in via urls (much like Go)
  • 5. Deno is an anagram for Node and it's pronounced Deeno (long e).
  • 6. Deno is its minimalistic design associated with its very efficient referentialy-transparent import-system.

In 2018 Ryan Dahl did a talk at JSConf EU where he talked about his top 10 regrets with Node.js. His talk was excellent and you can watch it below.

In his talk, Ryan mentioned he had concerns with the node_module system and other legacy API's that will never change. He noted that JavaScript has changed a lot since Node.js came out and that he could see a way to make a better version of Node.js. He wanted it to be compatible with the browser AND the server environment. Security was also something that he wanted to focus on.

Two years later, the date’s been set: May 13th, that’s when Deno 1.0 will be officially released. A brand new JavaScript runtime for the backend, but instead of being written in C++, it’s written in Rust, based on the Tokio platform (which provides the asynchronous runtime needed by JavaScript), still running Google’s V8 engine though.

#May 13th

A lot has happened since Ryan's talk at JSCONF 2018. Many people have joined the project, it already has 48k stars on Github, and the project is beginning to raise a lot of attention in the community prior to its official 1.0.0. release on May 13th.

Time will only tell whether Deno will continue to grow but if the initial reaction is anything to go by, it's very positive.

#Top Syntax Features

1. Top Level Await

No more wrapper async functions. Just use top-level await syntax

const data = await fetch('api/data');

2. Import and URLs

You can use import and you don't need to NPM install all your packages. Much like GoLang, you can import from URLs.

import stuff from 'https://package/url'

3. TypeScript Built In

No need to set up TypeScript. It's all built-in. Just start writing your code!

4. Secure By Default

Deno has restricted access to files, the network, and the environment. This is a big difference to Node.js which has access immediately to everything.

5. ES6 and beyond

Unlike Node, Deno has the opportunity to incorporate modern JavaScript syntax which can remove the callback hell that Node can lead to.

6. Compatible with the Web

Deno's API is meant to be compatible with the web.

7. Web Assembly

Deno has support for wasm binaries.

There's more planned with Web Assembly so keep an eye on the project.

#No more NPM or node_modules folder

This one’s a biggy since everyone and their mother has had something to say about it in the past. Is it too bloated? Is it the wrong way to distribute dependencies? It is definitely one of the most controversial aspects of Node and Deno decided to get rid of it, altogether.

So how is Deno handling dependencies? So far, by simply allowing you to require modules from anywhere. In other words, you can simply do:

import * as log from "https://deno.land/std/log/mod.ts";

No need to have your own centralized repository anymore, but you do have to be careful with this practice, since importing modules from 3rd party sources you don’t have control over, leaves you open and exposed.

In fact, our good pal package.json is also missing, dependency management is now simplified by having a list of modules and their respective URLs on a file called deps.ts . But what about versioning? I hear you ask. Well, you can specify the package version on the URL, it’s not really elegant, but it works.

#So, will it replace Node.js anytime soon?

Not really, to be honest, the title is a bit of a clickbait. Some of us started using Node.js back in the day when it was around version 0.10, and we were using it in production! 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) has evolved to meet the industry’s requirements. Is it perfect? Heck no! But like anything else in life, there is no perfect when it comes to programming languages.

Let's first go through some points which state that there may be low chance that Deno replace Node.js

  • 1. Forces everyone to use TypeScript
  • 2. Preaches security when that’s not an issue if you know what code is in your project (which you absolutely should)
  • 3. Still uses the same V8 C++ engine (but with Rust as middleman
  • 4. Still does not offer any portable builds (requires Deno installed on the target OS to even run a single line)
  • 5. STILL DOES NOT OFFER PORTABLE BUILDS so you have to carry around all your dependencies and source code with you wherever you want to actually run the code.
  • 6. Did a poor job of trying to copy what Go/Golang does for its import system
  • 7. Has a wide open import system that doesn’t enforce version control (doesn’t enforce using Git repos like Go/Golang does)
  • 8. Doesn’t offer much performance improvement from NodeJS TypeScript (their press release admits their TS compilation times are slow).
  • 9. Supports about 50% less requests per second via its HTTP server (though response times per request are much better)
  • 10. Doesn’t really offer anything new over NodeJS that your project manager cares about

All that said, if your backend NodeJS project is using TypeScript, I could see people justifying moving over to “the new thing”. The problem is, I can’t for the life of me see what you would gain that a project manager would really care about.

These days, apps are ran in Docker containers with full permissions since it’s containerized so security seems like a dumb thing to preach. If Deno came out with a way to absorb npm packages without issue, the migration process would be far less painful but mainly fruitless nonetheless.

Bottom line, I don’t know how you’d pitch your non-technical manager on the benefits of Deno because it doesn’t offer any transformative features or benefits. I see it gaining in popularity, yes. However, I do not see it replacing NodeJS and npm.

Let's Install Deno into our system & Run Hello World!!

NodeDeno

We use cookies to ensure better User Experience. Read More