Signup/Sign In

Deno vs. NodeJS - No one is Dead!

Posted in Programming   LAST UPDATED: MAY 27, 2020

    Deno vs. NodeJS has been quite a hot topic for discussion since version 1.0 of Deno got released a week ago. Deno is a secure JavaScript runtime that can be used to compile JavaScript and TypeScript code too outside the browser.

    Deno is created by the creator of NodeJs and he has been very vocal about the regrets he had with NodeJS and how he tried to fix them in Deno in JSConf last year and in multiple tech talks this year. In case you don't know, his name is Ryan Dahl.

    deno vs. nodejs

    You can find everything you want to know about Deno, here at deno.land which is its official website.

    In this tutorial, we will cover the main difference between both Deno and Node.

    Just like node, deno is also built on the V8 engine, and Rust programming language. But if we have node why we need Deno. Well, JavaScript has changed a lot since 2009(when node was created), really a lot. We have support for Promises, async/await, ES modules, typed arrays, and TypeScript is also very popular now.

    NodeJS, design wise, architecture wise is more like any other backend programming language and not like JavaScript where things like importing a script is as simple as using the <script> tag and specifying the URL of the script, although module systems are good, but they are too strict and bulky. And in Node, we have a centralized distribution for these modules, which again is kind of a restriction.

    And Node is less secure.

    Top Deno Features:

    The following are some of the top features of Deno.

    1. It’s secure. An application written in Node gets permission to system calls, environment variables, accessing files, sockets, network by default. Whereas deno its permission driven so to access disk, network, subprocesses or environment variables, you have to provide permissions to the code which is like --allowed-read, --allowed-write, --allowed-net for networking, --allowed-env for accessing environment variables and so on.

    2. It supports Typescript and has an inbuilt Typescript compiler.

    3. Node was created in 2009, and since then many new JS features have been introduced like ES modules, Promise, Async, Await, etc, which are supported in Deno.

    4. Improved module system, which is more generic with import statements, and we can use URLs in code to import any module directly using the URL in the code, and at runtime the module is downloaded and cached for future. With this __node_modules and index.js are gone. For those who do not know about node, when we use a module, which is like a readymade code which can be used directly in the code like for image compression, or http module, etc. the node_modules folder in your project directory gets the module downloaded in it and the execution defaults from index.js, but not anymore.

    5. It doesn't use npm and no package.json file for defining dependencies.

    6. GYP Build System (used to compile C library and link it to Node if you need any C native library, useful if you are developing some module in Node) is used in Node. It doesn’t affect us as developers but there are better builder systems available now.

    7. Uses V8 snapshots, which makes compilation and code incredibly run fast.

    8. It supports Browser APIs to like unload, on unload, location, setTimeout, etc. (why we need this if the code is server-side)

    9. We can even run URLs using the demo command for example, deno https://deno.land/welcome.ts and yes everything you run or import on your code must have the extension specified .js or .ts

    10. It comes pre-loaded with many tools are present in deno like deno install, deno info(dependency inspector), deno fetch, deno fmt(for code formatting), etc.

    Here is a video summarizing all these points:

    Is NodeJS Dead?

    Well absolutely No! Deno sounds like a better version of Node, but it's still too early to say this.

    Deno is too young and Node is too stable.

    NodeJs is used by many big companies like Netflix, PayPal, etc, it has a large community, it is stable runtime and is a great choice to develop an application. It is possible that in the coming time when more and more developers adopt deno, that we will get to know about how stable deno framework is or how the developer community builds around it, etc.

    So if you are beginner, and in doubt, what to learn? I would suggest go for Node, as it is still a great platform but do keep an eye on deno framework too.

    About the author:
    I like writing content about C/C++, DBMS, Java, Docker, general How-tos, Linux, PHP, Java, Go lang, Cloud, and Web development. I have 10 years of diverse experience in software development. Founder @ Studytonight
    Tags:DenoNodeJSJavaScript
    IF YOU LIKE IT, THEN SHARE IT
     

    RELATED POSTS