Bun's Rust Rewrite and Zig's Self-Inflicted Crashout
- https://www.youtube.com/watch?v=kAjNWanR3n8
- Original title: Well this really p*ssed me off
Theo splits the video in two. The first half walks through Jared Sumner's blog post detailing how Bun — over one million lines of Zig — was mechanically ported to Rust in eleven days using ~50 dynamic Claude Code workflows and a pre-release Claude model, and argues it is the clearest written account yet of a genuinely new kind of "loop engineering." The second half is an angry line-by-line reaction to Zig creator Andrew Kelley's blog post about the same rewrite, which Theo reads as a jealous, largely non-technical personal attack on Jared that, in his view, does more damage to Zig's reputation than any competitor could.
The port: how Jared did it
Jared discloses he is now at Anthropic. Bun began in April 2021 as a bet on Zig for its low-level control and performance, and grew to a massive scope: JS/TS/CSS transpiler, minifier, bundler, npm-compatible package manager, test runner, Node-compatible module resolution, HTTP/1 and WebSocket clients, and dozens of Node built-in modules. The recurring stability problem is that Bun mixes a garbage-collected JS engine (JSC/V8) with Zig's manual memory management — an uncommon combination no language designs for — producing memory leaks and occasional crashes. Their existing mitigations (patched Zig compiler with AddressSanitizer, 24/7 fuzzing with Fuzzilli, end-to-end leak tests) go further than most projects but only catch bugs late.
Zig prefers explicit defer cleanup with no hidden control flow, so lifetime correctness relied on style guides plus code review — enforcement Jared distrusted. C++ (already ~20% of the codebase, via JSC, uSockets, BoringSSL, SQLite) would add constructors/destructors but still leave memory bugs. Rust turns use-after-free, double-free, and forgotten frees in error paths into compiler errors — and compiler errors are a far better feedback loop for agents than style guides.
Instead of a year-long human rewrite (three engineers, all other work frozen), Jared spent a week testing whether the new model could do a near-mechanical Zig→Rust port against Bun's existing language-independent TypeScript test suite. Key tactics Theo highlights:
- A three-hour conversation with Claude produced a
porting.mdguide (Zig patterns/types → Rust) plus alifetimes.tsv; both were adversarially reviewed and hand-read. - Everything-at-once, not incremental (incremental adds temporary code that never gets deleted).
- Faithful "transpile-like" port first, idiomatic-Rust refactors later after 1.4 ships.
- Separate implementer and reviewer roles with split context windows; ideally reviewers on a different model family (Codex + Claude) to raise review quality.
- Agents stepped on each other; git worktrees exhausted disk, so Claude was instructed to never run =git stash=/=reset= or slow
cargocommands. Theo thinks the real future is running tool calls on separate machines. - Compiler errors used as a work queue; the codebase split into ~100 crates for faster compilation while avoiding cyclic dependencies.
- A rule that any workaround needing a paragraph-long justifying comment means the code is wrong — fix the code.
- Resource isolation via
systemd-runwith cgroups after tests exhausted TCP sockets, spawned 10,000+ processes, and filled the disk.
Results: peak ~1,300 lines/minute, 652 commits, ~1.78 million lines written/rewritten, about 6,500 commits total. Token spend would have been ~$165K at API prices. Only 19 regressions, mostly from code syntactically identical but semantically different across the languages. It also fixed 128 bugs still present in the last Zig release (1.3.14), cut memory usage and leaks dramatically, produced a ~20% smaller binary, and runs 2–5% faster. Only ~4% of code sits in unsafe blocks (78% of those a single line, usually C/C++ interop). Theo's economic argument: this wasn't $600K-of-engineers vs $165K — without AI it simply would not have happened, and at any fixed capability level inference gets roughly 5x cheaper year over year, so the number only falls.
The crashout: Andrew Kelley's post
Theo reads Kelley's post as belittlement dressed as praise: it opens by calling Jared — one of the best engineers Theo knows — a "beginner," frames his VC funding and work ethic as moral failings, relays secondhand claims that Jared was a "stinky manager," and mocks Bun as the poster child for how not to write Zig. Theo's rebuttals:
- Bun donated ~$60K/year to the Zig Software Foundation — roughly triple the entire annual budget of E18E, one of the most important groups in the JS ecosystem (which has raised ~$20K total) — undercutting the "sellout who gave nothing back" framing.
- Kelley admits almost no technical criticism until late, then claims Bun's test suite was deemed "good enough to catch everything," while simultaneously complaining Zig bugs slip through tests — Theo calls this an admission that Kelley doesn't understand memory-safety guarantees a compiler/borrow-checker provides but unit tests cannot (e.g. long-running-process memory leaks).
- Kelley's claim that Jared wasn't fuzzing contradicts his own statement that the teams had stopped talking; the binary-size and LTO points are speculative reaches.
- A later edited version softens some wording ("partially," "some slop"), and Kelley concedes the post read as a personal attack driven by "unprocessed resentment" and apologizes to Zig users it alarmed — while still blaming a "trillion-dollar company" for firing first.
Theo closes that the blog post that kills Zig's community goodwill was written not by Bun but by Zig's own creator, and that he learned about Zig through Jared's work and will now never touch it because of Kelley's conduct. Sponsor read: WorkOS (enterprise auth, agent sign-up via the Auth.md standard).