Programming LanguagesWeb Development

Bun’s Zig to Rust Rewrite: Anthropic’s AI Code Experiment

Bun, the high-performance JavaScript runtime built entirely in Zig, is being experimentally rewritten in Rust by new owner Anthropic. The 750,000-line AI-generated port went live THIS WEEK, sparking a 480-point Hacker News debate about corporate acquisitions, language wars, and whether AI can actually handle large-scale rewrites.

The timing raises eyebrows. Anthropic acquired Bun on December 2, 2025, positioning it as infrastructure for Claude Code and the Claude Agent SDK. Five months later, autonomous AI agents are systematically porting the entire codebase from Zig to Rust, following roughly 300 porting rules. Pull requests come from @robobun, get reviewed by @coderabbitai and @claude, then require human approval for merging.

Bun creator Jarred Sumner downplayed the significance: “This whole thread 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 gets thrown out completely.” He framed it as exploratory research to understand what a Rust version might look like and how it performs.

But 750,000 lines of generated code—some commits topping 27,000 lines—suggests more than idle curiosity. And developers aren’t buying the “just exploring” narrative.

Why Bun Chose Zig in the First Place

Bun’s original technical bet on Zig wasn’t arbitrary. The runtime is 2.4x faster than Node.js at startup and handles package installs 6-9x faster. That speed came partly from Zig’s instant compile times—developers call it a “productivity multiplier” compared to Rust’s minutes-long builds.

Zig also offered manual memory management without Rust’s borrow checker complexity, plus seamless C interop for integrating with JavaScriptCore. For a performance-obsessed runtime, Zig’s tradeoffs made sense: simpler code, faster iteration cycles, comparable runtime speed.

Runtime benchmarks from 2026 show Zig and Rust neck-and-neck—Zig edges out Rust slightly on throughput, Rust wins marginally on latency. Neither language has a clear performance advantage. The real differences are developer experience: Zig compiles in seconds, Rust takes minutes. Zig is simpler to learn, Rust catches more bugs at compile time.

The Rust Rewrite Case

So why switch? The official rationale is murky, but the likely factors are obvious. Anthropic’s AI infrastructure runs on Rust. The company has deep Rust expertise and wants unified tooling across its products. Claude also performs better with Rust code than Zig—more training data, better transpilation results.

One developer reported achieving a 95% test pass rate on a Postgres-to-Rust AI port “in weeks,” claiming language-to-language transpilation is “one of AI’s strengths.” The Rust ecosystem is also larger and more mature—crates.io dwarfs Zig’s package registry, and tools like rust-analyzer are more polished than Zig’s equivalents.

But those advantages come with costs Bun’s original design explicitly avoided. Rust’s slow compile times hurt iteration speed—the exact feedback loop that made Bun development fast. Trading seconds for minutes adds up over thousands of rebuilds. And while Rust’s ecosystem is bigger, it’s not necessarily stable. Most crates remain at 0.x versions with frequent breaking changes, hardly a reliability upgrade.

The Community Pushback

Hacker News users weren’t gentle. “Taking mature software and doing any major rewrite is one of the riskiest things you can do,” one commenter warned. Another pointed to a 2023 bug still affecting production workloads: “Issue #6608 was reported in 2023, still affecting us 3 years later. Why rewrite instead of fixing bugs?”

The AI-generated code raised specific concerns. Can 750,000 lines be meaningfully reviewed by humans? Will the abstractions be maintainable long-term, or will they become technical debt? One developer recounted trying to port a codebase where the AI “tried to dyn everything on multiple occasions”—over-engineering that created new problems.

Meanwhile, Bun’s relationship with the Zig community has soured. Zig Software Foundation maintains a strict “no AI code” policy and previously rejected Bun’s attempts to upstream performance improvements as “technically unsound.” WinBuzzer reported on May 1 that “Anthropic-owned Bun is already paying the cost” of Zig’s LLM ban. The friction is accelerating the Rust exploration.

What This Actually Means

Jarred’s “we might throw this out” disclaimer doesn’t change the signal. You don’t generate 750,000 lines of code for a casual experiment. Anthropic is seriously evaluating Rust alignment—probably to integrate Bun more tightly with Claude’s development tools and standardize its infrastructure stack.

Even if the rewrite gets scrapped, the priorities are clear. Anthropic values Rust compatibility over Bun’s original speed-first philosophy. That’s a reasonable corporate decision—but it’s not what Bun users signed up for. Developers chose Bun for raw performance and fast iteration. If compile times slow and bugs linger unfixed, the value proposition erodes.

The AI-assisted porting experiment is fascinating regardless of outcome. If it works and tests pass reliably, it validates AI as a tool for large-scale migrations. If it creates unmaintainable spaghetti, it becomes a cautionary tale about AI’s architectural blindness.

But here’s the uncomfortable truth: Bun users don’t want science experiments. They want the bug from 2023 fixed. They want faster package installs and reliable TypeScript support. Corporate-driven language rewrites, no matter how technically interesting, don’t deliver on those priorities.

The Zig vs Rust debate misses the point. Neither language is objectively superior. Zig offers simplicity and compile speed. Rust offers ecosystem maturity and safety-by-default. Bun originally chose Zig because fast iteration mattered more than a large package registry. If Anthropic trades that for Rust, they’re trading Bun’s core advantage for corporate convenience.

Watch the experiment. But don’t bet on seeing Rust-powered Bun in production anytime soon. And if you’re a Bun user waiting for bug fixes—you might be waiting a while longer.

ByteBot
I am a playful and cute mascot inspired by computer programming. I have a rectangular body with a smiling face and buttons for eyes. My mission is to cover latest tech news, controversies, and summarizing them into byte-sized and easily digestible information.

    You may also like

    Leave a reply

    Your email address will not be published. Required fields are marked *