Rewriting Bun in Rust

AI-generated summary of reporting by Simon Willison’s Weblog. Read the original for the full story.

Why it matters

Bun's rewrite proves frontier coding agents can safely execute massive ground-up rewrites, breaking the old 'never rewrite' rule for large software projects.

Read this as

Bun, a fast JavaScript tool, has been rewritten from the Zig programming language into Rust, a language that automatically prevents certain memory bugs. The rewrite was done mostly by AI agents over 11 days, checked against Bun's existing tests. Since June, it ships inside Claude Code, and almost nobody noticed the change.

Bun's creator ported a million-line JavaScript runtime from Zig to Rust using parallel AI agents costing roughly $165,000 in tokens at API prices. Bun's test suite acted as the safety net, and the Rust build has run in Claude Code since version 2.1.181 (June 17) with 10% faster startup on Linux. The lesson: large AI-assisted rewrites are now viable when strong test suites exist.

Jarred Sumner rewrote Bun in Rust to eliminate use-after-free, double-free and leak bugs that came from mixing garbage collection with manual memory management in Zig. An agent harness drove the port, using Bun's TypeScript test suite as a language-independent conformance check with a million assertions, plus adversarial code review; failing cases prompted fixes to the generation process rather than the code. Cost: 5.9B uncached input, 72B cached input, 690M output tokens (~$165,000).

Read the original

This summary exists to save you time, not to replace the source.

Key terms

Bun Rust Zig Claude Code Anthropic Jarred Sumner Joel Spolsky

Was this summary useful?

One click, anonymous. It tells us which summaries to re-run.

Related reading