Node.js
- Node is an open-source, lightweight, cross-platform runtime for JavaScript
- Node was created in 2009 by Ryan Dahl
- It’s based on an event-driven architecture and async I/O
Built on the V8 JavaScript engine, Node executes JavaScript code outside a web browser and allows devs to write command line tools and run event-driven server-side scripts.
It handles requests by executing a single-threaded loop registered in the system, and each request triggers a JS callback function. Moreover, it also distributes the CPU load by spawning threads for continuing the CPU-intensive or out-blocking tasks.
This callback scaling mechanism can handle more requests with less memory usage than other competitive frameworks, making it a more efficient option.
Callback hell
When the app gets complex the nesting callbacks leads to callback hell!
Deno
- Created in 2018 by Ryan Dahl (and others)
- Built on the same v8 JS engine and with Rust, Deno was was created to bypass the flaws in NodeJS
- The runtime offers native support for TypeScript and WebAssembly
- It’s more secure due to it’s adherence to web standards. Deno programs don’t have access to the filesystem, the network, etc. — you need to explicitly opt into those via permission flags. Deno’s permission flags extend to its dependencies
- Deno support using NPM packages
- Deno’s modules are hosted in a decentralized manner
Bun
- Created by Jarred Sumner, Bun is build on the JavaScriptCore engine instead of the v8
- It is complete with a bundler, test-runner and a package manager compatible with Node
- It has built-in support for TypeScript and JSX
Bun theory
Often in programming and engineering, something doesn’t quite work how we want it to, and so we create workaround systems. Then, new processes and systems come out that also rely on those old workarounds. It’s fine and everything works, but in theory, it could all work faster and more efficiently if we weren’t limited by that very first band-aid solution right?
That’s Buns theory also.
The reason it’s so fast is because it solves those band-aid problems that everything else has had to work around. They went back to the original issues and fixed them, meaning it can perform at much higher speeds, shaving off milliseconds here and there, that all add up.