The $165,000 Rewrite
How agentic engineering turned a decade-long impossibility into an eleven-day sprint
For decades, the rule in software engineering was simple: never rewrite a large, successful system from scratch. It is a fool's errand that consumes years of developer time and almost always results in a product that is less stable than the original. Joel Spolsky famously codified this in the early 2000s. But the arrival of high-reasoning coding agents has broken this rule. Jarred Sumner recently completed a total rewrite of the Bun runtime from Zig to Rust, not over years, but in a matter of days. This wasn't a human-led effort assisted by AI; it was a coordinated parallel agentic workflow that treated the original codebase as a set of constraints to be satisfied.
The Memory Problem
The decision to move to Rust was driven by a specific, recurring headache: memory safety. Bun, written in Zig, struggled with a mix of garbage collection and manual memory management. This combination led to a persistent list of bugs—use-after-free errors and double-frees that kept the team awake at night. Rust solves this through its ownership model and RAII-like automatic cleanup. By moving to Rust, the goal was to turn runtime crashes into compile-time errors. The challenge was the sheer scale of the task: adding over a million lines of code.
Our bugfix list felt bad and I was tired of going to sleep worrying about crashes in Bun.
The process relied on a language-independent TypeScript test suite. This suite acted as the ultimate arbiter of truth. The agentic harness would attempt to port segments of the code, run the tests, and when a failure occurred, the agent would iterate on the code until the assertions passed. This created a feedback loop where the human's role shifted from writing lines of code to managing the process that generates the code. It was an adversarial review system where the agent had to prove its work against a million assertions.
- Language-independent conformance testing
- Adversarial code review loops
- Automated error correction via model prompting
- Human-in-the-loop monitoring of high-level workflows
The result was a 10% speed increase on Linux. While most users noticed nothing, the engineering reality changed forever. The ability to perform massive, high-fidelity migrations in days rather than years changes how we think about technical debt. We are moving from a world where we must live with our early mistakes to a world where we can simply rewrite our way out of them.
Coding agents turn the 'never rewrite' rule into a strategic option.