You can find everything you want to know about Deno, here at deno.land which is its official website.
In this story, we will cover the main difference between both Deno and Node.
<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.
- 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.
- It supports Typescript and has an inbuilt Typescript compiler.
- 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.
- Improved module system, which is more generic with
importstatements, 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.
- It doesn’t use npm and no package.json file for defining dependencies.
- 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.
- Uses V8 snapshots, which makes compilation and code incredibly run fast.
- It supports Browser APIs to like
setTimeout, etc. (why we need this if the code is server-side)
- 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
- It comes pre-loaded with many tools are present in deno like
deno info(dependency inspector),
deno fmt(for code formatting), etc.
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.