DEV Community

Cover image for Simply Explained: Deno vs Node.js
Shawn Humphreys
Shawn Humphreys

Posted on • Edited on

Simply Explained: Deno vs Node.js

cover photo credits - Fernando Doglio

Most JavaScript developers are familiar with Nodejs as it is a well-established and highly-respected technology for making full-stack web applications. Nodejs is a popular open-source JavaScript runtime environment using the Chrome V8 engine. With the rise of Deno, could we possibly see a new leader in Javascript runtime?

Table of ContentsπŸ“‡

What is Deno❓

Deno is a new open-source runtime environment for JavaScript and TypeScript using the Chrome V8 engine. Just like Node, Deno utilizes event-driven architecture and asynchronous tools to build servers. Deno was founded by Ryan Duhl who is also the creator of the well-respected Nodejs. The major reason for creating Deno was that although Node is still a powerful, well-established tool for JavaScript there were still flaws about it that he wanted to address. He explained this at the JSConf EU in 2018. Watch the video below to learn more about the issues of NodeπŸ‘‡.

Why Deno?πŸ™‹

Under the hood, the major difference between Node and Deno is that Node was written on C++ as Deno was written in Rust. This provides Deno with a more strict validating procedure and is memory-safe compared to Node. Deno uses ES Modules as the default module system, whereas Nodejs uses CommonJS. With Deno, the dependencies are loaded using URLs which defeats the need for package manager or centralized registry(you heard me!πŸ“’ No package.json!😱) and comes with built-in utilities such as a code formatter while you would need to install dependencies for Node.

Example of imports with Deno and Node

Good News for TypeScript!😍

A big difference with Deno is that access needs to be explicitly granted which means better security. Because of this, Deno will run TypeScript right out-the-box(first-class)! This is a huge benefit as with Node you would need to install and configure the necessary toolsπŸ”§ needed to write in TypeScript.

Will Deno replace Nodejs?πŸ”‘

The short answer to this is not right now. Currently, Node is a well-established runtime that will be highly used for many years to come. Although Deno has a lot of potential to be the top technology for web applications, It is only in version 1.2.1 while Node is in version 14.7.0 as of July 29, 2020. Deno will be in development for a few years before it has enough features to be a competitor of Nodejs.πŸ“† The biggest disadvantage is that Deno does not support most third-party modules. As of 07/30/2020, there are 799 supported third-party modules. πŸ”– Click here for the current list of supported packages.

Should I start learning Deno?πŸ““

For beginners, I recommend learning Nodejs. Node is still highly-used for many companies and projects with only a handful of companies utilizing Deno. While Deno's third-party modules libraryπŸ“• is steadily growing, Node has a large list of modules ready-to-go for your next project. For experienced developers, this is your chance to be an early adopter of a highly-anticipated technology. It will serve a great benefit to show employers that you have been using Deno for some projects since version 1.0.0 has been released(at least until you find the "Must have 10 years of experience in Deno" job listings when Deno has only been out for five yearsπŸ˜•).

Let me know your thoughts!βœ‰οΈ

Are you currently exploring Deno? Do you think Deno will replace Node? If so, when you think Deno will be ready to replace Node? Comment down below your thoughts or mention what I left out about Deno or Node.

Thank you!πŸ˜ƒ

If this article provided any value to you, please leave a ❀️ or let me know your thoughts! Follow me to keep up when I post more articles as I will be posting five days a week until further notice. I might continue the new series of "Simply Explained" topics. Let me know what other topics I can simply explain to you!

Top comments (11)

Collapse
 
easrng profile image
easrng

I love the idea of deno because it brings web js and server is a lot closer together. Granted, you can't natively import typescript on the web, but it would be possible to have a service worker transpile the ts to js on the fly, making it work like deno.

Collapse
 
nemo011 profile image
Nemo

Hey! Nice article. You beautifully explained the topic. As a beginner, it often gets confusing whenever we hear a new name! Thank you for sharing. 😊

Collapse
 
mrshawnhum profile image
Shawn Humphreys

I am glad! I might continue to do this where I try to explain a topic as simple as I can. It has always been confusing for me in the beginning.

Collapse
 
nemo011 profile image
Nemo

That will be awesome! πŸ˜„

Collapse
 
kitarp29 profile image
Pratik Singh

Thanks Sir ,It was really helpful!!

Collapse
 
mrshawnhum profile image
Shawn Humphreys

I am glad it was! Thank you!

Collapse
 
hemant profile image
Hemant Joshi

I Love node

Collapse
 
mrshawnhum profile image
Shawn Humphreys

So do I!

Collapse
 
adam_cyclones profile image
Adam Crockett πŸŒ€ • Edited

If you want the deno experience for the web or you want to port node modules to deno, I am working on:

GitHub logo adam-cyclones / didi

Convert a project from common JS to ESmodules, with included bundler-like / task runner behaviour.

didi the dino is a pterodactyl logo

didi

A transpiler for JavaScript and Typescript, transforming CommonJS modules into distinct ES Modules

Who uses didi?

Frontend and deno developers will find didi useful.

Try it out.

didi is not ready for production however you can still take didi for a spin!

npm install -g @didi-js/client-didi-cli

# or

yarn global add @didi-js/client-didi-cli

Create a project an entry file, some installed node_modules and then require the browser dependency into your entry file using the base specifier.

const colorThief = require('colorThief'); // base specifier example, no paths needed

run didi path/to/example-project

The result should have output a new target directory within this example-project and also a server should have started on http://localhost:8086. You may see some console errors in the browser, this is normal for this stage.

You may also notice that your import looks like this:

import colorThief from "color-thief"; // still no path?
…
Collapse
 
andrewbaisden profile image
Andrew Baisden

All the more reason to learn and use TypeScript in future projects. Looking forward to when Deno becomes more stable.

Collapse
 
mrshawnhum profile image
Shawn Humphreys

Can't wait to get into Typescript!