Bun Rewritten from Zig to Rust with the Help of AI Agents
Translated by a model; the original is in Russian.
Jarred Sumner, the author of the JavaScript runtime Bun, has published his long-promised post about fully rewriting the project from Zig to Rust. In Simon Willison's words, it's a detailed and remarkable account of agentic engineering — with dynamic workflows, trial runs, and adversarial review.
Sumner devotes much of the text to praising Zig: it was this language that let Bun reach its present state, and he's grateful to it for that. Yet it was Zig, too, that became the source of the project's main problem.
Why the rewrite
Sumner admits that Bun's list of bugs was a constant source of anxiety for him — he'd fall asleep worrying about crashes. As he tells it, the issue isn't Zig itself: other projects in the language don't run into difficulties like these. The problem lies in combining garbage collection with manual memory management — a rare scenario that no language was ever specifically designed for.
A significant share of the bugs on the list came down to classic memory problems: use-after-free, double-free, and leaks caused by a forgotten release along error-handling paths. In safe Rust such mistakes are ruled out at the compiler level, and that became the decisive argument in the language's favor.
Rewriting is no longer taboo
The author of the post emphasizes the historical context of the decision. For a long time, the choice of programming language was an irreversible decision for a project on Bun's scale: the industry had long since internalized the rule “never rewrite a large program from scratch,” formulated by Joel Spolsky back in 2000 in his essay Things You Should Never Do.
The arrival of coding agents built on modern frontier models, however, changes that equation: a large-scale rewrite, once considered unjustifiably risky and labor-intensive, becomes a practically achievable task.
Sumner's post, in Willison's assessment, is interesting precisely as a detailed case study of applying the agentic approach to a non-trivial engineering problem, rather than merely as a technical note about switching languages.
Source: Simon Willison
Comments
Sign in, to comment.