YouTube Summaries

← All summaries

The Great Bun Rewrite: Zig to Rust with an LLM

2026-07-15 Wed ⏱ 14 min prime

Prime reacts to Bun's decision to rewrite its Zig codebase in Rust with heavy LLM assistance. What started in May as a "fun experiment" (with a community note insisting it was not a rewrite) became a production rewrite two months later, completed in 11 days using a pre-release Claude Fable model at a cost of roughly $165,000 in API pricing. Contrary to the pitchfork crowd, Prime argues the rewrite was a genuinely good deal, walks through Jared Sumner's stated reasons, and highlights the agent orchestration techniques he found worth stealing.

Why they did it

Jared credits Zig for getting Bun off the ground but says Bun's unusual scope — mixing a garbage collector with manually managed memory — is something no language really designs for. The 1.3.14 bug list is a wall of memory faults: use-after-free, double free, heap out-of-bounds, memory leaks, race conditions. His core argument is about enforcement: style guides (Tiger Beetle's Tiger Style in Zig, Google's 31,000-word C++ guide) rely on code review and linters to catch violations, i.e. community enforcement of a pact. Rust moves that enforcement to the compiler — you do not get the option to get it wrong. About 20% of Bun is C++, which would have kept the style-guide problem, so Rust won out. Prime concedes the "skill issue, Zig could have done it" critiques have merit but shrugs: it is a hard project he does not maintain, so more power to Jared.

The $165,000 in perspective

Prime pushes back on the sticker-shock reaction. He recounts a Netflix data-consistency rewrite: three engineers (one staff) for about a year, effectively over a million dollars when management, cross-team coordination, and overhead are counted — and it froze features. Against that baseline, 11 days for $160K is a steal. Even if the output were only ~50% of the desired shape and needed engineers a further month (or three engineers three months) to reshape, it is still far faster and cheaper. He frames it as a rare cost/quality/speed triple win.

How the rewrite actually ran

The pseudo-code loop: do the task, spawn two fresh reviewer agents with no context (given the change set and the intended goal, asked to find bugs/problems), then apply each review's feedback. Prime is unsure why two reviews — possibly different orientations. He has run this same review pattern for ~8 months (his own "prime agent review" tool that targets a cursor cloud run or a GitHub PR URL, gathers context files and a prompt, then produces feedback) and finds ~50% of the feedback genuinely useful. The mechanical process: whole-translate one Zig file to one Rust file, run the two reviews, repeat across the codebase — yielding ~16,000 errors. Fleets of agents in separate work trees each took one error, fixed it, got the two reviews, applied feedback, and looped until all errors cleared. First `bun --version` immediately hit a linker error and panicked, so the same swarm approach was pointed at unit tests, sharded across workers, until everything passed. Final tally: 6,502 commits, ~1.8 million lines written/rewritten, $165,000.

Prime's take

He admits it is a "weak take" — he is not outraged. Translating one thing to another is, in his view, one of AI's genuine strong suits, and the ported Rust likely mirrors the Zig structure closely enough that navigating the codebase is not bad, though real idiomatic cleanup surely took further effort. What actually excites him is the dev-tooling angle — the way changes, feedback, and fixes were orchestrated — which is why he keeps building his own review integration between cloud agents and Neovim. The open question is Bun 1.4's public release: either hundreds of thousands of users get their CI and installs broken, or nothing happens and everyone quietly agrees it was pretty cool. Prime signs off joking about sweating in his 100-degree horse barn and having "strong beginner energy."