What is Deno? New forces compete with Node.js?

Tram Ho

On May 13, 2018, Node.js’ father Ryan Dahl released a Runtime Enviroment for JavaScript called Deno , which is said to fix all Node.js issues. Don’t get me wrong, the current Node.js is still a great Runtime Enviroment in its own way. However, Ryan acknowledged a few things that need to be improved on Node.js such as security, modules, and dependent installation packages.

Runtime Enviroment: an environment that provides objects and environments for JavaScript to communicate with computers.

What is a Deno? Main features of Deno?

Deno is Runtime Enviroment for JavaScript and TypeScript, using V8 Engine and Rust programming language. Deno has several highlights such as:

  • Privacy by default. Unable to access modules without being enabled.
  • TypeScript support.
  • The standardized modular system is guaranteed to work with Deno.
  • Only one file is sent.

Security

According to the author, security is one of Deno’s most important features.
Contrary to Node, Deno defaults to executing in a virtualized environment (sandbox), which means that Runtime doesn’t have access to:

  • System files
  • Network
  • Different scenarios.
  • Environment variables
    Let’s see Deno security system in action

The above function creates two txt files named helloWorld.txt and helloWorld2.txt to print Hello world . This function is implemented in SandBox so it does not have access to the file system.
To run the above command, type

A notice will appear

This message indicates that creating a text file must be approved. So to fix this, add option: allow alway :

No errors will occur, and two text files have been created successfully.

Besides the --allow-write option, there are many other options such as --allow-net , which allows the use of network requests, allow-env , allows access to the environment, --allow-run , allows execution of person program.

Modules

Deno is like a browser, loading modules by URL. Many people were confused at first when they saw importing modules using Url

import { assertEquals } from "https://deno.land/std/testing/asserts.ts";
By importing the module by URL, Deno does not depend on Npm. This shows that there will be no need for bulky package.json file and node_modules directory.

When the application starts, Deno will download, automatically Import the modules and save them to caches. You can refresh the modules with the --reload command.

Compatible with web browsers

Deno was created to be browser compatible. Technically, when using ES modules, Deno will not need to use webpack so it will always be compatible with browsers, even for older browsers like Internet Explorer.

TypeScript support

Using TypeScript is very easy in Deno without any configuration files. However, you can also write in JavaScript without any trouble.

Summary

Deno, which is a new Runtime Enviroment for TypeScript and Javascript, has been around for quite some time. However, Deno still has a way to go to match NodeJs.

With a decentralized approach, Deno will not depend on a package manager like Npm .

The latest version of Deno has been released here with a notable number of Stars.

Share the news now

Source : Viblo