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
- Secure by default. No file, network, or environment access, unless explicitly enabled.
- Supports TypeScript out of the box.
- Ships only a single executable file.
- Has built-in utilities like a dependency inspector (deno info) and a code formatter (deno fmt).
- Deno does not use npm
- Deno does not use package.json in its module resolution algorithm.
- All async actions in Deno return a promise. Thus Deno provides different APIs than Node.
- Deno always dies on uncaught errors.
- Uses "ES Modules" and does not support require().
- Deno has a built-in test runner that you can use for testing JavaScript or TypeScript code.
Comments
Post a Comment
In case of any query or suggestion please comment here.