Bun Completes Full Rewrite from Zig to Rust
JavaScript runtime Bun completes full rewrite from Zig to Rust using Anthropic's Claude Fable 5, announces improved stability and 22 million monthly downloads.
JavaScript runtime “Bun” has announced on its official blog that it has completely rewritten its core implementation from Zig to Rust. Following its acquisition by Anthropic in December 2025, a large-scale rewrite was carried out using a pre-release version of Anthropic’s latest AI model, Claude Fable 5. Bun has a adoption rate of over 22 million monthly downloads, and popular tools such as Claude Code and OpenCode use it as their runtime. This migration is seen as a decision prioritizing the project’s long-term stability and maintainability.
Bun’s Origins and Bet on Zig
Bun began in April 2021 when then-developer Jarred Sumner wrote the first code in Zig, inspired by a single-page Zig language reference published on Hacker News. He was strongly attracted to the emphasis on low-level control and performance.
Bun’s scope was extremely broad from the outset. It is an ambitious project that integrates a JavaScript, TypeScript, and CSS transpiler, minifier, bundler, an npm-compatible package manager, a Jest-compatible test runner, Node.js-compatible module resolution, HTTP/1.1 and WebSocket clients, and Node.js API implementations (fs, net, tls, and dozens of other modules) into a single binary.
The initial version was developed alone in a small apartment in Oakland over a year using Zig, before the era of LLMs (large language models) reached its peak. The official blog states, “Zig made Bun possible. Without Zig, we couldn’t have built it in such a short time.” While many projects with such a broad default scope become dead side projects, Bun survived thanks to Zig’s productivity.
Reasons Behind the Decision to Migrate to Rust
Bun’s broad scope has always been a challenge in terms of stability. The official blog has disclosed some of the bugs fixed in version 1.3.14. These include serious issues stemming from C-like memory safety, such as use-after-free crashes, memory leaks, double frees, and out-of-bounds reads.
Specifically, there were use-after-free during asynchronous processing in node:zlib streams, invalidation of internal stream pointers during hashmap reorganization in node:http2, ArrayBuffer detach issues in UDPSocket.send(), memory leaks in crypto.scrypt, SSL_SESSION leaks (approximately 6.5KB per call) in tlsSocket.setSession(), inability to garbage collect in fs.watch(), and double frees in the CSS parser.
These problems are less a reflection of Zig’s quality and more a result of the complexity of manual memory management in a runtime requiring large-scale and rapid development. Rust’s ownership system and borrow checker can prevent these memory safety issues at compile time, giving it an advantage in long-term maintainability.
Code Generation Assistance from Claude Fable 5
For this rewrite, a pre-release version of Anthropic’s in-development Claude Fable 5 was used. This model is specifically designed for code generation and refactoring, and is presumed to have been used to streamline large-scale language porting.
The original article explicitly states “Claude Fable 5 for much of the Rust rewrite,” making this a notable case of AI-assisted large-scale rewriting. Since the Bun team continued development within Anthropic after the acquisition, this appears to be an effort to simultaneously improve the product’s quality and create a feedback loop for the model itself by deploying it in a real-world scenario.
Impact on the Ecosystem
Bun has now grown to the point where major cloud platforms such as Vercel, Railway, and DigitalOcean offer first-party support. AI-assisted tools like Claude Code and OpenCode choosing Bun as their runtime further strengthens its position in the ecosystem.
The migration to Rust may improve memory safety and also increase interoperability with Rust’s rich ecosystem (libraries on crate.io). On the other hand, for the Zig community, Bun was a flagship project for Zig, so its loss carries significant impact.
Editorial Opinion
Bun’s migration to Rust can be assessed as a typical case of a rapidly growing project addressing technical debt. Over the next three to six months, improved memory safety is likely to reduce crash frequency and increase reliability for commercial use. Adoption is expected to accelerate, especially in use cases requiring long uptime, such as server-side rendering and API gateways. In the long term, deeper integration with the Rust ecosystem will make it easier to develop unique APIs and extensions beyond Node.js compatibility. If Anthropic’s AI models further advance their code generation capabilities, more projects may consider similar large-scale rewrites. This suggests that we are entering an era where the cost of language porting is dramatically reduced by AI.
From our editorial perspective, it remains to be seen how accurately the AI-assisted rewrite was performed and whether new bugs have been introduced after the migration. Community verification is awaited. Additionally, it is important to publish benchmark results to show how the transition from Zig to Rust changes Bun’s performance characteristics.
References
- Rewriting Bun in Rust - Bun Blog — Published 2026-07-08
- Anthropic Official Site — Acquisition-related information
- Related article: Meta Announces Free AI Image Generation Model Muse — Context on AI model code generation capabilities
- Related article: Google Photos UI Refresh and Gemini Video Editing Features — Implementation example of AI features
Frequently Asked Questions
- Why did Bun rewrite from Zig to Rust?
- The main reasons are improving long-term stability and maintainability. Development in Zig led to frequent memory-safety bugs (use-after-free, memory leaks, etc.). Rust's ownership system can prevent these issues at compile time. Interoperability with Rust's rich ecosystem is also expected.
- How long did the rewrite take?
- The exact duration has not been announced, but it was carried out after the December 2025 acquisition by Anthropic, using a pre-release version of Claude Fable 5. Given the large scale of language porting, it is estimated to have taken several months to about half a year.
- Will existing Bun users be affected?
- This rewrite involves internal implementation changes and is not expected to cause major changes in APIs or behavior. Since the primary goal is bug fixes and stability improvements, users are likely to benefit from a more reliable runtime. However, if performance characteristics change, it is recommended to check benchmark results.
Comments