Bun, the new Javascript runtime competing with Deno and Node
Tags: javascript, programming, webdev, react
Published: 2022-07-13 14:51:11

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](https://bun.sh/), 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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oi6yfxenbfcuhlrkl6j7.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cqj6u280qmdwq7fgnw5h.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lwyq1pf6gv4c9bb992fa.png)

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](https://ziglang.org/). 

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…

---
At [Codesphere](https://link.codesphere.com/PD), we’re also in the business of making web development faster, smoother, and less stressful. We’re building an all-in-one web IDE, DevOps tool, and cloud provider.

Happy Coding!