Is Bun 'Actually' Faster?

This ad is not shown to multipass and full ticket holders
React Summit US
React Summit US 2025
November 18 - 21, 2025
New York, US & Online
The biggest React conference in the US
Learn More
In partnership with Focus Reactive
Upcoming event
React Summit US 2025
React Summit US 2025
November 18 - 21, 2025. New York, US & Online
Learn more
Bookmark
Rate this content

The JavaScript ecosystem has evolved significantly, with Bun.js marking a notable milestone. Built from the ground up in Zig, Bun.js is an all-in-one JavaScript runtime featuring an integrated package manager, bundler, test runner, and Nodejs-compatible environment designed for the growing demands of edge computing and server-side applications. My presentation will explore Bun.js's foundational principles, highlighting its performance benchmarks against traditional runtimes like Node.js, seamless TypeScript support, zero-configuration framework, and innovative features such as built-in hot reloading and efficient file operations.

This talk has been presented at React Advanced 2024, check out the latest edition of this React Conference.

FAQ

Bun's bundler enables efficient loading, code compatibility, and framework functionality in JavaScript applications, supporting features like file system routing and server components.

Bun uses the JavaScript Core engine from Apple, which outperforms the V8 engine in many cases, leading to faster startup times on Linux compared to Node.js.

Bun's efficiency can reduce CPU usage, leading to lower electricity consumption and helping to slow down global warming by requiring less computational power.

You can visit the official Bun and ZigLang websites for more information, as well as explore additional resources like the public benchmarking demo repo mentioned in the presentation.

Bun's package manager offers commands like install, add, remove, update, link, and supports global cache, workspaces, lifecycle scripts, overrides, and resolutions.

Bun's test runner is built-in and Jest-compatible, allowing tests to be written in JavaScript or TypeScript. It runs tests significantly faster than other popular test runners like Vtest and Jest.

Bun is a modern JavaScript runtime built for speed and ease of use. It includes tools like a package manager, bundler, test runner, and runtime.

You can install Bun by running the command 'npm install -g bun' or by downloading the binary from the official website and following the installation instructions.

Bun was built on top of Zig due to Zig's readability, ease of understanding, and ability to write performant code, which enhances Bun's performance, stability, and compatibility.

Yes, benchmarks indicate that Bun is faster than other JavaScript runtimes such as Yarn, NPM, and Webpack, with specific tests showing Bun running significantly faster in various scenarios.

Devlin Duldulao
Devlin Duldulao
24 min
28 Oct, 2024

Comments

Sign in or register to post your comment.
Video Summary and Transcription
Welcome to React Advanced London. Today's agenda: what is bun? Features, benchmark, demo, key takeaways. Bun provides a better developer experience, faster CI, and decreased app file size. Building bun on top of Zig prioritizes performance, stability, and compatibility. Install bun with npm or download the binary from the official website. Bun is a comprehensive development toolkit with a fast and efficient package manager. Learn how to benchmark CLI commands using Hyperfine with flags. Compare different package managers. Bond is fast and provides a few features in its package manager: install, add, remove, update, link. Test the bond test runner against vtest and jest using hyperfine. Discover the features supported by the test runner and the importance of bundling in JavaScript applications. Learn about the main.js code, the performance comparison of different bundlers, and the features offered by Bun, including loaders and macros. Explore macros in Bonn and how to optimize the code by including the type macro. Discover the benefits of Bonn, such as reducing CPU usage and fast installation of node dependencies.
Available in Español: ¿Es Bun 'Realmente' Más Rápido?

1. Introduction to Bun

Short description:

Welcome to React Advanced London. Today's agenda: what is bun? Features, benchmark, demo, key takeaways.

So again, welcome to React Advanced London, and you're here with Devlin Dudula. That's me, and I prepared something for you. It's about bun. Is bun actually faster?

OK. So to give you a little information about me, an overview, so I'm currently based in Oslo, Norway, living here for five years now, originally from Manila, Philippines. And during the pandemic, since I cannot go home, I decided to spend my time writing books and then co-authored some.

