Bun ports over half a million lines from Zig to Rust with AI in four months
The Rust-based Bun v1.4.0 fixes longstanding bugs and sharply cuts memory use while slightly boosting HTTP throughput.
Bun has been rewritten from 535,496 lines of Zig into Rust and shipped as Bun v1.4.0 after four months of work, with the primary goal of eliminating recurring memory safety bugs via Rust’s type system and tooling. Jarred Sumner orchestrated an AI-heavy migration using a pre-release of Anthropic’s Claude Fable 5, running about 64 agents in parallel across four workspace shards, and spending roughly $165,000 in API tokens to get the full test suite passing. The process relied on a detailed PORTING.md guide and a LIFETIMES.tsv file, adversarial reviewer agents, and continuous refinement of the implementation workflow instead of extensive manual patching of generated code. The Rust release reportedly fixed 128 longstanding bugs from Bun v1.3.14, drastically reduced memory leakage in stress tests, and improved HTTP throughput by 2–5%. The move has drawn criticism from Zig creator Andrew Kelley over the reliance on unreviewed machine-generated code and test suites, while observers note that Bun now serves as a key test case for the long-term maintainability of million-line LLM-generated codebases.
Why it matters
The move reshapes Bun’s reliability profile. The Rust rewrite fixes 128 long‑standing bugs, removes native memory leaks, and delivers a modest 2–5% HTTP throughput gain, turning a project that previously grew past 6.7 GB of memory in stress tests into one that plateaus at 609 MB. For anyone running Bun in production, this means fewer memory safety failures, more predictable resource use, and performance that ticks up instead of degrading under sustained load.