- Bun migrated over a million lines of code from Zig to Rust to enhance memory safety and long-term stability.
- The rewrite was achieved in weeks using AI agents, reaching 99.8% test compatibility on Linux x64.
- The move facilitates a larger contributor pool and strengthens the infrastructure powering Anthropic's Claude Code.
For a long time, the tech world watched as Bun carved out its niche as the speed demon of JavaScript runtimes. Starting as a bold bet by Jarred Sumner, it aimed to solve the sluggishness of Node.js and the complexity of fragmented tooling by bundling everything into one lightning-fast binary. However, while its initial foundation in the Zig language allowed for incredible performance, the project recently hit a massive turning point that has sent ripples through the developer community.
The big news is that Bun has undergone a monumental transition, rewriting its core in Rust. This wasn’t just a minor tweak; we are talking about a migration of over a million lines of code. This move signifies a shift from the raw, manual control of Zig to the industrial-grade safety and ecosystem of Rust, ensuring that Bun can scale not just in speed, but in reliability and maintainability for millions of users worldwide.
The Shift from Zig to Rust: Why Now?

When Bun first launched, Zig was the perfect choice. It offered low-level memory management and a pragmatic approach to performance that helped Bun dominate benchmarks in HTTP requests and WebSocket throughput. However, as the project matured, the limitations of Zig’s youth became apparent. The language lacks a stable 1.0 version, meaning updates can frequently break existing code, creating a stability headache for a project that now powers critical infrastructure.
Rust provides a different set of advantages. The primary driver was memory safety. Many of the bugs haunting the Zig codebase—such as use-after-free and double-free errors—are simply caught by the Rust compiler before the code ever runs. Additionally, since Bun was acquired by Anthropic, the stakes have skyrocketed. Bun now serves as the engine for Claude Code, meaning any runtime crash directly impacts Anthropic’s AI tools. Switching to Rust was essentially a move to battle-harden the software for professional, high-stakes environments.
An AI-Powered Engineering Feat

What makes this rewrite truly wild is how it happened. In what would normally take a huge team years to complete, this migration was accelerated by advanced AI coding agents. Using tools like Claude Code, the team managed to port the codebase in a matter of weeks. The process involved an agentic workflow: AI handled the initial port, the existing TypeScript test suite acted as a conformance check, and humans monitored the loop to fix systemic issues.
The cost of this operation was staggering, with an estimated $165,000 in API tokens. Billions of tokens were processed to ensure the new Rust code matched the original Zig logic. Currently, the rewrite has achieved a staggering 99.8% test compatibility on Linux x64 glibc, proving that AI can now handle massive, complex architectural migrations with surprising precision.
Impact on Performance and Development
Many are wondering if this swap kills the speed that made Bun famous. The short answer is: hardly anyone noticed. In fact, startup times on Linux actually improved by about 10%. Since both Zig and Rust compile to native machine code without a garbage collector, the performance gap is negligible. The real win is in the contributor ecosystem; it is far easier to find experienced Rust developers than Zig experts, which means faster bug fixes and broader platform support.
- Better Tooling: Rust’s mature crates like Tokio for async I/O provide a more stable foundation than building everything from scratch.
- Stability: The ownership model eliminates entire classes of memory bugs, leading to more consistent production performance.
- Cross-Platform Growth: While currently focused on Linux x64, Rust’s superior cross-compilation tools will make bringing Bun to macOS and Windows much smoother.
The Bigger Picture: The Native Renaissance
Bun’s journey is part of a larger trend where critical web tooling is moving away from JavaScript and toward native systems languages. We see this everywhere: SWC and Biome are replacing Babel and ESLint, and Zed is challenging VS Code by being built from the ground up in Rust. Even Python is seeing a shift with uv replacing traditional package managers.
This is essentially a return to using the right tool for the job. While JavaScript remains the king of the browser, the infrastructure that supports it—the runtimes, compilers, and linters—needs the raw power and safety of native code. The fact that an AI can now port a million lines of code suggests that the marginal cost of rewriting software for better performance has effectively dropped to near zero, opening the door for many other legacy tools to be \”Rust-ified.\”
The transition to Rust secures Bun’s future by combining its signature speed with enterprise-grade stability. With the backing of Anthropic and a massive leap in maintainability, Bun is evolving from a high-performance experiment into a reliable industry standard, proving that the combination of native languages and AI-assisted engineering is the new blueprint for modern software development.