What is Deno? Will it replace Node.js?
Tags: deno, node, javascript, webdev
Published: 2020-05-17 19:05:17

This is my first blog ever. Hope you all like it! ✌

__Deno v1__ has just recently released and this is a new runtime for JavaScript. So think about Node as what you already know and Deno is upgraded newer version of Node.js. It is created by the exact same person who created Node.js. It is built using V8 engine, Rust & TypeScript 🔥

**Ryan Dahl** is the creator of Deno. He saw all the shortcomings and old technology used in node.js, So he decided to built a better version of Node.js. But by the time he realized that Node.js needs some upgrade, it was impossible for him to do so. Because Node.js gained so much popularity in such a small amount of time, there were so many packages and applications using Node.js everywhere. So Ryan Dahl couldn't afford to take the risk of manipulating Node.js and breaking things all over the internet. So he wanted essentially to recreate node.js in a better form and that's why they he created Deno. Deno is very similar to Node.js and do a lot of things that node does but with a lot of advantages. So here are the advantages of Deno :

##**1) Deno is built in TypeScript**
One of the biggest advantage of Deno is it has TypeScript support. You dont have to manually configure your environment to work in TypeScript, you can use it right out of the box with Deno have compiler and everything built-in so you dont have to worry about any TypeScript configuration. *It's all there for you!*

##**2) Browser compatibility & Module imports**
So in node.js if you want to for ex, fetch a resource, you have to import a library to do that,
while in the browser you just use fetch. Also you will notice a lot of the Node based API are all using callbacks instead of using Async/Await. So in Deno they have scratched all of that old code
got rid of that and said, " *we are gonna make everything promise based* ". So in Deno everything will be based on promises and Async/Await. 

And on top of this, when you import a modules instead of doing traditional Node.js way using '*require(module)*', you can simply import things using browser based '*import/export*' syntax
from ES6. This allows us to do things similarly like we would do in the browser. On top of that, all of the browser based API built on Deno can be run in the browser or outside the browser using Deno & *this is really POWERFUL!*

On top of that browser compatibility, Deno takes it even a step further, they have included a library with a bunch of useful packages which normally browser doesn't provide us. So we have to follow a standard library without worrying about browsers. *How cool is that!*

##**3) Handling Security**
Deno is based around Security as its first principle. So Deno scripts cannot access the hard drive, open network connections, or make any other potentially malicious actions without permission. Deno provides us with a command-line flag **'--allow-net'** to give access to all the external permissions for script.

If you import a package and somehow it is corrupted or malicious or contains bad code which can corrupt your files or delete all the files on your system, if you run script containing that package in Node.js you would definitely lose everything on your computer it would delete everything but in Deno, unless you explicitly give your program the ability to delete files from your computer, your program wont be able to do anything like that without your permission. So Deno really cares about your Security!

##**4) Package management**
With node.js, you get *npm* to manage your packages. But in Deno, you can directly install packages from URL or directly use them by importing that package as an library in your script from URL. 
On top of that, there is no *'package.json'* file for managing dependencies and there is no *'node_modules'* folder, all of that is handled in the background by Deno and stored in the computer as a central dependencies. So you dont have to worry about massive node_modules folder or package.json files to use packages. *Clean Workspace!*



###**Closing thoughts** : 
As excited as you all are to gets your hands on Deno, I am too! 
Some of you will ask "*Is it going to replace Node.js?*"
Well, that's not going to be the case right now. To be honest, Deno has just released its version 1 it is still in its beta version, this means they are still working on its features to put it out in the market. I know it has so cool features but it is still in its early stage, even its browser compatibility is not 100% sure they are still implementing browser APIs and they are going to continuously implement those as time goes on, so that is going to be a continuous effort. 
Another question is "*Should I learn Node or wait for Deno to come?*"
I recommend you should learn Node.js first because there is not much Deno based APIs. If you skip Node.js you are missing a whole world of Node.js, npm and its ecosystem. Unless you know the downside of node how would you know the advantages of Deno. So use Node.js as of now, let Deno build its ecosystem then it will be ready to take over Node.js! It's not gonna take days or months it may take 4-5 years for Deno to make its mark onto Web World. Hope you liked it! Thank you! 

###**Follow me on** : 
*Instagram* : [ @ui.ashwin ](https://www.instagram.com/ui.ashwin/)
*Twitter* : [@ashwin4real](https://twitter.com/ashwin4real)
*Linkedin* : [Ashwin Khode](https://www.linkedin.com/in/ashwin-khode/)