And the agenda today would be what is bun? Features of bun, like package manager, test runner, bundler, runtime. We're going to do benchmark, right? But you have to take it with a grain of salt. I'm going to explain why a bit later. And then there will be a demo along the way. Then key takeaways. OK?

2. Benefits and Installation of Bun

Short description:

Bun provides a better developer experience, faster CI, and decreased app file size. Building bun on top of Zig prioritizes performance, stability, and compatibility. Install bun with npm or download the binary from the official website. Bun is a comprehensive development toolkit with a fast and efficient package manager.

It's going to give us a better developer experience, better DX, in short. Going to enjoy the development. The CI will be faster. It's going to run quick, saves us money. And if a bundler is efficient in decreasing the file size of the app, going to have lesser download time or lesser data for your users. That saves money, right? But actually, the direct impact of this to the environment is, it slows down global warming because you have lesser electricity to consume or lesser computers to consume. Because everything is fast.

So why did the creators of bun choose to build it on top of Zig? So Jared, the author, said mainly because of its readability and easy to understand nature of the programming language, which helps him to write a performance code. Here's an example code of Zig. Let's say you want to create a function that calculates the square of a number. But instead of doing it while your program runs, you want to figure it out before your program even starts. And with this comp time, you can tell Zig to calculate the square of a number when the program is compiled, and not when it's running. This means your program already knows the result before it even starts making your code faster and efficient. So by building bun on top of Zig, the creators have made a choice to prioritize performance, stability, and compatibility. And that's exactly what we get with bun, a modern JavaScript runtime that's built for speed and ease of use.

How to install bun? You can install bun by running the command npm install dash g bun. Alternatively, you can download the binary from the official website and follow the installation instructions. Now let's dive into its powerful features. So bun is more than just a JavaScript runtime. It's a comprehensive development toolkit that includes a package manager, bundler, test runner, and runtime. Let's take a closer look at bun's package manager. If you go to bun's website, you can see the result of their benchmark. And of course, as a best practice, you should have a validation about this, or we need to find evidence on how they do this. So bun's package manager is designed to be faster and more efficient than these alternatives. That's their take, while still providing the same level of functionality and compatibility. Benchmarking tools is not simple when you're, for example, measuring how fast a tool is. So that's why most of the time, we don't trust benchmarking because incomplete features of the tooling affects it. Some authors prioritize a feature than the other, and then they're going to be mismatched if you're using different tools because some have features, these specific features, some have not. Different ways of using also scripts, libraries, frameworks, it's going to be specific. Using different flags, they have different flags, right? Different machines also affects it.

3. Benchmarking CLI Commands with Hyperfine

Short description:

Learn how to benchmark CLI commands using Hyperfine with flags. Compare different package managers. Bond is fast and provides a few features in its package manager: install, add, remove, update, link.

Using different flags, they have different flags, right? Different machines also affects it. So, you know, benchmarking might be useless. But we are here to learn how you can run some CLI commands for benchmarking, and what you need to know. Here's how you can do benchmarking on your own using Hyperfine with some flags. You can install this with your Mac, Linux, or Windows with WSL2. And here, we're going to be comparing yarn, the version 4, you have PNPM, NPM, and then bund.

So basically, this is prepare here, this flag prepare means you're going to run a command before we run this install installation. For example, deleting node modules. Warm up means you're going to run it once to get cache and use cache. And then this runs here, dash runs, means how many times you want this to run. Like, for example, 10 or 3. And this is going to take, as you can see here, meaning there will be like 10 yarn install, 10 PNPM install, 10 NPM install, et cetera. And it will just get the average of it. But you can just use one if you want to really do it quickly. I'm going to do demo here. And actually, I've run it already. As you can see, bond, NPM, NPM, here are how long it took for NPM to complete it, bond, NPM, yarn. And then you got this summary. Normally, the one will be the winner here on top and then comparing it to the rest. For example here, bond, one. So it says here bond install run 3.73 times faster than yarn, 3.8 times faster than NPM, and then 4.93 times faster than NPM. What are these libraries? So this is just here, a medium size JavaScript application.

