The Beginning of the End ?   Deno vs Node.Js
Tags: deno, node, javascript, typescript
Published: 2020-06-08 21:01:23

The Beginning of the End ?   Deno vs Node.Js

Creator of Node.js regretted !	
Yes you heard that right , But WHY ?	
Ryan Dahl creator of Node.js thinks he made number of mistakes while designing Node.js	
Lets see what are those mistakes	
1. Not sticking to promises: Promises are the necessary abstration for async / await
2. Security: In Node.js program you have access to all sorts of system calls
3. The Build System GYP: Which was later dropped by Chrome but Node continued using it.
4. package.json:That made Node.js dependent on NPM ( Privately controlle repository) and Concept of modules directory of files to look into
5. node_modules: Heaviest object in the Universe	It complicated module resolution algorithm
6. require("module"):without .js extension	Not a JS type of thing
index.js,this Needlessly complicated Module loading system just to look fancy.

**Ryan Dahl came up with a solution to Node.js Problems**
##DENO:  A SECURED runtime for JavaScript and TypeScript

* Built in Rust language
* Uses V8 Engine
* Tokio
* Supports TypeScript out of the box.

Ships as a single executable file with no dependencies.Yup, No dependencies to be installed
Secured by default. No file, network, or environment access (unless explicitly enabled).
Has built-in utilities like a dependency inspector (deno info) and a code formatter (deno fmt).
Bundled into a single JavaScript file.

## Node.js vs Deno
Lets see how it fairs against Node.js
* Deno does not use npm
* It uses modules referenced as URLs or file paths
* Deno does not use package.json in its module resolution algorithm.
* All async actions in Deno return a promise. Thus Deno provides different APIs than Node.
* Deno requires explicit permissions for file, network, and environment access.
* Deno always dies on uncaught errors.
* It uses "ES Modules" and does not support require(). Third party modules are imported via URLs:
For eg:
```javascript
import * as log from "https://deno.land/std/log/mod.ts";
```
Remote code is fetched and cached on first execution, and never updated until the code is run with the --reload flag. so this will allow it to run later even if you are offline
Modules/files loaded from remote URLs are intended to be immutable and cacheable.

## Deno Installation
Now lets see how easily we can install Deno

Run following command on terminal

**Shell (Mac, Linux):**
```
$ curl -fsSL https://deno.land/x/install/install.sh | sh
```
**PowerShell (Windows):**
```
> iwr https://deno.land/x/install/install.ps1 -useb | iex
```
ref: [Deno.land website](https://deno.land/)

###Now lets build the HelloWorld !
Create a welcome.ts file and add basic javascript code
```javascript
console.log('Hello World!');
```
Run from command line
```
$ deno run welcome.ts
Hello World!
```

You can run programs from URL directly without even downloading it.
```
$ deno run https://deno.land/std/examples/welcome.ts
```

Isn't it that simple ?

###Would you like to have a detailed video on React + Deno with a functional CRUD Operation ?
###Please comment. 


You can find video on this [Deno vs Node.js: The Beginning of the End of Node.js](https://youtu.be/lw6ljR-lehk)
<a href="http://www.youtube.com/watch?feature=player_embedded&v=lw6ljR-lehk" target="_blank"><img src="http://img.youtube.com/vi/lw6ljR-lehk/0.jpg" alt="Deno vs Node.js" width="480" border="0" /></a>


Also you can more tutorials on Deno 
[Deno js Tutorial: Installation, HTTP Server, Deno Routing, Deno MySQL & Deno Rest API with MySQL](https://www.youtube.com/watch?v=1VtA2Q3w6cY)
<a href="http://www.youtube.com/watch?feature=player_embedded&v=1VtA2Q3w6cY" target="_blank"><img src="http://img.youtube.com/vi/1VtA2Q3w6cY/0.jpg" alt="Deno js Tutorial: Installation, HTTP Server, Deno Routing, Deno MySQL & Deno Rest API with MySQL" width="480" border="10" /></a>

[Deno Installation](https://youtu.be/1VtA2Q3w6cY?t=31)
[How to Run HTTP Server on Deno ?](https://youtu.be/1VtA2Q3w6cY?t=98)
[How to do Routing using Oak Middleware on Deno ?](https://youtu.be/1VtA2Q3w6cY?t=175)
[How to connect to MySQL Database in Deno ?](https://youtu.be/1VtA2Q3w6cY?t=364)
[How to build REST API with MySQL on Deno ?](https://youtu.be/1VtA2Q3w6cY?t=582)