Bun Ditches Zig for Rust in Its Core — And That Tells You Everything

5 min read 2 sources clear_take
├── "The rewrite is a pragmatic response to Zig's ecosystem limitations as Bun's scope grew"
│  ├── top10.dev editorial (top10.dev) → read below

Argues that Zig was the right choice for a small team building a runtime from scratch, but as Bun expanded from 'fast npm install' to a full Node.js replacement with bundler, test runner, and package manager, the Zig ecosystem's size became a liability. Every HTTP/2 parser, TLS implementation, and compression algorithm that Rust developers pull from crates.io, the Bun team had to write from scratch or maintain C bindings for.

│  └── Chaoses (Hacker News, 371 pts) → read

Surfaced the PR which shows the rewrite targets core infrastructure — bundling, transpilation, and module resolution — the subsystems where correctness and performance intersect most painfully and where the available library ecosystem matters most. The PR's scope signals this was driven by practical engineering needs rather than language preference.

├── "This validates Rust's dominance as the successor language for systems-level infrastructure"
│  └── Dev Blog (r/rust, 52 pts) → read

Posted the merge to r/rust where it was received as further evidence of Rust's gravitational pull on systems programming projects. The framing positions Bun's migration as part of a broader pattern where even projects that deliberately chose alternatives to Rust eventually converge on it due to its ecosystem and safety guarantees.

├── "The language a runtime is written in matters as much for project velocity as for performance"
│  └── top10.dev editorial (top10.dev) → read below

Frames the decision not as a performance optimization but as an acknowledgment that developer productivity and ecosystem access are first-order concerns for a runtime project. Rust's crates.io ecosystem lets the Bun team leverage existing, battle-tested libraries rather than hand-rolling every subsystem, directly accelerating development velocity.

└── "Zig's original value proposition — simplicity, comptime, and C interop — was the right early bet"
  └── top10.dev editorial (top10.dev) → read below

Notes that Zig offered C-level performance with cleaner syntax, comptime metaprogramming, and seamless C interop critical for wrapping JavaScriptCore. For a small team building a runtime from scratch, Zig's simplicity was genuinely an asset — the problem only emerged as Bun's scope expanded beyond what a small ecosystem could sustain.

What happened

Bun — the JavaScript runtime that made its name as the fast, Zig-powered alternative to Node.js and Deno — has merged PR #30412, a substantial rewrite of core internal subsystems from Zig to Rust. The pull request, which generated a score of 371 on Hacker News and significant discussion across the Rust and JavaScript communities, represents one of the most consequential architectural decisions in the project's history.

Bun was originally built almost entirely in Zig, with some C++ for JavaScriptCore bindings. The decision to rewrite core components in Rust isn't a tweak — it's an acknowledgment that the language a runtime is written in matters as much for the project's velocity as for its performance. Creator Jarred Sumner and the Oven team had been signaling this direction for months, with Rust gradually appearing in the bundler and CSS parser components before this larger merge landed.

The PR touches core infrastructure — the parts of Bun that handle bundling, transpilation, and module resolution. These are the subsystems where correctness and performance intersect most painfully, and where the available library ecosystem matters most.

Why it matters

To understand why this is significant, you need to understand the bet Bun originally made. Zig was chosen because it offered C-level performance with a cleaner syntax, comptime metaprogramming, and seamless C interop — critical for wrapping JavaScriptCore. For a small team building a runtime from scratch, Zig's simplicity was an asset.

But runtimes don't stay small. As Bun's scope expanded from "fast npm install" to "full Node.js replacement with bundler, test runner, and package manager," the Zig ecosystem's size became a liability rather than a curiosity. Every HTTP/2 parser, every TLS implementation, every compression algorithm that Rust developers pull from crates.io, the Bun team had to either write from scratch or maintain C bindings for. That's not a tooling preference — it's an engineering tax that compounds with every feature.

The Rust community on Reddit responded with predictable enthusiasm but also genuine technical analysis. Several commenters noted that the move validates a pattern seen across the industry: projects start in a niche language for its unique properties, then migrate to Rust when they need ecosystem breadth. Deno went through a version of this in reverse — starting with Rust from day one, which gave it access to the tokio async runtime and the entire crates.io catalog.

The contributor pipeline argument may be even more important than the technical one. Zig has an estimated 15,000-20,000 active developers. Rust has over 3 million. For an open-source project that needs external contributors to reach production quality across dozens of subsystems, a 150x difference in available talent isn't something you can ignore.

There's also the tooling gap. Rust-analyzer provides IDE support that is, by most accounts, the best in any systems language. Cargo's dependency management, while not without its critics, is leagues ahead of Zig's build system for managing complex dependency trees. When your runtime has to integrate with OpenSSL, zlib, libuv equivalents, and dozens of other native libraries, the package manager matters.

What this means for your stack

If you're already running Bun in production or evaluating it, this change is broadly positive and requires zero action on your part. Bun's public API — the CLI, the Node.js compatibility layer, the bundler interface, the test runner — remains the same. The rewrite is entirely internal; your `bun install` and `bun run` commands don't care what language implements them.

However, three practical implications are worth noting:

Build-from-source gets different. If you're building Bun from source (common in CI pipelines that need custom patches or bleeding-edge features), your build toolchain now needs a Rust compiler in addition to Zig. This adds ~5 minutes to a cold CI build and requires `rustup` in your Docker images. Not a dealbreaker, but update your Dockerfiles.

Bug reports may need different context. If you're filing issues against Bun's bundler or module resolution, the internal stack traces and debugging context will look different. The Bun team will likely update their contributing guide, but expect a transition period where diagnosis of edge-case bugs takes longer as the team maps old Zig mental models to new Rust code paths.

Plugin and extension authors should watch closely. If you've written native Bun plugins or extensions that interact with Bun's internals (rare, but it happens), the FFI surface is shifting. The Rust rewrite may eventually stabilize a cleaner native plugin API, but in the short term, expect churn.

For teams choosing between Bun, Node.js, and Deno for new projects, this actually simplifies the decision matrix. The "what if Zig stalls" risk that cautious CTOs cited when evaluating Bun just got substantially smaller. Rust is not going anywhere, and the Bun team's willingness to make a pragmatic language choice over a sentimental one is a sign of engineering maturity.

The Zig question

This inevitably raises uncomfortable questions for the Zig community. Bun was, by far, Zig's most visible production user — the project that proved Zig could build something real and fast and used by hundreds of thousands of developers. Losing that flagship doesn't mean Zig is dead (it has genuine strengths for embedded systems and other domains), but it does remove the strongest counterargument to "Zig's ecosystem is too small for large projects."

Andrew Kelley and the Zig team have been transparent about the language's maturity timeline — Zig hasn't hit 1.0 yet, and the standard library is still evolving. That's a perfectly reasonable position for a language project. But it also means that production users who can't wait for ecosystem maturity will continue to face the same pressures that pushed Bun toward Rust.

Looking ahead

Expect the Rust migration to continue incrementally. The merged PR is significant but almost certainly not the last — the Bun team will likely port additional subsystems as they encounter the same ecosystem leverage benefits in other areas. The more interesting second-order effect is what this does to Bun's contributor community. If the Rust rewrite opens the door to contributions from the massive Rust ecosystem, Bun's development velocity could accelerate meaningfully in the next 6-12 months. For a runtime competing against Node.js (backed by OpenJS Foundation resources) and Deno (backed by a well-funded company with Ryan Dahl's credibility), that contributor pipeline might be the real strategic win.

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

// share this

// get daily digest

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