Bun Bets on Rust: The Zig-to-Rust Migration Is Now Merged

4 min read 2 sources explainer
├── "This is a verdict on Zig's production readiness, not its design quality"
│  ├── top10.dev editorial (top10.dev) → read below

The editorial argues that Zig's comptime system and C interop are genuinely elegant, but the problems are everything around the language: limited libraries, a small hiring pool, tooling gaps, and compiler semantics that shift between versions. When competing with Node.js and Deno, you can't also be beta-testing your implementation language.

│  └── @Chaoses (Hacker News, 596 pts) → view

Submitted the merged PR which drew nearly 600 upvotes and 658 comments, signaling the HN community's intense interest in the implications of abandoning a pre-1.0 language for production infrastructure after years of investment.

├── "Rust's ecosystem maturity is the decisive advantage over Zig for runtime development"
│  ├── top10.dev editorial (top10.dev) → read below

The editorial emphasizes that Rust offers battle-tested crates for HTTP parsing, compression, cryptography, async I/O, and dozens of other subsystems a JavaScript runtime needs. The cargo ecosystem eliminates the need to hand-roll infrastructure that Zig's smaller ecosystem couldn't provide.

│  └── Dev Blog (r/rust, 81 pts) → read

The r/rust community discussion with 81 upvotes and 90 comments reflects the Rust community's reception of the rewrite as validation of Rust's ecosystem strength for systems-level projects that need reliable, production-grade dependencies.

├── "The incremental migration strategy — not a big-bang rewrite — was critical to success"
│  └── top10.dev editorial (top10.dev) → read below

The editorial highlights that the Bun team migrated components progressively over months, keeping the runtime functional throughout. This approach deliberately avoided the catastrophic big-bang rewrite pattern that Joel Spolsky famously warned against, calling it 'a rewrite done by practitioners who've read the cautionary tales.'

└── "Pre-1.0 language choices carry compounding hidden costs that only emerge at scale"
  └── top10.dev editorial (top10.dev) → read below

The editorial argues that the costs of building on a pre-1.0 language aren't obvious on day one but compound over time — compiler semantic changes between versions, debugging and profiling tooling gaps, and a small contributor pool all create drag that accelerates as the project scales. Bun's original 2022 Zig bet was central to its identity but ultimately unsustainable.

What happened

Oven, the company behind the Bun JavaScript runtime, has merged PR #30412 — titled "Rewrite Bun in Rust" — into the main branch. The pull request, which hit the top of Hacker News with nearly 600 upvotes and drew significant discussion on r/rust, rewrites core components of Bun's internals from Zig to Rust.

Bun originally chose Zig as its implementation language back in 2022, and that choice was central to its identity. Jarred Sumner, Bun's creator, had been vocal about Zig's advantages: manual memory management without a garbage collector, comptime metaprogramming, and seamless C ABI interop that made binding to JavaScriptCore straightforward. The decision to abandon Zig for Rust isn't a rejection of Zig's design — it's a verdict on Zig's readiness for production infrastructure at scale.

The merge represents months of incremental work. Rather than a big-bang rewrite (the kind that Joel Spolsky famously warned against), the Bun team appears to have migrated components progressively, keeping the runtime functional throughout. This is a rewrite done by practitioners who've read the cautionary tales.

Why it matters

### The Zig bet didn't pay off

Zig is a genuinely interesting language. Its comptime system is elegant. Its C interop is best-in-class. But building a production runtime on a pre-1.0 language carries compounding costs that aren't obvious on day one.

The problems aren't with Zig's design — they're with everything around the language: limited third-party libraries, a small hiring pool, tooling gaps in debugging and profiling, and a compiler that occasionally changes semantics between versions. When you're trying to ship a runtime that competes with Node.js and Deno, you can't afford to also be beta-testing your implementation language.

The Rust ecosystem, by contrast, offers battle-tested crates for HTTP parsing, compression, cryptography, async I/O, and dozens of other subsystems that a JavaScript runtime needs. The `cargo` toolchain is mature. The hiring pipeline, while not cheap, actually exists.

### This is a pattern, not an anomaly

Bun isn't the first project to make this kind of migration. Discord rewrote performance-critical services from Go to Rust. Cloudflare has been steadily moving from C to Rust. The Linux kernel accepted Rust as a second language. What's notable about Bun's case is that it's a migration *from* a systems language *to* another systems language — suggesting that Rust's ecosystem advantages now outweigh raw language design considerations.

The r/rust community discussion surfaced a pragmatic point that often gets lost in language debates: developer velocity matters more than language aesthetics. Rust's borrow checker is famously steep to learn, but once you're past it, the ecosystem carries you. Zig asks you to build more of that infrastructure yourself, which is fine for small tools but brutal for something the size of a JavaScript runtime.