So that's how you going to do it. And this will be actually, this repo is public. You will see it later. And you can check and copy things here. And then I put everything here like how to get started with hyperfine, what tools you need, what should be installed in your machine. So bond, it's fast. But what are the things that we can do with this package manager? I will just show you a few things from bonds package manager. You have this bond install, add, remove, update, link.

4. Test Runner in Bond Package Manager

Short description:

Learn about common commands in the bond package manager. Test the bond test runner against vtest and jest using hyperfine.

You have this global cache, workspaces, lifecycle scripts, overrides and resolutions. So these are just common commands that you will find in package manager.

Now let's move to the test runner part of the bond. I'm going to use again hyperfine. And we're going to test it against vtest and jest. You can see here hyperfine, and do warmup and run them three times each. So that would be for tests. As you can see here, and we have a readme file for you to see what you need first. You might need typings here, by the way. So and these are just the same code. The difference is how do you import them. Because for example, in vtest, we need to import from vtest. I name it apple, so that would be like from vtest. I name it apple, so it would be like it's easy to run and distinguish. So that's going to be for vtest, the apple. Bond for banana here. So you're going to import it. Basically the same test. Orange would be for the jest. And just going to run it. And here, again, hyperfine warmup. I'm just going to wait. And first would be running vtest. Second would be bond test. And then last would be jest here. And we have the summary again, meaning it's already done, finished and says here bond test banana. So we know bond test. Then it says here, we have this 37.77 times faster than vtest and 56.44 faster than jest. But what about this 3.49 and 3.86? These are margin of errors that if you do it 3.49 more, times more, the data might be different by the time.

5. Test Runner and Bundler in Bond Package Manager

Short description:

Learn about the test runner in bond package manager and the bundler part. Discover the features supported by the test runner and the importance of bundling in JavaScript applications.

But what about this 3.49 and 3.86? These are margin of errors that if you do it 3.49 more, times more, the data might be different by the time. So this is just a figure that it can be different results whenever you run these tests. So that would be for test runner part of bond. Let's go back to the slides. So you can do a bunch of things with bond as a test runner. It is fast and has built in jest compatible test runner and tests are executed with the bond runtime and supports these features. You know, writing tests, use what you have learned from jest. Tests are written in JavaScript or TypeScript with a jest-like API. You can describe, test, async. You can also have watch flag for running tests. Lifecycle hooks like before each, after each. You can do set up and tear down anything you want before all, before each, after each, and after all. Create mocks with mock function. Looks like this.

And now for the bundler part. Bundlers also help in framework features. Bundlers enable framework specific features like file system routing, code collocation, and server components through plugins and code transformations. In short, bundling is essential for efficient loading, code compatibility, and framework functionality in modern JavaScript applications. Here, they have their own benchmark, you know, bundling 10 copies of 3.js on scratch with source maps and minification. And this is going to be our own. I'm going to use hyperfine again. We have prepare removing some cache. And this will be like parcel, roll up, ES build, bun, RS build, and then webpack using webpack-cli. And there's so many things here because I need to be explicit with which folder the output will be generated or the dist. So, let's go back to our IDE, our VS code. Going to be here. And it will all, again, give you some details of which one to install. Like parcel, roll up, ES build, bun, RS build, then webpack. Then running this. Hyperfine.

6. Main.js Code and Bun Features

Short description:

Learn about the main.js code, the performance comparison of different bundlers, and the features offered by Bun, including loaders and macros.

But again, sorry. Before we're going to run it, I'm just going to show you what type of code is here in this main.js. It's just Fibonacci. Very simple. Again, that's why it's hard to trust benchmarking could be depending on who's doing or writing the code. But I'm here again to teach you what tools you would need, what to remember, and we're going to run it.

