Bun's Rust Rewrite Achieves 99.8% Test Pass Rate in 6 Days with AI
Bun's experimental Rust rewrite achieved 99.8% test compatibility in 6 days using AI-assisted coding. Learn what this means for software rewrites and language choices.
We witnessed an experimental Rust rewrite of Bun achieve 99.8% test compatibility in just six days, heavily assisted by an LLM. Bun's creator, Jarred Sumner, announced the milestone on Hacker News, sparking a heated debate about AI's role in software rewrites, Rust versus Zig, and the value of a comprehensive test suite.
What Happened in the Bun Rust Rewrite Experiment
On March 28, 2024, Sumner tweeted that an experimental branch of Bun rewritten in Rust hit 99.8% compatibility with the existing test suite on Linux x64 glibc. The rewrite took only six days, with extensive LLM assistance. Sumner cautioned that this is purely experimental and "there's a very high chance all this code gets thrown out completely." The tweet linked to a private branch, but the HN thread quickly filled with reactions.
Why the HN Community Debated AI-Assisted Coding
The HN community split into two camps. Some were impressed by the speed. Others questioned the real-world value of an AI-driven rewrite. A Bun developer commented: "This whole thread is an overreaction. 302 comments about code that does not work. We haven't committed to rewriting." Others saw it as a preview of future velocity: "6 days of work to do this. Even if it doesn't end up becoming meaningful, it shows just how tokens and work done will be linked now and in the future."
Several commenters noted that the existing test suite was essential for guiding the AI and validating output. The debate also touched on language safety: some argued that Rust would reduce memory bugs compared to Zig. Others pointed out that unsafe code can undermine those benefits.
Key Takeaways for Using Test Suites as a Superpower
A Rust rewrite of a major runtime achieving near-perfect test pass rates in under a week is impressive. But it's built on a pre-existing test suite designed for the Zig version. Tests can only validate behavior that is explicitly checked. Subtle differences in memory management or edge cases may remain.
Using an LLM to port from Zig to Rust is a natural fit. Mapping semantics is a translation task large models handle well, especially with a strong type system like Rust's to catch mismatches. Two big takeaways emerge:
- A high-quality test suite is your superpower. It enables experiments that would otherwise be prohibitively risky.
- Language choice matters less than rigorous process. Rust's safety guarantees are real, but they don't automatically eliminate bugs—especially when AI writes
unsafeblocks.
What This Means for Bun and the Ecosystem
If you're maintaining a large codebase, invest in your test suite now. It's your safety net for future rewrites, whether done by humans or AI. If you're tempted to do a similar AI-assisted rewrite, make sure experienced developers review the output for correctness and maintainability. The AI can get you to high pass rates quickly, but it may produce fragile code.
For Bun users, don't worry—this is an experiment that may never ship. For language enthusiasts weighing Rust versus Zig for systems programming, this highlights that both can work. But Rust has better tooling and a stronger safety story out of the box. For anyone building developer tools, the lesson is clear: a comprehensive test suite is your best asset for leveraging AI in software development.
For further reading, check out the Bun GitHub repo, the Rust language, and Zig language websites.