ππ½ Meet Bun: the brand new, all-in-one JavaScript runtime that can install npm
packages faster than yarn
and faster than npm
and claims to be 3x faster than both Deno
and node.js
. Oh, last small fact it was all built by one person Jarred Sumner.
So, what is Bun?
A new JavaScript runtime, so you don't need any longer node.js
, or Deno
, so ahead and uninstall them for your system now, just kidding we will still need them for a while.
Bun
just announced it's beta release and makes the claims that it's significantly faster that node.js
and Deno
.
But before we continue let's clarify something.
What is a JavaScript Runtime?
Let's think for a moment JavaScript by itself it's not very useful and it's needs to run thru an engine to convert it to machine code for a CPU.
The most popular JavaScript engine is google's V8, which powers chrome
, node.js
and Deno
and makes execution very fast with JIT (Just in time compilation).
Now JavaScript together with the engine it's not very useful, we still something else, the developers want that the engine will provide a user-friendly API(WebSockets, file system and more). So JavaScript Runtime it's all this together(JavaScript engine and APIs), that only what is missing for the developers is to write JavaScript and it will run on this platforms.
π So what it's so special with bun
?
First they are talking about better performance, but how they actually make it so fast π€?
- It doesn't use V8 π±, but instead use JavaScript Core from Webkit, this engine it's consider faster but more difficult to work with.
It's written in a low level programing language called
zig
, a relative new language similar toC
orRust
.-
Is all-in-one run time:
- Native bundler to replace tools like
webpack
- Native transpiler, so you can write
TS
code out of the box - Will also transpile your
JSX
not supported yet? - Support node core modules
import {readFile| from node:fs
- Support node APIs, which allow to
npm
packages to also work in bun - Implements node's module resolution algorithm, which means you can install packages from
npm
into bun and this packages install much faster, like magic πͺ. - Automatically loads environment variables from
.env
files. No more require("dotenv").load() - Own test runner, similar to Jest
- Native bundler to replace tools like
πͺInstalling npm
packges feels like magic πͺ
This is a small/medium project example
Sounds amazing, but remember this project it's on it's early days and there will be bugs π.
Resources
Thanks for reading
Top comments (0)