So, just going to generate two directors here, the dist and out, because different bundlers use different director names. Then I'm going to move it here so you can see. Parcel is done, roll up is done, ES build is done, bun is done, RS build is done, webpack is done. Says here, bun, main.js. Again, bun is a winner here and says it runs 1.00 times faster than ES build. It's almost the same. 10.60 times faster than roll up. 36.63 times faster than RS build. 40 times faster than parcel and then 100 times faster than webpack. Okay.

So, let's take a look what different supports we can get out of the box from bun. This is using CLI or using JavaScript. Like this. And for loaders, these are default loaders both for bonding and also during runtime. You can write your own plugin. For example, something that does CSS extraction, macros and client server code collocation. Right? And in programming, both zigs, comp time, and buns, macro system are designed to perform computations at compile time rather than at runtime. However, they operate in different contexts and are used in very different programming environments. Here's a simple function that returns a random number. And then, you know, here you have to consider macros are indicated using import attribute syntax. If you haven't seen this syntax before, it's a stage 3. The TC39 proposal that lets you attach additional metadata to import statements. And you won't see the code of the random function in the bundle output because it was executed during the bonding. I can do a demo here really quick.

7. Macros and Bonn Runtime

Short description:

Learn about macros in Bonn and how to optimize the code by including the type macro. Explore the runtime features of Bonn, including the use of the JavaScript core engine for Safari and executing TypeScript files directly. Discover the benefits of Bonn, such as reducing CPU usage and fast installation of node dependencies. Visit Bonn and ZigLang websites for more resources and explore liciajs.com for using Bonn with JavaScript frameworks.

About these macros that I'm talking about. So, we have mat random. And you have this console here, right? And then I have here also again what run. Going to output. And as you can see, comparing it with a export function random that returns mat random. Going to main. You can see it here, right? Going to main. You can see it here, right? The problem is, I think this is heavy. It's still included here. What we're going to do is to include this type macro. See here. And then you have to change something in your TS config file module. Yes, next. Let's go up and look for the module. Let's go up and look for the module. Go back here. Then run it again. So, just going to optimize it for you once you have it. Okay.

I think we're running out of time. So, run time. So, for the run time part of Bonn, Bonn uses the JavaScript core engine developed by Apple for Safari, which outperforms V8, and in most cases, additionally, it's a transpiler runtime built with Zig, resulting to four times faster startup times on Linux compared to Node.js. And there's a few of what you can do in Bonn's runtime. You can execute TypeScript, SX files directly, Bonn automatically processes your ENV files, no need for any library, like .env and a lot more. We don't have a demo here for run time, but you can still go to the public repo of this demo and see the instruction there, how you can do it. I prepared something there, but unfortunately, we don't have time here.

So, key takeaways. Reduces CPU usage and continuous integration. Installing node dependencies is fast, running tests is fast, and bonding is fast. And resources here. Go to Bonn and ZigLang website. And if you want to use also a JavaScript framework using Bonn runtime, you can go to liciajs.com and this demo here, this whole benchmarking. And, yeah, thank you for listening Bonn and simple things that you can do for benchmarking. That's all. Peace out.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

