This article will give you a basic understanding of what Deno is, the value this technology adds, and where it lacks at the moment. Also, I’ll share some thoughts about adopting it.

In a nutshell, what is Deno?

Deno is a new (version 1.0 just came out) JavaScript runtime, created by the Node.js creator and designed to overcome several design flaws from Node.js and add improvements on top of that. A runtime is a “box” where code can run, and it’s a vital part of a system because it imposes certain restrictions around applications built inside of it and dictates a tremendous amount of the development experience and tradeoffs involved in creating the system.

Before checking Deno’s benefits, we need to understand which problems it aims to address.

Problems with Node.js

On this great talk, Ryan Dahl, the creator of Node.js, talks about some of the regrets in the development of Node.js

Amongst them, I’d like to highlight the following:

  • Security: There was a missed opportunity while designing Node to add certain guarantees around security. For example, your linter should not get access to your network or entire file system.
  • Making npm the defacto standard: This creates a centralized and privately controlled entity that has great power over the whole ecosystem and things like this happen.
  • node_modules: You know the meme, nothing is deeper than the node modules folder. It complicates the module resolution algorithm and is very inconsistent with how browsers work.

After reading this, you might be wondering: “Why not just fix these issues in Node?”. Deno’s blog answers this question: “Due to the large number of users that Node has, it is difficult and slow to evolve the system.”

Another great benefit of using Deno is the complexity around developing JavaScript applications with Node. There is just massive tooling involved, which creates confusion amongst new developers and headaches to more experienced ones for having to keep up with new versions of each package.

Benefits of using Deno

Some of Deno’s most important benefits compared to Node are:

  • Secure by default: Just like mobile applications, you need to grant explicit permission to access file, network, or environment. Because of this, you don’t have to be scared anymore about one corrupted package stealing your personal information.
  • Simplicity: Deno ships as a single executable, which provides everything you need to develop your application. No need for a package.json file or setting up external config files.
  • Support for TypeScript out of the box: Given Typescript popularity and adoption, this can significantly improve the developer experience and help developers catch bugs early.
  • Built-in utilities such as a bundler and code formatter: In other words, there is no need for external dependencies such as Prettier or Webpack for common tasks.
  • Standard library: This has been a long-requested feature for JavaScript, and Deno offers one. It provides utilities for testing, date-formatting, and more.
  • Browser compatible API: Global variables and events such as fetch, load, unload, and window are available in Deno just like you would expect in a browser, thus reducing the friction of moving from one platform to another.

All these benefits translate to mainly two things. First, you significantly improve developer experience, thus leading to potentially shorter development cycles, and second, you reduce the risk of downtime and data loss due to vulnerabilities from unsecured scripts.

#deno #node #javascript #typescript #web-development

Should I be using Deno instead of Node.js?
23.30 GEEK