Deno is a javascript runtime same as Node, reached its 1.0 release status on May 13, 2020. Deno was developed by Ryan Dahl, the same person who developed Node. Two Javascript run-times by the same person. This raises many questions — What made Ryan develop another Javascript runtime? What is wrong with Node? Is Deno going to replace Node? Let’s find answers to all of these.
Node was designed in 2009 when Javascript was a much different language. Since then, through standards organizations like ECMA International, the Javascript has been improved continuously. For instance, there were no Promises or async/await when Node was developed. Node’s counterpart to promises was the EventEmitter which has a back-pressure issue and later it was mitigated with extra code.
On other hand, out of necessity, Node had to invent concepts that were later taken up by the standards organizations and added to the language differently.
With the continuous evolution of Javascript and new additions like TypeScript, building and managing Node projects needed extra heavy lifting work. Since Node’s first release, Javascript and its ecosystem have changed enough to consider simplifying Node.
In a single line, Node has redesigned to Deno to fix its flaws.
If you are curious and want to understand the design mistakes of Node, check this below video by Ryan Dahl — Regret about Node.js
According to Deno’s official page, Deno is ‘A secure runtime for JavaScript and TypeScript’. This definition has a very close match to Node except for the terms security and Typescript. Let’s understand this a bit more with a Deno sample and find out how it is different from Node.
I am running windows, so I installed it using a power shell. For all install options, look at here.
iwr https://deno.land/x/install/install.ps1 -useb | iex
Run the command “deno -V” to confirm successful installation. This will give the current version (1.0 as of writing this) of deno.
Here is the simple typescript code in Deno.
We are importing serve from a web resource, spinning up the server at port 8000 and listening to it. Run the code with the below command.
deno run sample.ts
This will throw an error — Uncaught PermissionDenied error.
Before we fix the error, let’s dig deeper to understand how this code is different from Node.
Deno is an alternative to Node. But it is very new, immature and it will have bugs. It has been in development for 2 years now and there will be a lot of development in the coming year. Deno initial release 1.0 is stable, however, it might not be the right choice for everyone right now. Deno is not compatible with Node packages. All the functionality which is not yet ready for stabilization has been hidden under the ‘- -unstable’ command line flag.
With all these, Node is not going anywhere. It is a huge ecosystem and a lot of company still uses it. Deno will co-exist with Node and might play an important role in the future. But, it is still nice to dive in to start to play around with it and do some experiments.
Legal Stuff