Skip to content

Bun: Zig-to-Rust Rewrite Merged After AI-Assisted Port

Jarred Sumner's AI-assisted rewrite of Bun from Zig to Rust has been merged. The port used agentic engineering with dynamic workflows and adversarial review.

Jarred Sumner spent longer writing his blog post about Bun’s Zig-to-Rust rewrite than the rewrite itself took — and he’d been promising that post since May 9th.

The rewrite has been merged into Bun’s main branch. Here’s what changed:

  • Language swap: Bun’s core moved from Zig to Rust, fixing memory leaks, improving stability, and shrinking binary size
  • AI-assisted: Sumner used agentic engineering — dynamic workflows, trial runs, adversarial review — to execute the port
  • Root cause: mixing garbage collection with manually-managed memory, a combination unusual enough that no language designs for it
  • Prep work: a detailed instructions file mapping Zig idioms to Rust equivalents preceded the actual code work, raising fair questions about how “fast” the rewrite really was

Sumner’s framing is notably generous to Zig. He credits it as essential — “We wouldn’t have gotten this far if not for Zig” — and attributes the bugs to Bun’s specific GC-plus-manual-memory needs, not to Zig itself. Other Zig users don’t hit the same crash patterns.

The deeper claim is the one that lands: “Until very recently, programming language choice was a one-way decision.” An entire JavaScript runtime rewritten in a different systems language, AI-assisted, in roughly a week. That’s not a normal thing that happens.

NOTE

HN commenters flagged that the “1 week” timeline excludes substantial preparation — including a detailed Zig-to-Rust mapping document. The agentic workflow’s speed depends on upfront engineering that doesn’t show up in the headline number.

The merged rewrite is live in Bun’s main branch. The full blog post is worth reading for the agentic engineering techniques alone — dynamic workflows and adversarial review are patterns any team can borrow.