DEV Community

Pramuda Liyanage
Pramuda Liyanage

Posted on

What is Deno js?

=======What is Deno?==========

Deno is a simple, modern and secure runtime for JavaScript and TypeScript that uses V8 and is built in Rust.Deno is essentially a shell around the Google V8 JavaScript engine.

======Why use Deno?===========

Deno’s features are designed to improve upon the capabilities of Node.js. Let’s take a closer look at some of the main features that make Deno a compelling alternative to Node.

Security (permissions) in Deno
Among the most important of Deno’s features is its focus on security.

As opposed to Node.js, Deno by default executes the code in a sandbox, which means that runtime has no access to:

**The file system
**The network
**Execution of other scripts
**The environment variables

====Deno Features====

This is a list of few of Deno's features:

**Modern JavaScript: Node.js was created in 2009, and since then JavaScript has gotten a lot of updates and improvements. So Deno, as expected, takes advantage of more modern JavaScript.

**Top-level await: Normally, when using async/await in Node.js, you have to wrap your awaits inside of an asynchronous function, and you have to label it async. Deno makes it possible to use the await function in the global scope without having to wrap it inside an async function, which is a great feature.

**Typescript support out of the box: This is my second favorite feature—there is nothing more fun than having a little more control over your types in projects. This is the reason why I started building most of my projects in Go.

**Built-in testing: Deno has a built-in test runner that you can use for testing JavaScript or TypeScript code.

**A single executable file: If you have used Golang, the idea of shipping just a single executable file will be familiar. This is now present in JavaScript with the help of Deno. So say bye to downloading hundreds of files to set up your development environment.

**Redesigned module system: This is my favorite feature:, Deno has no package.json file, nor huge collections of node_modules. It has its package manager shipped in the same executable, fetching all the resources for you. Modules are loaded onto the application using URLs. This helps to remove the dependency on a centralized registry like npm for Node.js.

**Security: With Deno, a developer can provide permission to scripts using flags like --allow-net and --allow-write. Deno offers a sandbox security layer through permissions. A program can only access the permissions set to the executable as flagged by the user. You're probably asking yourself, "How will I know which flags I have to add to execute the server?" Don't worry; you will get a message in the console log asking you to add a given flag. Here is a list of the flags:

--allow-env allow environment access
--allow-hrtime allow high resolution time measurement
--allow-net= allow network access
--allow-plugin allow loading plugins
--allow-read= allow file system read access
--allow-run allow running subprocesses
--allow-write= allow file system write access
--allow-all allow all permissions (same as -A)

Thank You....
Pramuda Liyanage
-Fullstack Developer-

Top comments (0)