An Introduction To Deno.JS

Posted By : Raghav Sehgal | 22-Jul-2020

Deno provides a runtime environment for JavaScript and TypeScript. It is based on the V8 JavaScript engine and the Rust programming language and is becoming increasingly popular in SaaS application development services


Deno could also be a secure TypeScript runtime built on V8, the Google runtime engine for JavaScript.

It was built with:

  • Deno’s core was written in Rust.
  • The event loop is written in Rust(Tokio).
  • It supports both JavaScript and TypeScript.
  • Google’s V8 engine.

Security (permissions) - It executes the code during a sandbox, which suggests that runtime has no access to:

  • The filing system 
  • The network
  • Execution of other scripts
  • The environment variables
  • Let’s take a glance at how the permission system works.
(async () => {
 const encoder = new TextEncoder();
 const data = encoder.encode('Hello world\n');
 await Deno.writeFile('hello.txt', data);
 await Deno.writeFile('hello2.txt', data);

When we run it by executing: deno run write-hello.ts

We are prompted with the following:
It requests to write access to "/Users/user/folder/hello.txt". Grant? [a/y/n/d (a = allow-always, y = allow-once, n = deny- once, d = deny-always)]

We are prompted twice since each call from the sandbox must invite permission. In fact, if we chose the allow always option, we might only get asked once. If we elect the deny option, the PermissionDenied error is going to be thrown, and therefore the process is going to be terminated since we don’t have any error-handling logic.

If we execute the script with the subsequent command: deno run --allow-write write-hello.ts

import { assertEquals } from "";


What If An Internet Site Goes Down?

Since it’s not a centralized registry, the web site that hosts the module could also be taken down for several reasons. counting on its being up during development or even worse, during production and that would be risky.

Since the cache is stored on our local disk, the creators of Deno recommend checking it in git-version system and keeping it within the repository. This way, even when the web site goes down, all the developers retain access to the downloaded version.

Deno stores the cache within the directory specified under the $DENO_DIR environmental variable. If we don’t set the variable ourselves, it'll be set to the system’s default cache directory. we will set the $DENO_DIR somewhere in our local repository and check it into the version system.


Do I Have To Import It By The URL All The Time?

Constantly typing URLs would be very tedious. Deno gives us two options to avoid this problem.

The first option is to re-export the imported module from an area file, like so:

export { test, assertEquals } from "";
Let’s say the file above is named local-test-utils.ts. Now, if we would like to again make use of either test or assertEquals functions, we will just reference it like this:

import { test, assertEquals } from './local-test-utils.ts';
So it doesn’t matter if it’s loaded from a URL or not.

The second option is to make an imports map, which we specify during a JSON file:

 "imports": {
 "http/": ""

And then import it as such:

import { serve } from "http/server.ts";
In order for it to figure , we've to inform Deno about the imports map by including the --importmap flag:

deno run --importmap=import_map.json hello_server.ts


Will It Replace Node.js Anytime Soon?

Not really, to be honest, the title may be a little bit of a clickbait. a number of us started using Node.js back within the day when it had been around version 0.10, and that we were using it in production! it had been a touch scary to inform you of the reality, but we were doing it because there was nothing love it around. Neither PHP, Python, nor maybe Ruby (let alone Java or .NET) could compare to having JavaScript and an asynchronous I/O model within the back-end beat one. And over these years, Node (and JavaScript) has evolved to satisfy the industry’s requirements. Is it perfect? Heck no! But like anything in life, there's no perfect when it involves programming languages.

Deno is not any different, just because immediately, it’s just the culmination of around 2 years of labor on a thought. It hasn’t been reviewed and put into weird and unintended use cases to ascertain how it deals with those border situations. Maybe during a year, we’ll start hearing from companies sharing their experiences with it, how they’ve solved the newly found shortcomings, and eventually, the community behind it'll adapt it to some extent where it's useful. Will it replace Node then? Who knows! We’ll need to wait and see.
We are a SaaS app development company with an extensive experience in building cross-platform web and mobile applications for varied business requirements. Our team of developers is skilled at using JavaScript-based technologies like AngularJS, NodeJS, and DenoJS for building, deploying, and launching scalable web applications for multiple platforms. We have a proven track record in delivering full-fledged SaaS application development solutions for clients from across the globe. For more information, reach us out at
#SaaSApplicationDevelopmentServices #SaaSAppDevelopmentCompany #SaaSApplicationDevelopment

About Author

Author Image
Raghav Sehgal

Raghav Sehgal is a Front-end Developer having Good exposure of HTML, CSS3, Bootstrap, JavaScript, Angular 6. He likes to listen music, improve coding skills, learn new technologies.

Request for Proposal

Name is required

Comment is required

Sending message..