VOOZH about

URL: https://thenewstack.io/meet-bun-a-javascript-runtime-for-the-whole-dev-lifecycle/

⇱ Meet Bun: A JavaScript Runtime for the Whole Dev Lifecycle - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2022-07-18 08:28:17
Meet Bun: A JavaScript Runtime for the Whole Dev Lifecycle
Frontend Development / Software Development

Meet Bun: A JavaScript Runtime for the Whole Dev Lifecycle

Bun aims to “run most of the world's JavaScript outside of browsers, bringing performance and complexity enhancements to your future infrastructure, as well as developer productivity through better, simpler tooling,” Sumner said in a YouTube interview.
Jul 18th, 2022 8:28am by Jessica Wachtel
👁 Featued image for: Meet Bun: A JavaScript Runtime for the Whole Dev Lifecycle

Designed as a drop-in replacement for running JavaScript and Typescript applications, Bun, a new JavaScript runtime built with a JavaScriptCore engine, was designed to be an all-in-one tool for bundling, transpiling, and running code at lightning speed.

Built by Jarred Sumner, a former frontend engineer at Stripe, Bun aims to “run most of the world’s JavaScript outside of browsers, bringing performance and complexity enhancements to your future infrastructure, as well as developer productivity through better, simpler tooling,” Sumner said in a YouTube interview, conducted by Ping Labs CEO Theo Browne.

Bun processes about three times more HTTP requests per second than Node.js when rendering React server-side. WebSocket, ReadableStream, and fetch are built in. Bun is also a transpiler so TypeScript and JSX work out of the box. Because Bun implements Node.js’ module resolution algorithm, npm packages also work.

“I’ve been frustrated by how slow everything is in JavaScript and I think, rather, I know, that JavaScript can get a lot faster,” Sumner said.

Beating a Slow Iteration Cycle

It was the speed that first brought on the need for something new that led to the creation of Bun. At that time, Sumner was developing a game in Next.js but was frustrated with the speed of the iteration cycle.The first solution was using the esbuild builder with Next.js but that didn’t bring the result he was looking for even after getting the technologies to work with plugins. Sumner’s next idea was to build a bundler and a transpiler but in the end, he built a runtime that includes a bundler and transpiler.

In the interview, Sumner explained that he knew JavaScript could be faster, because of an experience he had writing native code in Objective-C. The speed of Apple’s NSLog, which is the Objective-C equivalent of console.log in JavaScript, showed him how quickly it was possible to write to the terminal. It was a window of insight into a possible workflow that was slowing JavaScript applications.

After taking a look at a number of languages to build Bun, Sumner ultimately landed on the relatively little-known Zig. Zig’s “comptime” metaprogramming approach helped seal the deal. Comptime is metaprogramming based on compile-time code execution and lazy evaluation.

In Zig, the programmer can label a variable at compile time guaranteeing to the compiler that every load and store of the variable is performed at compile time. Essentially, comptime can run arbitrary code at compile time. “I just tried it and realized comptime would be an incredibly powerful tool for writing fast code,” Sumner explained.

Before Bun, Sumner never wrote a line of code in Zig. He credits the helpfulness of the discord server as one of the reasons why he was able to write Bun completely in Zig.

Comptime is used in the lexical analyzer, called the “lexer,” one of the slowest parts of parsing for Bun. Its job is to iterate through all of the text to determine if the current token is a valid identifier or a keyword. Because of comptime, Bun uses a bit-set that’s generated at compile time. This process gives a 2% performance boost to Bun.

For technical challenges, of which there were many, Sumner specifically states, “One of the things that working on Bun really taught me a lot is how to read error messages.” He’s referring to the phrasing in Zig’s error messages looking more similar to those in compilers. For example, the word token, which is mostly seen in lexing or parsing, was actually very common in the error messages he was receiving.

Sumner plans to have at least two permission models in the future with one being binary dead code elimination. This model will turn features on and off so if a feature is not used in an application, Bun will not have the code. Since there is a performance hit each time a permission is hit, there will be less performance hits depending on how many features are turned off.

Right now, Sumner recommends Railway or fly.io as the best deployment options. There will be a built-in option but it’s too early for any additional details. Express, Angular, and Jest’s testing APIs are specific technologies Sumner is working on adding proper support for but on JavaScript frameworks in general he says, “I wouldn’t say I’m competing with any framework because I want all of these frameworks to use Bun.”

Shaking the Bugs Out

And last but certainly not least, testing. Bun is new and it has bugs. Sumner is aware of this and credits the lack of widespread testing as one of the reasons why it’s so buggy. Of this he says, “bun doesn’t have enough test coverage and that’s why it’s so buggy.” Bun has a JavaScript test runner and the cli command is bun wiptest.

Developers and Sumner alike are very excited about Bun and though it’s still new, there are very high hopes for it. Sumner said, “I’ve been coming from the perspective of ‘it needs to work as much as possible with the existing ecosystem because people shouldn’t have to rewrite their code’ but maybe I should start thinking more about what if we make/what new things are possible because the APIs bun enables.”

TRENDING STORIES
Jessica Wachtel is a developer marketing writer at InfluxData where she creates content that helps make the world of time series data more understandable and accessible. Jessica has a background in software development and technical journalism.
Read more from Jessica Wachtel
SHARE THIS STORY
TRENDING STORIES
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.