What is Deno and will it Replace NodeJS?

What is Deno and will it Replace NodeJS?

What is Deno and will it Replace NodeJS

What is Deno?

Deno is simple, modern and secure runtime for JavaScript and TypeScript, created by Ryan Dahl - the original creator of Node.js. The project is intended to fix design problems in Node.js described in Dahl's famous talk "10 Things I Regret About Node.js".

10 Things I Regret About Node. js — Ryan Dahl

Not sticking with Promises

He added promises to Node in June 2009 but removed them in February 2010 for minimal. It’s possible unified usage of promise in Node would have sped the delivery of the standardization and async/await.

Security

Node program can access all the system calls, such as writing to the disk, accessing to the network.

The Build System (GYP)

If you are writing a module links to a C library, you’d use GYP to compile that C library and link it into Node.
Chrome used to use GYB, but now Node is the sole GYP user.
Funky interface, it’s Python adaptation of JSON. Node has several unnecessary complex wrappers around it.

package.json

Include NPM in the Node making NPM the standard of the Node distribution.
Centralized (privately controlled) repository for modules.
`require(“sommodule”)` is not specific: package.json, local node_modules folder, NPM’s database.
Unnecessary abstraction to rise the concept of a “module” as a directory of files. Don’t exist on the web.
Includes unnecessary information, such as license, repository.

node_modules

Module resolution algorithm is wildly complex.
Vendored-by-default has good intentions, but $NODE_PATH would work.
Deviates from browser.

require("module") without the extension ".js"

Needlessly less explicit.
Not how browser works.
The module loader has to guess.

index.js

Needlessly complicated the module loading system.
Especially unnecessary after require supported package.json.


Deno was built with


  • Rust (Deno’s core was written in Rust, Node’s in C++)
  • Tokio (the event loop written in Rust)
  • TypeScript (Deno supports both JavaScript and TypeScript out of the box)
  • V8 (Google’s JavaScript runtime used in Chrome and Node, among others)


Let's look at features of Deno


  1. Secure by default. No file, network, or environment access, unless explicitly enabled.
  2. Supports TypeScript out of the box.
  3. Ships only a single executable file.
  4. Has built-in utilities like a dependency inspector (deno info) and a code formatter (deno fmt).
  5. Deno does not use npm
  6. Deno does not use package.json in its module resolution algorithm.
  7. All async actions in Deno return a promise. Thus Deno provides different APIs than Node.
  8. Deno always dies on uncaught errors.
  9. Uses "ES Modules" and does not support require().
  10. Deno has a built-in test runner that you can use for testing JavaScript or TypeScript code.


Will Deno replace Node.js?

Deno is a replacement for Node.js, BUT! not in the sense that you should start learning it and using it right away, instead you could look at Deno because it might do the same thing as Node.js but on a better way. Deno is still in the early stages of development, and Node.js is used in many projects out there, this means that Node.js is not going out of the game anytime soon. 


Comments

Popular posts from this blog

Top 5 Programming Languages to Learn in 2020

10 NodeJS Tips and Tricks for developers