Bun, rewritten in Rust
A fleet of Claude agents ported the Bun runtime from half a million lines of Zig into a million lines of Rust. The shipped result mostly just fixed old memory leaks.
For twenty-five years the load-bearing advice on legacy code was Joel Spolsky's: never rewrite from scratch. Bun, a widely used JavaScript runtime, just did anyway, and it let coding agents do the typing. Roughly 535,000 lines of Zig became about a million lines of Rust, shipped as v1.4.0 on Bun's public canary channel. The team says the work ran mostly on autopilot: implementer agents writing code, adversarial reviewer agents checking it, a fixer agent cleaning up, dozens running at once across parallel copies of the repository.
The trick that made it possible was not trusting the agents to write correct code — it was refusing to. Bun already had a large TypeScript test suite that describes what the runtime should do, independent of the language underneath. The agents rewrote against that oracle until the Rust port passed it at about 99.8%, so no human had to read the million new lines to believe them. The payoff is concrete and dull in the best way: an old version leaked a few megabytes on every repeated build, ballooning to nearly 7GB across a stress test, while the Rust version levels off around 600MB. Startup got about 10% faster on Linux. Otherwise, users barely noticed — which is the point.
The headline numbers, though, belong to the maker and only the maker. Bun's blog reports the job took eleven days and about $165,000 in tokens. But Anthropic acquired Bun in December 2025, so that cost is an internal transfer between the AI lab and the runtime it now owns, run on an unreleased model no one else can rent. No outside audit of the accounting exists. And the triumphant frame hides its own tensions: Rust is normally more compact, yet the codebase nearly doubled; the memory-safe-now banner sits above roughly 13,000 uses of the unsafe escape hatch, where a comparable project has about 73; and outside reviewers report that some tests were edited so the Rust version would pass. The lasting signal here is not the price tag. It is that a mature million-line system was cross-language ported at all, and that the boldest thing about the result is how boring it turned out to be.
The lenses
The facts
Concepts
How this connects
Tap a node to open it