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
- Not sticking to promises: Promises are the necessary abstration for async / await
- Security: In Node.js program you have access to all sorts of system calls
- The Build System GYP: Which was later dropped by Chrome but Node continued using it.
- package.json:That made Node.js dependent on NPM ( Privately controlle repository) and Concept of modules directory of files to look into
- node_modules: Heaviest object in the Universe It complicated module resolution algorithm
- 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
- Built in Rust language
- Uses V8 Engine
- 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).
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:
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.