What Is Bun and Does It Live Up To The Hype?

Bun, a new JavaScript bundler, was announced, and there were a couple of excellent reasons why many people took notice. While it is still early days for Bun, it is already showing a lot of promise and is worth keeping an eye on for the future.
What Is Bun and Does It Live Up To The Hype?

What Is Bun?

Bun is a fast, all-in-one JavaScript runtime that allows users to bundle, transpile, install and run JavaScript as well as TypeScript projects. It was built from scratch by Jarred Sumner, a former frontend engineer at Stripe, who describes it as "experimental software" (https://github.com/oven-sh/bun). Sumner wrote Bun in ZIG, which is a low-level programming language sharing similarities with C or Rust. Most of it was written entirely from scratch, including the JSX/TypeScript transpiler, npm client, bundler, SQLite client, HTTP client, WebSocket client, and more.

What Is The Focus Of Bun?

There are already existing modern JavaScript runtimes like Node and Deno, so what exactly is it that sets Bun apart from these? According to the official Bun website, Bun focuses on three main things. First, it is designed to start fast; next, it should offer new levels of performance by extending JavaScriptCore (the engine). Finally, it is being designed to be a "great and complete" tool that includes everything from bundler and transpiler to package manager.

Bun's overall goal is to run most of the world's JavaScript outside of browsers and bring performance and complexity enhancements to the future infrastructure of users. Through the use of better, more straightforward tooling, it also aims to enhance developer productivity.

What Separates Bun From Node and Deno?

While it fulfills the same functions as Node and Deno, a few things set Bun apart from the pack. As mentioned earlier, it is written in ZIG, which is a system language that is also currently still under development. This is in contrast to Deno, which is built on Rust, and Node, which uses C++. According to Sumner, he chose ZIG as the lack of hidden control flow makes it simpler to write fast software. The only potential downside is that ZIG does not have the built-in memory safety of Rust. Also, whereas Node and Deno use Google's V8, Bun makes use of the faster WebKit JavaScriptCore engine. In fact, the developer of Bun was able to implement a lot of performance fixes to JavaScriptCore in the process.

On his Twitter account, Jarred Sumner stated that one of the things he is most excited about is Bun install. According to Sumner, Bun for a simple Next.js app, Bun installs npm packages about twenty times faster than yarn and a whopping 49 times quicker than npm install. Sumner also revealed that Bun can handle over one million lines of JavaScript (input) per second. He added that Bun's WebSocket client has higher throughput than the "ws" npm package and Deno's. An infographic on the official Bun website shows far ahead of node and deno Bun is in terms of HTTP requests per second. In addition, it is supposedly 14 times faster than Next.js for reloading CSS and only takes a couple of milliseconds to clean projects from dist and node_module. To make Bun as fast as it is, an enormous amount of time was spent profiling, benchmarking, and optimizing things.

Conclusion

As stated before, Bun is still an experimental project, but it is already apparent that it has a lot of potential. Its performance is undoubtedly eye-catching, and its npm module compatibility is a great feature. Most JavaScript projects still involve having to package the source into a more standard format, such as with Typescript, so having Bun automatically take care of these things simplifies the process considerably. For example, Bun can automatically transpile TypeScript files to JavaScript without the need for any extra configuration. The same applies to the web-specific APIs that are built into Bun.

In its current state, it will likely only be used in special scenarios, but given enough time and effort to mature, it can become a serious contender and is worth keeping an eye on. Since all the code for Bun is available on Github under an MIT license, it is easy to take a look at it yourself. In addition, Bun has an official Discord (https://bun.sh/discord) for anyone with questions or who wants to help with the project.

Ready to start?

Get in touch or schedule a call.

Get in touch

Our blog
Latest articles
Tool and strategies modern teams need to help their companies grow.
Ultimate Guide to EV Roaming: The Executive Playbook
Roaming refers to the ability of an EV driver to access charging infrastructure from various operators without the need for multiple subscriptions or membership cards. With growing pressure from regulators and competition, providing a seamless EV roaming experience is increasingly essential to the survival of Charge Point Operators (CPOs). In this guide, we'll explore the critical aspects of implementing EV roaming. We'll provide clear insights and actionable recommendations to help you make informed and strategic decisions.
5
min read
Creating User Personas to Evaluate a CSMS
Creating and understanding user personas is more than just a trendy exercise. It's a way to get deeper insights into the actual needs and preferences of different users within your system. For any organization, this understanding is crucial.
5
min read
The Great CSMS Debate for CPOs: To Buy or To Build?
One of the most frequent dilemmas we encounter in the realm of software solutions is the age-old debate: to build or to buy? This question, seemingly simple on the surface, is layered with complexities and considerations.
5
min read
Download whitepaper
Download Whitepaper