Bun 1.4: The controversial AI-Driven Rewrite from Zig to Rust
In May 2026, the Bun team did something the software industry has been whispering about for years: they rewrote their entire runtime from Zig to Rust. Not over the course of a year with a dedicated team. In six days. Using AI agents.<br>At nearly a million lines of code, this is the largest AI-driven codebase migration ever attempted in public. And it shipped. Here's what happened, what it means, and why the developer community can't stop arguing about it.<br>The Numbers<br>Let's start with the raw facts:<br>~570,000 lines of Zig became ~682,000 lines of Rust (excluding AI-generated comments)<br>99.8% of the existing test suite passes on the first AI-generated port<br>13,044 unsafe blocks in the resulting Rust code (hand-written Rust projects of similar size average ~73)<br>999+ uses of static mut (global mutable state, the antithesis of Rust's safety guarantees)<br>262 instances of ManuallyDrop , 81 of mem::forget<br>Files as large as 9,765 lines (the JS parser, p.rs)<br>The largest PR in GitHub history was reviewed by coderabbitai[bot] and claude[bot]<br>How It Was Done<br>The rewrite used Anthropic's Claude Code with "dynamic workflows" -- a system that fans out work across hundreds or thousands of AI agents. Boris Cherny, head of Claude Code at Anthropic, described the approach:<br>"If you look at most Claude Code sessions, it's actually another Claude that does the prompting."<br>The pipeline worked like this:<br>Claude agents translated files from Zig to Rust in parallel<br>Each file had an "adversarial reviewer" -- a second AI agent assigned to find bugs in the first agent's output<br>Build and test feedback looped back into the agents for automatic correction<br>Jarred Sumner, Bun's creator, provided high-level oversight<br>Bun is owned by Anthropic (the company behind Claude), giving the team access to unlimited compute on the frontier model. This wasn't a $20/month coding assistant -- it was an industrial-scale AI operation.<br>Why the Switch?<br>Jarred Sumner cited several reasons for the migration:<br>Memory safety. Bun had accumulated a reputation for segfaults. The GitHub issue tracker was littered with crash reports. Rust's compile-time guarantees promised to eliminate entire classes of memory bugs that had plagued the Zig codebase.<br>Compiler velocity. The Bun team had been maintaining a fork of Zig's compiler (bun's zig fork got 4x faster compilation times), but it had become a maintenance burden. Zig upstream was making changes that broke Bun's IO patterns. Rust's compiler ecosystem offered stability and tooling that Zig couldn't match.<br>AI fit. Here's the uncomfortable truth the Rust community doesn't want to admit: Rust's compiler is the perfect AI coding assistant. It has what X user rentierdigital called an "andon cord." When an AI agent writes bad Rust, the compiler yanks the cord immediately -- structured error, exact location, path to fix. The agent reads, corrects, reruns. No other systems language provides this feedback loop at the same fidelity.<br>What the Code Actually Looks Like<br>The quality debate is where things get heated.<br>On one hand, 99.8% test pass rate is impressive for any rewrite, let alone one done entirely by AI in under a week.<br>On the other hand, the code is rough. A Reddit user doing a deep dive found:<br>"999 uses of static mut. It would appear it's even worse a globally mutable cesspit of slopagetti carbonara than I had predicted. What I find especially crazy is that it has literally identified the solution and has spent a similar number of tokens commenting about it."<br>A typical comment in the generated code reads:<br>// PORT NOTE: Zig used plain `var` globals (unsynchronized). Mirrored here as<br>// `static mut` with the same single-writer-at-startup discipline; reads after<br>// `enable()` are technically racy in both languages.<br>// TODO(port): consider AtomicBool/AtomicI32 if Phase B wants strict soundness.<br>The AI knew it was writing unsound code. It just didn't care. The comment says "Phase B" -- suggesting the team plans to clean this up later. But critics point out that with 13,000 unsafe blocks and no humans reading the code, "Phase B" may never arrive.<br>The Community Reaction<br>The response has been...... polarized. Here's a sample of the sentiment:<br>From r/rust (718 upvotes, 436 comments):<br>"It's almost 100% AI done as I understand it, near-zero human input and code is only reviewed by AI" -- u/AlyoshaV<br>"if something like this ends up working, and it may well work, I might actually have that meltdown I've been planning for a while" -- u/gordonnowak<br>From r/programming (610 upvotes, 401 comments):<br>"My old CS professor used to say that we write code for humans to read and only incidentally to run on computers. I think this guy missed that lesson." -- u/Pharisaeus (689 points)<br>"It will either be an engineering miracle or disaster... I'm leaning toward the latter." -- u/Chaoses_Ib<br>From the Rust community specifically:<br>"The idea of using a static mut bool instead of an AtomicBool just...