Bun, the new Javascript runtime competing with Deno and Node

Bun, the new Javascript runtime competing with Deno and Node

Incredible amounts of discussion have taken place over the past couple years over Deno, Ryan Dahl’s successor to the NodeJS runtime meant to solve all the problems of his original creation.


In reality, despite Deno being largely stable and solving a lot of the issues with Node, it hasn’t received significant adoption because it isn’t compatible with existing node modules.

The development world was caught by surprise when Bun, a new Javascript runtime, launched its public beta about a week ago.

Bun’s pitch is that it is solving the problems that Deno does and is compatible with the existing Node ecospace, all while being significantly faster than both Deno and Node.

Let’s dive in  


The Issues with Node

Despite its widespread usage for the past decade, NodeJS has its fair share of problems.

The most egregious issue with Node is the incredibly convoluted nature of NPM and the entire module system. Not only can it be incredibly slow and unsecure, but the design of the system is drastically different from what is typical of web technologies.

Additionally, Node has near complete access to the system, which is a major security flaw.

On top of all that, some of the standard capabilities that a developer is going to need, like environment variables, https, or Typescript, aren’t included in Node out of the box.

Most of these issues seem to be solved with Deno, but at the expense of the entirety of the Node ecosystem. For the vast majority of developers, solving these issues simply isn’t worth jumping into a completely new ecosystem, and thus we haven’t seen adoption of Deno.


How Bun solves them

Now while Bun is very much in its infancy, it seems to largely be solving the lack of built-in support and the unfortunate speed issues of Node.

Bun claims to be more than twice efficient on many key tasks than both Node and Deno


Bun achieves this by not running on the V8 engine that Deno and Node use, and instead opting for the incredibly low level language Zig.

Additionally, Bun is a drop-in solution for Node, so it is already compatible with the entirety of the Node ecosystem that’s out there.


Trying out Bun

You can install Bun on Mac and Linux with:

curl https://bun.sh/install | bash

And then you can run a js file with:

bun run index.js

And you can install your NPM packages with:

bun install package-name

As you can see, the CLI is effectively identical to Node’s, which means there’s no learning curve.


What to Keep in Mind

Keep in mind that Bun was launched barely over a week ago. It is still very-much full of bugs. You are likely to run into some issues if you are trying to play around with it.

Additionally, this means we are yet to see what comes of this project. Will it really solve all the issues of Node and finally dethrone it? Maybe. But it might also be the case that Bun simply can never achieve the stability of Node.

We will likely find out the fate of BunJS over the next year…