Welcome to Deno 🦕

Prashanth Wagle
4 min readFeb 16, 2020

For all folks outside the Javascript world out there, don’t worry, ITS COMING SOON!!!

Before jumping right into Deno, let me give a brief introduction about Node.js.

Will Deno replace Node?

As per the official website of Node.js,

“Node.js is a platform built on Chrome’s JavaScript runtime for easily building fast and scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.”

Node.js was invented in a time where Javascript was a “kid” language where it didn’t have the features that excites us in 2020. It is primarily used to build network programs. The below image shows the popularity of Node.js among professional developers according to the StackOverflow Developer Survey of 2019. This shows the level of traction that Node.js has obtained since a few years after its inception.

Source: StackOverFlow

In a little over a decade, the software managed to attract huge companies to give it a try. Some of these names include Groupon, Netflix, LinkedIn, IBM, Voxer, SAP, Paypal, Walmart, and many more. This shows the level of trust invested into Node.js and Javascript in general. PayPal especially has even benchmarked the performance of Node.js and Java and Node.js and the image displayed below speaks it.

Source: PayPal Engineering Blog (https://medium.com/paypal-engineering)

Is Node.js the perfect backend for the Industry? Perhaps not. Infact the creator of Node.js Ryan Dahl has given a talk in JSConf titled “10 Things I Regret About Node.js”. A few of them are enlisted below:

  1. Node.js has evolved with callbacks at the expense of the Promise API that was present in the first versions of V8.
  2. Node.js can have access to the file system and network which yields poor security.
  3. GYP (Generate Your Projects), the compilation system forcing users to write their bindings (links between Node and V8) in C++ while V8 no longer uses it itself.
  4. The “require” syntax omits the .js extension in files.
  5. The absence of a “window” object.
  6. The entry point “index.js” became useless after the require became able to support the package.json file.

The talk highlights about certain wrongful decisions undertaken while building the runtime. Currently, he is involved in the developing of “Deno” which is aimed at fixing Node.js problems. It is built with:

  1. Rust (Node.js was written in C++)
  2. Tokio (the event loop written in Rust)
  3. Typescript (Open Source language developed by Microsoft which mainly adds static features to Javascript)
  4. V8 (Google’s Javascript Runtime)

So what does Deno has on offer?

Typescript as the main language

Deno is integrated to run Typescript files by default. Typescript can compiled to JS using Babel or TS compiler. But now since TS is the main language, there is no overhead of compilation.

Typescript compiler is compiled into Deno. According to Ryan, “JS is supported and Encouraged” and TS compiler is is not invoked when JS is used which prevents unnecessary bloats.

Importing from a URL

The web was meant to be decentralized. Unfortunately it isn’t. Deno solves it by allowing imports directly from a link.

Eg. import * as log from “https://deno.land/std/log/mod.ts";

Code from a remote location is cached locally

Unlike Node which caches modules in the node_modules directory which is at project level, Deno caches it to a folder pointed by $DENO_CACHE. Hence a module used in one particular project need not be re-downloaded as deno enables modules to be cached in system level. Hence, the code doesn’t require a dependency management manifest (package.json) as it resolves the dependencies all by itself.

Improved Security

By default, Deno doesn’t have the permission to access the file system and the network unless the user explicitly allows the code to have access to these resources at runtime by responding positively to prompts or by using flags.

One deliverable, one executable

In order to ensure efficient distribution, Deno offers its own bundler (deno bundle) creating a single consumable (.js) at the time of delivery and later, a single executable binary (deno compile).

Conclusion

Deno, the new runtime for TypeScript and JavaScript, is an interesting project that has been steadily growing for quite some time now. As stated by Dahl himself at the “Holy JS” conference of 2019, Deno is not going to replace Node anytime soon as it has a long way to go for being production-ready.

With it’s decentralized approach, it takes the necessary step of freeing the JavaScript ecosystem from the centralized package registry that is npm.

Expect some major breakthroughs in this project. For those devs interested, make sure you star the official repository https://github.com/denoland/deno.

đź“ť Save this story in Journal.

👩‍💻 Wake up every Sunday morning to the week’s most noteworthy stories in Tech waiting in your inbox. Read the Noteworthy in Tech newsletter.

--

--