There's also a contributor dynamics angle. Bun is open source and needs community contributions. Rust has roughly 3 million developers according to the 2024 Rust Survey, while Zig's community, though passionate, is orders of magnitude smaller. Choosing Rust dramatically widens the pool of potential contributors who can meaningfully engage with Bun's internals.

### What this means for Zig

This is a high-profile defection, and the Zig community will feel it. But it's worth keeping perspective: Zig is still pre-1.0, and Andrew Kelley has been explicit that the language isn't ready for everyone yet. Zig's sweet spot remains smaller, performance-critical tools where its minimal runtime and C interop shine — think command-line utilities, embedded systems, and game engines. The lesson isn't "Zig is bad" — it's "don't build critical commercial infrastructure on a pre-1.0 language unless you're prepared to absorb the ecosystem tax."

Tigerbeetle, the financial database, remains committed to Zig. So does the Ghostty terminal emulator. These projects have different risk profiles and team structures than Bun. The one-size-fits-all narrative is wrong in both directions.

What this means for your stack

If you're a Bun user, the migration should be mostly invisible at the JavaScript API level. Bun's public interface is its Node.js-compatible API, its bundler, and its test runner — none of which change semantically because the internals switched languages. Performance characteristics may shift, but Oven wouldn't have merged this if it regressed their benchmarks.

If you've been contributing to Bun or writing native extensions, the change is significant. Zig FFI patterns will give way to Rust's FFI story (which is well-documented but different). If you had `build.zig` integrations, those are going away. The contributor onboarding experience will change — arguably for the better, given Rust's superior documentation and tooling ecosystem.

If you're choosing a runtime for a new project, this doesn't fundamentally change the Node vs. Bun vs. Deno calculus. Your choice should still be driven by API compatibility needs, deployment constraints, and team familiarity. But it does remove one of the quieter concerns about Bun: that its Zig dependency was a long-term maintenance risk. Rust is a language you can bet a decade of infrastructure on.

If you're evaluating Zig for a new project, treat this as a data point, not a verdict. Ask yourself: can my project absorb the cost of a thin ecosystem? Do I need the contributor pool, or is this a small-team project? Is the C interop story genuinely better than what Rust offers for my use case? For many projects, the answers still favor Zig. For anything at Bun's scale, they clearly didn't.

Looking ahead

The merge is done, but the migration isn't over. Expect the Bun team to progressively port remaining Zig components over subsequent releases. The interesting metric to watch isn't benchmarks (Oven will make sure those look good) — it's contribution velocity. If the Rust rewrite brings in more external contributors and faster feature development, it will validate the decision far more convincingly than any microbenchmark. The next six months of Bun's GitHub activity will tell the real story.

Hacker News 652 pts 718 comments

Rewrite Bun in Rust has been merged

→ read on Hacker News
Devblogs 94 pts 125 comments

Bun's Rust rewrite has been merged

→ read on Devblogs
sesm · Hacker News

When announcements say that rewrite took 1 week, I wonder how much time went into preparing this file with very detailed instructions on mapping Zig to Rust idioms: https://github.com/oven-sh/bun/commit/46d3bc29f270fa881dd573...On top of that, if you look at 'Point

azangru · Hacker News

Remember the top comment to this Hacker News thread? https://news.ycombinator.com/item?id=48016880 "This is an overreaction." "302 comments about code that does not work." "We haven’t committed to rewriting." "There’s a very high chance all this code

Jarred · Hacker News

Still writing the blog post about this. Will share more details.For where this is coming from, skim the bugfixes in the Bun v1.3.14 and earlier release notes. Rust won’t catch all of these - leaks from holding references too long and anything that re-enters across the JS boundary are still on us. Bu

gm678 · Hacker News

$ rg 'unsafe [{]' src/ | wc -l 10428 $ rg 'unsafe [{]' src/ -l | wc -l 736 Language Files Lines Code Comments Blanks ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Rust 1443 929213 732281 116293 80639 Zig 1298 711112 574563 59118 77431 TypeScript 2604 654

vitaminCPP · Hacker News

> +1009257 -4024Bun is now over 1M lines of Rust code.This is approaching the size of the Rust compiler itself; except that BunJs is mostly a JavaScript interpreter wrapper + a reimplementation of the NodeJS library (Rust STD wrapper).I think BunJS is becoming the canary for software complexity m

// share this

// get daily digest

Top 10 dev stories every morning at 8am UTC. AI-curated. Retro terminal HTML email.