Bun Bids Farewell to Zig: AI Completes 960K-Line Rust Rewrite in 6 Days — Full Breakdown

Bun is migrating from Zig to Rust, with AI Agents rewriting 960K lines of code in just 6 days
Bun v1.3.14 has been released and may be the last version of the Zig era. The team used AI Agents to complete a 960,000-line Zig-to-Rust migration in 6 days, achieving a 99.8% test pass rate with performance on par with the Zig version. The migration targets better memory safety guarantees rather than performance gains. v1.3.14 itself also brings major updates including a native image processing API, HTTP/3 support, and a 7x speedup for global virtual stores.
Event Overview: From Experiment to Production in 6 Days
Bun v1.3.14 has been released, but behind this update lies much bigger news — Bun is migrating from Zig to Rust.

Bun founder Jarred Sumner tweeted on May 12 that if the Rust rewrite merges successfully, v1.3.14 could be the last version of the Zig era. Just 6 days earlier (May 5), he said it was merely an experiment and the code would "very likely be thrown away." From "very likely thrown away" on May 5 to "fairly high confidence" on May 11, and then "dogfooding internally tomorrow" on May 13 — the pace of this transformation is jaw-dropping.
What's even more noteworthy is that this 960,000-line code migration was primarily completed by AI Agents, marking a major shift in software development paradigms.
Core Data of the Rust Rewrite
Code Coverage and Test Pass Rate
According to the Bun CEO's report, the team covered approximately 68% of the original Bun codebase rewrite in 6 days, equivalent to translating 960,000 lines of source code. The resulting Rust code is approximately 681,000 lines — slightly less than the original.
The most critical metric: on Linux x64 glibc, the test pass rate reached an astonishing 99.8%. This is absolutely top-tier for a language migration. The tests covered all target platforms:
- Linux x64 and ARM64 (covering both glibc and musl libc)
- Windows x64 and ARM64
- macOS x64 and ARM64
Performance: Rust Version Is No Slower Than Zig
Jarred explicitly stated: "I haven't seen a single benchmark that's slower than the Zig implementation." This is because it's essentially the same codebase — no Async Rust is used, and like the Zig implementation, only a handful of third-party libraries are referenced. In his own words: "It's literally the same thing, we just have better anti-crash tooling."
Safety Benefits and Current Concerns
This rewrite is expected to resolve approximately 200 GitHub Issues — not because Rust automatically fixes bugs, but because Rust's memory safety features inherently help eliminate potential memory problems.
Interestingly though, the code currently contains 13,044 Unsafe Blocks. This number indicates the Rust rewrite hasn't yet fully reaped the benefits of the borrow checker — it's more like using Rust as "a better Zig." Jarred himself acknowledged they're "still refactoring and simplifying," with the next engineering goal being to consolidate these Unsafe blocks into the smallest possible core modules, letting upper-layer logic run on safe Rust.
Detailed Breakdown of the AI Agent-Led Migration
Two-Phase Migration Strategy
The Bun team used Anthropic's own AI Agent infrastructure — the community calls these "Robo PRs." The entire migration was split into two phases:
- Phase A: Generate a corresponding RS draft next to each Zig file, faithfully reproducing the logic without requiring it to compile
- Phase B: Get the code to compile crate by crate and pass tests
The New "AI Writes, Humans Review" Development Model
The most shocking statement from Jarred: "We haven't written code ourselves in months." Even before the acquisition, this description was "almost accurate." This tells us the Bun team's workflow had already been inverted — it's not humans writing with AI assistance, but AI writing with human review.
On May 13, Jarred announced they would use Claude Code to internally dogfood the Rust version of Bun. This means Claude Code will become the first real heavy user of the Rust version of Bun. An AI-developed runtime running AI-generated code — this circular dependency is fascinating in itself.
Notable Updates in v1.3.14 Itself
Setting aside the Rust rewrite, v1.3.14 is a heavyweight update on its own, fixing 92 issues and responding to 380 pieces of feedback.
Bun.image: Native Image Processing API
A built-in native image processing API eliminates the need for Sharp or libvips. Metadata operations are claimed to be 70x faster than Sharp, 1080P PNG scaling is 1.38x faster, and 4K JPEG operations are 1.22-1.27x faster. Most importantly, zero native dependencies — no more headaches compiling Sharp for serverless deployments.
HTTP/3 Server Support
Bun.serve now includes experimental HTTP/3 support with automatic negotiation between HTTP/1.1, HTTP/2, and HTTP/3. In loopback static route tests, HTTP/3 achieves 509,135 req/s compared to HTTP/1.1's 189,130 req/s — a significant performance gap.
Global Virtual Store: 7x Faster
Enabling install.globalStore in bunfig.toml makes warm installs use a single symlink instead of clone_file_at. On macOS with approximately 1,400 packages, this drops from 841ms to 115ms — a 7.3x speedup.
Other Key Optimizations
- FS.Watch Complete Rewrite: Fixes long-standing issues like recursive watching and silently lost events after file deletion and recreation
- --no-fork Flag: Child processes exit when the parent dies, solving orphan process issues in CI/CD and watchers
- Cross-Language LTO: Zig and C++ boundaries use LLVM Bitcode for LTO, with 42% of cross-language functions inlined away
- Binary Size Reduction: Windows x64 reduced by 17.66MB, Linux x64 reduced by 8.58MB
The Deeper Logic Behind Technical Decisions
Why Rust Instead of Continuing with Zig?
The Bun team chose Rust not for performance, but for the following reasons:
- Better anti-crash tooling: The borrow checker and destructors catch memory issues at compile time
- Ecosystem maturity: Rust's talent pool, toolchain, and best practices far exceed Zig's
- Long-term maintenance costs: As Rust's position in systems programming grows, maintenance costs may be lower
- AI-friendliness: AI may have better capabilities for understanding and generating Rust code compared to Zig
Minimal-Change Approach Ensures Migration Success
The Bun team chose a minimal-change approach — preserving the original code structure and architecture without making sweeping changes just because of a language switch. This is key to many successful technical migrations: avoid over-engineering and maintain existing strengths.
Implications for the Software Development Industry
The significance of this event extends far beyond the Bun project itself. It demonstrates:
- AI-driven large-scale code migration is now viable: 960,000 lines in 6 days — a speed that human teams simply cannot match
- The "AI writes, humans review" model is becoming reality: Human engineers focus on architecture design, performance optimization, and security review
- The barrier to language migration has dropped dramatically: Technology choices are no longer irreversible decisions
Judging from Jarred's use of "if" rather than "when," he still maintains a cautious attitude. But looking at the overall pace of events, the community is already discussing this under the assumption that "Bun is about to switch to Rust." The next few months will be the critical validation period — whether the Rust version can truly stabilize, continue passing tests, and perform excellently in production environments will determine the ultimate success or failure of this migration.
Related articles
Industry InsightsAI Product Development in Practice: Model Selection, Building Moats, and Paths to Commercialization
Practical strategies for AI product development: why not to train models from scratch, when to use APIs vs. fine-tuning, building product moats, and the full path from evaluation systems to commercialization.
Industry InsightsNo Product Fits Your Needs? Building It Yourself Is the Best Starting Point for Indie Developers
Can't find a product that fits? Building from personal pain points is the best entry for indie developers. Niche needs + AI tools = rapid product creation.
Industry InsightsOpenAI Codex Tutorials Mass-Copied on Bilibili, Highlighting AI Content Farm Problem
At least 9 Bilibili accounts mass-published identical OpenAI Codex tutorial videos, exposing content farm operations in the AI tools space.