What’s your current JavaScript runtime, and why is it Node.js? But have you heard there’s a new solution in town? Bun is a native code bundler, transpiler, and task runner with a built-in npm client. The creators promised to fulfill our need for speed and prioritized Bun’s performance over all other features. In this article, I will show you how to start an existing Node.js project on this new JavaScript runtime and compare if Bun is really the fastest out there.

First things first, what is JavaScript runtime?

A runtime environment is where your program will be executed. You can do it:

  • by JavaScript engine built-in browser (V8 developed by the Chromium Project for Google Chrome)
  • on server environments (such as Node.js or Bun) which are de-facto implementations of a “browser” running on the server.

There are few Javascript runtimes on the market. As of writing this article, the top three look like this.

Node.js

Node.js – the most popular (by GitHub stars), the oldest, but above all “the first one”. Before Node, JS existed only in the browser, so we have a lot to be grateful for.

At The Software House, we run our JS applications on Node.js, as it’s an established JS execution environment. In fact, it’s the only one supported by AWS Lambda and GCP Functions.

If you’re here, you definitely know Node inside and out, so let’s move on.

Deno

In second place there is Deno. We’ve already made some attempts to try out Deno and we really gave it a chance. Unfortunately, we didn’t find it convincing enough to move to this still slightly immature JS runtime.

Read more about our Deno experiences:

But the fact was a fact – a competition appeared. We have been curious ever since if something else than Node.js and Deno would fulfill JS developers’ hopes for super fast JS applications.

And then Bun was baked in Oven!

What is Bun?

As of writing, the third place is occupied by fresh and crisp Bun – the newest and fastest-growing JS runtime. Bun attracted a lot of attention when it gained $7 million in funding in August 2022.

The entire Bun project focuses on performance and being an all-in-one tool (runtime, bundler, package manager, transpiler). 

In the “traditional” Node.js, you need the combined power of a couple of tools to achieve the same goals: npm, Webpack, etc.

How is Bun supposed to be faster than Node? 

Aiming to boost its performance, the Bun team wrote it from scratch in Zig, a low-level C alternative. The browser engine running JS code in Bun is based on JavaScript Core – the JS engine inside Safari that is considered faster than Node’s V8, the engine inside Chromium.

Bun ships and the development team claim it’s faster because of an enormous amount of time spent profiling, benchmarking, and optimizing things. The general theme: Zig’s low-level control over memory and lack of hidden control flow makes it so much easier to write fast software.