AI in Practice

Bun rewrites JavaScript runtime with AI: from Zig to Rust

3 min read
Developer workstation with multiple screens showing parallel terminals during the migration of Bun's source code from Zig to Rust. Image generated with GPT Image 2
Developer workstation with multiple screens showing parallel terminals during the migration of Bun's source code from Zig to Rust.

TL;DR Too Long; Didn’t read

Bun developer Jarred Sumner ported 535,496 lines of Zig code to Rust in eleven days, using up to 64 parallel instances of Anthropic's Claude Fable 5 model. The switch cost about $165,000 in compute, per Sumner, backed by automated cross-checking and a full test suite. Version 1.4.0 is Bun's first fully Rust-based release.

Key takeaways

  • 535,496 lines of Zig code were fully ported to Rust in eleven days.
  • Up to 64 Claude instances ran simultaneously across four separate working copies of the codebase.
  • Sumner estimates the pure computing cost of the overhaul at about $165,000.
  • Anthropic acquired Bun's maker in spring 2026 and has funded the project since.
  • Bun version 1.4.0 is the first fully Rust-based release of the runtime.
  • Zig creator Andrew Kelley publicly criticized the split from his language.

The software developer Jarred Sumner had the JavaScript runtime Bun completely rewritten from the programming language Zig to Rust. Up to 64 parallel instances of the unreleased Anthropic model Claude Fable 5 did the work within eleven days. The rebuild of roughly 535,000 lines of code cost about $165,000 in compute, according to Sumner – independently unverified.

Automated cross-checking secures the new codebase

The transition ran between May 3 and 14, 2026, across four parallel working copies of the Bun repository. A total of 6,502 commits converted 1,448 Zig files into Rust code and added roughly one million lines net. The process consumed 5.9 billion input tokens and 690 million output tokens, according to Sumner’s report on the Bun blog. Sumner himself reportedly wrote no code, instead monitoring and steering the agents’ workflows.

One set of AI instances wrote the code while another set then checked it specifically for errors. This automated cross-checking treated compiler errors like a work queue and resolved about 16,000 error messages that way. No existing test was deleted or skipped. Every change had to pass the full test suite before it could merge into the main branch.

Address and leak sanitizers as well as test-driven fuzzing were also used. They caught three major bugs before the changes were merged. After release, developers and automated checks identified nineteen further regressions, which have since been fixed.

Anthropic has funded the project since acquiring Bun

Anthropic acquired Bun in spring 2026. The JavaScript runtime counts more than 22 million monthly downloads and also serves as the technical foundation for Anthropic’s own Claude Code tool. The acquisition explains why Anthropic apparently supplied the Bun team with extensive compute for the rebuild.

Independent developer and blogger Simon Willison called the project a case study in so-called agentic programming. Large rewrites of an existing codebase are traditionally seen as risky in software engineering. Willison sees the combination of parallel AI work and a comprehensive test suite as evidence that this risk can now shift. The switch went largely unnoticed in production, since mainly startup time on Linux got measurably faster – “boring is good,” as Willison puts it.

Zig creator Andrew Kelley spoke publicly about the split from his language. He reportedly felt relief at the decision and sharply criticized earlier working methods at the Bun project. His claims about the earlier collaboration remain a personal account with no rebuttal from Sumner on record.

Bun 1.4.0 ships as the first fully Rust-based release

With version 1.4.0, the Bun team shipped the runtime’s first release based entirely on Rust. Binaries came out roughly twenty percent smaller than before, and HTTP throughput rose by up to 4.8 percent. Several memory leaks in the build function disappeared entirely, since Rust’s automatic memory management catches missing frees at compile time.

According to the Bun blog, about four percent of the new code remains marked “unsafe,” mostly for interfaces to existing C and C++ code. Claude Code itself now runs on the Rust version of Bun and starts up ten percent faster on Linux, according to the company.

The real crux lies less in the language switch than in the method. If parallel AI agents can reliably rebuild large codebases under strict tests and automated cross-checking, that changes the calculus for rewrites across the entire software industry. It remains open whether the result can be repeated in comparable time and at similar cost without the tight integration with an in-house AI provider like Anthropic.

Frequently asked questions

What is Bun?

Bun is a JavaScript and TypeScript runtime built as a faster alternative to Node.js, reportedly downloaded more than 22 million times a month.

Is Bun now fully written in Rust?

Largely yes: version 1.4.0 is the first release based entirely on Rust, though about four percent of the code remains marked unsafe because it interfaces with existing C and C++ code.

Who paid for the rewrite?

According to Sumner, the computing costs were covered by Anthropic, which acquired Bun in spring 2026 and has since tightly integrated Claude Code's infrastructure with the runtime.

What is Claude Fable 5?

Claude Fable 5 is an Anthropic AI model from the so-called Mythos class that was unreleased at the time of the Bun rewrite and is built for long, autonomous coding tasks.

What role did automated code review play in the project?

Some AI instances implemented changes while separate instances specifically checked the code for errors and security flaws. Only code that passed the full test suite was merged into the main branch.


← Back to the blog