Rewriting Bun in Rust
Switch to the Rust port of Bun via Claude Code v2.1.181, benchmark startup, and review any breaking changes in the new API.
Switch your local Bun to the Rust port via Claude Code v2.1.181, benchmark startup, and review any breaking changes.
Summary
Jarred Sumner has rewritten the JavaScript runtime Bun from Zig to Rust, a major overhaul that eliminates memory‑management bugs such as use‑after‑free and double‑free.
The rewrite leverages safe Rust’s RAII to automatically clean up resources, and an agent harness uses Bun’s existing TypeScript test suite as a conformance suite to port code automatically. Over 11 days of agent‑driven development, the Rust code matched the original Zig implementation and was merged after extensive testing.
The new Rust port is now live in Claude Code v2.1.181, delivering a 10% faster startup on Linux while keeping the API largely unchanged. The rewrite cost roughly $165,000 in API tokens, demonstrating the feasibility of large‑scale agentic engineering for core runtimes.
Key changes
- Rewrite from Zig to Rust eliminates use‑after‑free and double‑free bugs
- Safe Rust RAII cleans up memory automatically
- Agent harness uses Bun test suite as conformance suite
- 10% faster startup on Linux in Claude Code v2.1.181
- 5.9B uncached input tokens, 690M output tokens, 72B cached reads cost ~$165k
- Rust port now live in Claude Code for nearly a month