Research collaborate build

Jun 10, 2020

Deno — The NextGen Revolution?

Breaking down Deno and diving deep into what it provides to the developer community.
Devanand Padmanaban
Devanand PadmanabanSoftware Engineer
lines
Adapting to the new cutting-edge technologies has been a much-needed thing of the hour which leads to impactful revolutions!

Here comes Deno, the next-gen server-side framework; created by Ryan Dahl, the creator of Node JS himself.

Deno — What and Why?

Deno is a simple, modern, and secure runtime for JavaScript and TypeScript that uses V8 and is built in Rust.

“Demand and supply are two sides of the same coin.” -Someone

Evolutional demand in terms of technology has paved the way to create a new framework called Deno. To exactly know the necessity of creating Deno from the instigator himself, check out this uber-cool stuff.

Is Deno a replacement to Node?

Obviously, it is unfair to compare both! Remember the era, when nobody could ever think of 'JavaScript for Server-side', the universe had other plans to build a gem called NodeJS which was a gift to the Developer community, and the rest was history. Definitely, when Deno comes from the same team, it can be called an enhanced, highly secure, highly optimized server-side framework similar to Node JS which can achieve even more wonders.

Before moving on, know what is a Standard Library?

Deno has its own core modules as a Standard Library which do not have any external dependencies. They are reviewed by the Deno core team and updated regularly. You can look into the Standard Library here.

SWOT Analysis of Deno:

“The common facts of today are the products of yesterday’s research”- Someone

So lets hit the bullseye straightaway by doing a clear cut analysis on what Deno is about to provide us!

Strengths :

1. Deno is built on RUST language replacing C++ which is equally good on performance and improved security.

2. Deno creates a Sandbox for running the code which is very similar to JVM and runs the entire code as a single executable file. This stabilizes runtime security which never affects the computer hardware.

3. Deno has excellent TypeScript support which has a type-control over JavaScript.

4. Deno mainly depends on the promise (top-level async/await) feature which was the biggest drawback in Node JS.

5. Code optimization will make you awestruck because of no package.json and all old school stuff. Just directly import the URL and you are good to go!

Weakness :

1. Deno doesn’t support NPM and alternatively has its own third-party modules. I see this as a weakness because in the starting phase it takes time for all kinds of third-party modules to provide support for Deno. Also, migration of older Node JS projects which was built on a larger scale previously will be tough perhaps, as most of the projects currently depend on NPM.

2. Deno allows direct URL imports from Standard Template Library which is a new feature. This is a kind of tough task for the developer as we need a bit of time to search for the module URL in Standard Library.

3. Deno actually converts the TS codes into JS while compiling. Deno uses Microsoft's TypeScript compiler to check types and produce JavaScript. Compared to the time it takes for V8 to parse JavaScript, it is very slow. The Deno team is trying to enhance this by taking V8 Snapshots and comparing it, which is still in progress. 

Opportunities :

Deno provides a lot of improvements in terms of security. This is a very valid point for any Developer switching to Deno because it uses command-line arguments to enable or disable access to different security features. Since everything has been wrapped with a flag from basic network preferences, Deno sounds like a very reliable framework.

Threats :

Deno can be considered as a better version of Node which fixes the security breaches in the former. So, the major threat for Deno is to convince Developers to use it as an alternative for Node JS. It will definitely take Deno a lot of time to reach its potential and popularity. Node JS came as a flagship killer to solve the problems that PHP had and we have to wait and see whether Deno does the same!

Hands-on Deno — Everything about!

Let's start doing and everything falls under place — Me!

Installation :

Using Shell (macOS and Linux):

curl -fsSL https://deno.land/x/install/install.sh | sh

Using PowerShell (Windows):

iwr https://deno.land/x/install/install.ps1 -useb | iex

Using Scoop (Windows):

scoop install deno

Using Chocolatey (Windows):

choco install deno

Using Homebrew (macOS):

brew install deno

Using Cargo (Windows, macOS, Linux):

cargo install deno

Direct Download

Deno binaries can also be installed manually, by downloading a zip file at

https://www.github.com/denoland/deno/releases

After installation check-in your command line using

deno --version

If you want to download Typescript manually (Optional)

npm install -g typescript

Note: Make sure you have the npm library installed for the above code to run

Deno Basic Commands:

deno --version - For checking the version of Deno deno help - For Deno related help and actions deno run - To run the Deno code and make the server up deno run --reload - To reload all the modules deno run --allow-net=<allow-net> - To allow network access

Quicklinks:

  1. https://deno.land — Deno Official Website
  2. https://deno.land/std/ — Deno Standard Library
  3. https://deno.land/manual/ — Deno Setup Manual
  4. https://deno.land/x — Deno Third-Party Modules

Node has Express, Deno has?

Pogo, the easy-to-use, safe, and expressive framework for writing web servers and applications. Check this best companion of Deno in terms of all serverside operations.

Whats then? Get Denofied!

Try this sample code and look at the magic happening in your browser :

Hire our Development experts.
<span style="font-weight: 400;">import { serve } from "</span><a href="https://deno.land/std@0.55.0/http/server.ts"><span style="font-weight: 400;">https://deno.land/std@0.55.0/http/server.ts</span></a><span style="font-weight: 400;">";</span></p>
<p style="padding-left: 160px;"><span style="font-weight: 400;">const s = serve({ port: 8000 });</span></p>
<p style="padding-left: 160px;"><span style="font-weight: 400;">console.log("http://localhost:8000/");</span></p>
<p style="padding-left: 160px;"><span style="font-weight: 400;">for await (const req of s) {</span></p>
<p style="padding-left: 160px;"><span style="font-weight: 400;">req.respond({ body: "Hello World\n" });</span></p>
<p style="padding-left: 160px;">}


Denouement — The Takeaway!

Deno has already flabbergasted us in terms of performance optimization and security. Definitely any novice developer looking into Server-side frameworks can go to Deno for all the higher layer advantages that it gives, provided they also know the features that Node JS succumbs to. If you are someone who is always ready to explore cutting edge technologies and dive deeper into them, then Deno must be your right and best companion. Let's wait and see the magic and miracles that Deno is going to do!

Heartful Thanks, for meekly reading. I thank my entire GeekyAnts fraternity to support me in exploring new technology like Deno in its early stage, which our company audaciously does. Also, I extend my greatest gratitude to Pushkar for guiding me throughout this exploration.

Make a ? sound if you really found this article insightful! 

Hire our Development experts.