- Published on
Rewriting Bun in Rust
- Authors

- Name
- DeepHorus
In a landmark demonstration of AI-assisted software engineering, Bun creator Jarred Sumner has revealed the complete rewrite of the JavaScript runtime from Zig to Rust, accomplished primarily through coordinated coding agents. The announcement, published on July 8, 2026, details how Sumner leveraged Anthropic's Claude models to port over one million lines of code in just 11 days, a feat previously considered impossible. The rewrite is now live in Claude Code v2.1.181, released June 17, 2026, delivering a 10% faster startup on Linux while remaining functionally identical to users.
Bun, initially a high-performance JavaScript runtime written in Zig, had long struggled with memory safety bugs. 'Our bugfix list felt bad and I was tired of going to sleep worrying about crashes,' Sumner wrote. He praised Zig for enabling Bun's initial success but noted that the combination of garbage collection and manually managed memory created unique challenges that no language was designed to handle. This pain point drove the search for a safer alternative, ultimately selecting Rust for its compile-time memory safety guarantees.
The rewrite was enabled by Bun's existing TypeScript test suite, which served as a conformance harness for the AI agents. Sumner described an iterative workflow where agents generated Rust code, ran tests, and refined output through adversarial review. 'A few days in, a high % of the test suite started passing and I saw how much the new Rust code matched up with the original Zig codebase,' he recalled. The process consumed 5.9 billion uncached input tokens, 690 million output tokens, and 72 billion cached token reads, costing an estimated $165,000 at API pricingâa figure Sumner could afford as an Anthropic employee.
Sumner emphasized that this approach overturns Joel Spolsky's famous 2000 admonition against rewriting software from scratch. 'Coding agents powered by today's frontier models change that equation,' he argued. The key was a language-independent test suite with millions of assertions, combined with adversarial code review and process-level fixes rather than manual debugging. This allowed Sumner to merge a pull request exceeding one million lines with confidence.
Industry observers have noted the broader implications for software engineering. The success suggests that AI agents can now handle massive, safety-critical rewrites that were previously considered too risky. However, Sumner cautioned that the technique required careful oversight: 'For most of those 11 days, I monitored workflowsâmanually reading outputs and prompting Claude to edit the loop.' He also stressed that Zig remains a capable language, and the rewrite was driven by specific memory management issues, not a failure of Zig itself.
Since deployment, the Rust-based Bun has been running in Claude Code for nearly a month with minimal user impact. 'Boring is good,' Sumner concluded. He described the project as a case study in 'agentic engineering,' where human judgment orchestrates parallel AI agents to tackle ambitious software tasks. The rewrite has already sparked discussions about whether similar approaches could revitalize legacy codebases across the industry.
Looking ahead, Sumner plans to extend the technique to other parts of Bun and potentially to other performance-critical software. The cost, while high, is expected to drop as models improve and token prices decline. For now, the project stands as proof that with the right test infrastructure and AI assistance, even the largest rewrites can be accomplished in days rather than yearsâa shift that may redefine how fundamental software infrastructure is maintained and evolved.