React's Most Useful Types
React Day Berlin 2023React Day Berlin 2023
21 min
React's Most Useful Types
Top Content
Watch video: React's Most Useful Types
Today's Talk focuses on React's best types and JSX. It covers the types of JSX and React components, including React.fc and React.reactnode. The discussion also explores JSX intrinsic elements and react.component props, highlighting their differences and use cases. The Talk concludes with insights on using React.componentType and passing components, as well as utilizing the react.element ref type for external libraries like React-Select.
TypeScript and React: Secrets of a Happy Marriage
React Advanced 2022React Advanced 2022
21 min
TypeScript and React: Secrets of a Happy Marriage
Top Content
React and TypeScript have a strong relationship, with TypeScript offering benefits like better type checking and contract enforcement. Failing early and failing hard is important in software development to catch errors and debug effectively. TypeScript provides early detection of errors and ensures data accuracy in components and hooks. It offers superior type safety but can become complex as the codebase grows. Using union types in props can resolve errors and address dependencies. Dynamic communication and type contracts can be achieved through generics. Understanding React's built-in types and hooks like useState and useRef is crucial for leveraging their functionality.
Making Magic: Building a TypeScript-First Framework
TypeScript Congress 2023TypeScript Congress 2023
31 min
Making Magic: Building a TypeScript-First Framework
Top Content
Daniel Rowe discusses building a TypeScript-first framework at TypeScript Congress and shares his involvement in various projects. Nuxt is a progressive framework built on Vue.js, aiming to reduce friction and distraction for developers. It leverages TypeScript for inference and aims to be the source of truth for projects. Nuxt provides type safety and extensibility through integration with TypeScript. Migrating to TypeScript offers long-term maintenance benefits and can uncover hidden bugs. Nuxt focuses on improving existing tools and finds inspiration in frameworks like TRPC.
Stop Writing Your Routes
Vue.js London 2023Vue.js London 2023
30 min
Stop Writing Your Routes
Top Content
Designing APIs is a challenge, and it's important to consider the language used and different versions of the API. API ergonomics focus on ease of use and trade-offs. Routing is a misunderstood aspect of API design, and file-based routing can simplify it. Unplugging View Router provides typed routes and eliminates the need to pass routes when creating the router. Data loading and handling can be improved with data loaders and predictable routes. Handling protected routes and index and ID files are also discussed.
How Bun Makes Building React Apps Simpler & Faster
React Day Berlin 2022React Day Berlin 2022
9 min
How Bun Makes Building React Apps Simpler & Faster
BUN is a modern all-in-one JavaScript runtime environment that achieves new levels of performance. It includes BUN dev, a fast front-end dev server, BUN install, a speedy package manager, and BUN run, a fast package runner. BUN supports JSX, has optimized React server-side rendering, and offers hot module reloading on the server. The priorities for BUN include stability, node compatibility, documentation improvement, missing features in BUN install, AST plugin API, native Windows support, Bundler and Minifier optimization, and easier deployment to production. BUN's AST plugin API allows for bundle-time JavaScript execution and embedding code, potentially inspiring new frameworks.
Rethinking Bundling Strategies
React Day Berlin 2023React Day Berlin 2023
32 min
Rethinking Bundling Strategies
Watch video: Rethinking Bundling Strategies
The talk discusses rethinking bundling strategies, focusing on challenges such as long-term caching and improving the state of Next.js and Webpack. It explores handling immutable caching and content hashes, optimizing asset references and page manifests, and addressing issues with client-side navigation and long-term caching. The talk also covers tree shaking and optimization, optimizing module fragments and code placement, and the usage and relationship of TurboPack with Webpack. Additionally, it touches on customizing configuration and hash risks, barrel imports and code splitting, and entry points and chunking heuristics.

Workshops on related topic

React, TypeScript, and TDD
React Advanced 2021React Advanced 2021
174 min
React, TypeScript, and TDD
Top Content
Featured Workshop
Paul Everitt
Paul Everitt
ReactJS is wildly popular and thus wildly supported. TypeScript is increasingly popular, and thus increasingly supported.

The two together? Not as much. Given that they both change quickly, it's hard to find accurate learning materials.

