Rewriting Bun in Rust
Simon Willison Simon Willison ● Covered by 2 sources
Jarred Sumner rewrote the Bun runtime from Zig to Rust using AI agents to automate the port, addressing memory safety issues that caused use-after-free and double-free bugs in the original codebase. The rewrite consumed 5.9 billion input tokens and 690 million output tokens across 11 days of agent-assisted development, with costs estimated at $165,000 at standard API pricing. Startup performance on Linux improved 10 percent, and the new Rust version has been running in Claude Code since June 17th with minimal user-visible changes.
Why it matters
Rewriting Bun in Rust Jarred Sumner has been promising this blog post (since May 9th) about his Zig to Rust rewrite of Bun for significantly longer than it took him to finish the rewrite. Honestly, it was worth the wait. This is a detailed description of an extremely sophisticated piece of agentic engineering, featuring dynamic workflows, trial runs, adversarial review and all sorts of other interesting tricks. Jarred spends the first half of the post praising Zig for getting Bun this far. Then we get to a core idea in the piece, emphasis mine: Our bugfix list felt bad and I was tired of going to sleep worrying about crashes in Bun. I don't blame Zig for that - other users of Zig don't have the bugs we had, and mixing GC with manually-managed memory is an uncommon enough thing for software to need that no language really designs for it. We wouldn't have gotten this far if not for Zig, and I'll always be grateful. Until very recently, programming language choice was a one-way decision f