React+TypeScript, with JetBrains IDEs? That three-part combination is the topic of this series. We'll show a little about a lot. Meaning, the key steps to getting productive, in the IDE, for React projects using TypeScript. Along the way we'll show test-driven development and emphasize tips-and-tricks in the IDE.
Mastering advanced concepts in TypeScript
React Summit US 2023React Summit US 2023
132 min
Mastering advanced concepts in TypeScript
Top Content
Featured WorkshopFree
Jiri Lojda
Jiri Lojda
TypeScript is not just types and interfaces. Join this workshop to master more advanced features of TypeScript that will make your code bullet-proof. We will cover conditional types and infer notation, template strings and how to map over union types and object/array properties. Each topic will be demonstrated on a sample application that was written with basic types or no types at all and we will together improve the code so you get more familiar with each feature and can bring this new knowledge directly into your projects.
You will learn:- - What are conditional types and infer notation- What are template strings- How to map over union types and object/array properties.
Deep TypeScript Tips & Tricks
Node Congress 2024Node Congress 2024
83 min
Deep TypeScript Tips & Tricks
Top Content
Featured Workshop
Josh Goldberg
Josh Goldberg
TypeScript has a powerful type system with all sorts of fancy features for representing wild and wacky JavaScript states. But the syntax to do so isn't always straightforward, and the error messages aren't always precise in telling you what's wrong. Let's dive into how many of TypeScript's more powerful features really work, what kinds of real-world problems they solve, and how to wrestle the type system into submission so you can write truly excellent TypeScript code.
Best Practices and Advanced TypeScript Tips for React Developers
React Advanced 2022React Advanced 2022
148 min
Best Practices and Advanced TypeScript Tips for React Developers
Top Content
Featured Workshop
Maurice de Beijer
Maurice de Beijer
Are you a React developer trying to get the most benefits from TypeScript? Then this is the workshop for you.In this interactive workshop, we will start at the basics and examine the pros and cons of different ways you can declare React components using TypeScript. After that we will move to more advanced concepts where we will go beyond the strict setting of TypeScript. You will learn when to use types like any, unknown and never. We will explore the use of type predicates, guards and exhaustive checking. You will learn about the built-in mapped types as well as how to create your own new type map utilities. And we will start programming in the TypeScript type system using conditional types and type inferring.
Build Peer-to-Peer Applications with Pear Runtime
JSNation 2024JSNation 2024
152 min
Build Peer-to-Peer Applications with Pear Runtime
WorkshopFree
David Mark Clements
David Mark Clements
Learn how to rapidly build peer-to-peer applications with Pear Runtime. No servers required. Understand peer-to-peer paradigms and construct applications from well-defined building blocks. This workshop will cover how to create both Desktop and Terminal applications (with discussion for Mobile) that work entirely peer-to-peer from anywhere in the world. By the end of this workshop you should know how to build a new type of highly scalable application with entirely reduced infrastructural costs (~0) along with suitable architectures and best practices for peer-to-peer applications. From the creator of Pear Runtime and the company that brings us keet.io. Table of content:- Introducing Pear- Initial Q & A- Getting Setup- Creating a Pear Desktop Application- Sharing a Pear Application- Running a Pear Application- Creating a Pear Terminal Application- Releasing a Pear Application- Architectural Discussions- Wrap-up Q & A
Practice TypeScript Techniques Building React Server Components App
TypeScript Congress 2023TypeScript Congress 2023
131 min
Practice TypeScript Techniques Building React Server Components App
Workshop
Maurice de Beijer
Maurice de Beijer
In this hands-on workshop, Maurice will personally guide you through a series of exercises designed to empower you with a deep understanding of React Server Components and the power of TypeScript. Discover how to optimize your applications, improve performance, and unlock new possibilities.
 
During the workshop, you will:
- Maximize code maintainability and scalability with advanced TypeScript practices
- Unleash the performance benefits of React Server Components, surpassing traditional approaches
- Turbocharge your TypeScript with the power of Mapped Types
- Make your TypeScript types more secure with Opaque Types
- Explore the power of Template Literal Types when using Mapped Types
 
Maurice will virtually be by your side, offering comprehensive guidance and answering your questions as you navigate each exercise. By the end of the workshop, you'll have mastered React Server Components, armed with a newfound arsenal of TypeScript knowledge to supercharge your React applications.
 
Don't miss this opportunity to elevate your React expertise to new heights. Join our workshop and unlock the potential of React Server Components with TypeScript. Your apps will thank you.