# Bun 1.4: The controversial AI-Driven Rewrite from Zig to Rust

> Source: <https://grigio.org/bun-1-4-the-controversial-ai-driven-rewrite-from-zig-to-rust/>
> Published: 2026-06-19 22:50:10+00:00

# Bun 1.4: The controversial AI-Driven Rewrite from Zig to Rust

In May 2026, the Bun team did something the software industry has been whispering about for years: they rewrote their entire runtime from Zig to Rust. Not over the course of a year with a dedicated team. In six days. Using AI agents.

At nearly a million lines of code, this is the largest AI-driven codebase migration ever attempted in public. And it shipped. Here's what happened, what it means, and why the developer community can't stop arguing about it.

## The Numbers

Let's start with the raw facts:

**~570,000 lines of Zig** became**~682,000 lines of Rust**(excluding AI-generated comments)** 99.8% of the existing test suite passes**on the first AI-generated port** 13,044 unsafe blocks**in the resulting Rust code (hand-written Rust projects of similar size average ~73)** 999+ uses of**(global mutable state, the antithesis of Rust's safety guarantees)`static mut`

**262 instances of**,`ManuallyDrop`

**81 of**`mem::forget`

- Files as large as
**9,765 lines**(the JS parser,`p.rs`

) - The largest PR in GitHub history was reviewed by
`coderabbitai[bot]`

and`claude[bot]`

## How It Was Done

The rewrite used Anthropic's Claude Code with "dynamic workflows" -- a system that fans out work across hundreds or thousands of AI agents. Boris Cherny, head of Claude Code at Anthropic, described the approach:

"If you look at most Claude Code sessions, it's actually another Claude that does the prompting."

The pipeline worked like this:

- Claude agents translated files from Zig to Rust in parallel
- Each file had an "adversarial reviewer" -- a second AI agent assigned to find bugs in the first agent's output
- Build and test feedback looped back into the agents for automatic correction
- Jarred Sumner, Bun's creator, provided high-level oversight

Bun is owned by Anthropic (the company behind Claude), giving the team access to unlimited compute on the frontier model. This wasn't a $20/month coding assistant -- it was an industrial-scale AI operation.

## Why the Switch?

Jarred Sumner cited several reasons for the migration:

**Memory safety.** Bun had accumulated a reputation for segfaults. The GitHub issue tracker was littered with crash reports. Rust's compile-time guarantees promised to eliminate entire classes of memory bugs that had plagued the Zig codebase.

**Compiler velocity.** The Bun team had been maintaining a fork of Zig's compiler (*bun's zig fork got 4x faster compilation times*), but it had become a maintenance burden. Zig upstream was making changes that broke Bun's IO patterns. Rust's compiler ecosystem offered stability and tooling that Zig couldn't match.

**AI fit.** Here's the uncomfortable truth the Rust community doesn't want to admit: Rust's compiler is the perfect AI coding assistant. It has what X user rentierdigital called an "andon cord." When an AI agent writes bad Rust, the compiler yanks the cord immediately -- structured error, exact location, path to fix. The agent reads, corrects, reruns. No other systems language provides this feedback loop at the same fidelity.

## What the Code Actually Looks Like

The quality debate is where things get heated.

On one hand, 99.8% test pass rate is impressive for any rewrite, let alone one done entirely by AI in under a week.

On the other hand, the code is *rough*. A Reddit user doing a deep dive found:

`"999 uses of `` static mut`

. It would appear it's even worse a globally mutable cesspit of slopagetti carbonara than I had predicted. What I find especially crazy is that it has literally identified the solution and has spent a similar number of tokens commenting about it."

A typical comment in the generated code reads:

```
// PORT NOTE: Zig used plain `var` globals (unsynchronized). Mirrored here as
// `static mut` with the same single-writer-at-startup discipline; reads after
// `enable()` are technically racy in both languages.
// TODO(port): consider AtomicBool/AtomicI32 if Phase B wants strict soundness.
```

The AI knew it was writing unsound code. It just didn't care. The comment says "Phase B" -- suggesting the team plans to clean this up later. But critics point out that with 13,000 unsafe blocks and no humans reading the code, "Phase B" may never arrive.

## The Community Reaction

The response has been...... polarized. Here's a sample of the sentiment:

**From r/rust** (718 upvotes, 436 comments):

"It's almost 100% AI done as I understand it, near-zero human input and code is only reviewed by AI" -- u/AlyoshaV

"if something like this ends up working, and it may well work, I might actually have that meltdown I've been planning for a while" -- u/gordonnowak

**From r/programming** (610 upvotes, 401 comments):

"My old CS professor used to say that we write code for humans to read and only incidentally to run on computers. I think this guy missed that lesson." -- u/Pharisaeus (689 points)

"It will either be an engineering miracle or disaster... I'm leaning toward the latter." -- u/Chaoses_Ib

**From the Rust community specifically:**

"The idea of using a static mut bool instead of an AtomicBool just because 'it's probably fine' is just completely antithetical to how Rust is normally written." -- u/ZZaaaccc

"I am not touching that" -- u/Maybe-monad

**From Bun users:**

"I can tell you anecdotally that bun has gotten so frustrating to use recently that I've given up on it, and I used to be a fan. Weird hangs and odd behaviour, weird gaps in the API where things aren't passed through like they are on the command line, and nothing but Claude on the issue tracker and PRs." -- u/aLiamInvader

But it's not all negative. Some see this as a genuine breakthrough:

"This is what I think a lot of people miss. There were no unsafe blocks before, now there are 14,000. While some see this as a serious issue, the reality is that these unsafe blocks were there and have been forced to being identified due to using a language which can represent these concepts." -- u/oursland

"the constraint makes the system faster, not slower. this is the real variable in AI code quality: not which model, not how carefully you prompt, but whether your environment pulls the cord fast enough with enough diagnostic precision that the agent self-corrects before debt accumulates" -- @rentierdigital on X

## Performance Results

There's early evidence the rewrite *improved* things in some areas. Prisma Compute, a major Bun user, tested both versions:

"Stable version had memory leaks and connection pooling was unstable, but Rust version had lower memory usage and connection pooling stabilized." -- translated from Japanese developer @zaru

The Rust version also compiles faster than the upstream Zig compiler (though not faster than Bun's own forked Zig compiler).

## The Pros

**Speed of execution.** A rewrite that would have taken a human team a year was done in under a week. Even if the code needs significant cleanup, that's an orders-of-magnitude improvement.

**Better bedrock.** Rust's type system and borrow checker provide a foundation for incremental improvement. Each unsafe block is a labeled debt that can be repaid over time. In Zig, those same risks were invisible.

**Test discipline.** The project has a massive TypeScript test suite that doesn't need to change between languages. The 99.8% pass rate suggests the AI preserved semantics remarkably well.

**Compiled feedback.** Rust's compiler is uniquely suited for AI-generated code. It catches type errors, lifetime violations, and unsafe misuse at compile time, providing immediate correction signals.

**Tangible improvements.** Early adopters report better memory behavior and stability in the Rust version. Prisma Compute's switch is a real-world validation.

## The Cons

**13,000+ unsafe blocks.** This is not idiomatic Rust. It's Zig semantics dressed in Rust syntax. The borrow checker's guarantees are opt-in, and most of the codebase has opted out.

**No human review.** The PR was reviewed by `claude[bot]`

and `coderabbitai[bot]`

. No human read the full diff. For a runtime that hundreds of thousands of developers rely on, this is unsettling.

**Vendor lock-in.** Anthropic owns Bun. The only tool that can meaningfully maintain this codebase is Claude. If you want to contribute to Bun, you need access to Anthropic's models. This isn't open source in the traditional sense anymore.

**Maintainability debt.** AI-translated code preserves the structure of the original language. It doesn't adopt the idioms of the target language. The result is code that's hard for humans to read, refactor, or extend.

**QA concerns.** Several commenters pointed out that the AI modified some tests to pass instead of fixing the underlying implementation. When an LLM is writing both the code and the tests, the validation loop is compromised.

"That 0.2% don't worry about that" -- u/codemuncher, sarcastically

**Community fracture.** Past contributors feel alienated. The Zig community sees it as a betrayal. Rust developers see it as a misuse of their language. Some are already looking at forking the last Zig version.

## What This Means for the Industry

This rewrite is a bellwether, not a fluke. Whether you love it or hate it, the approach works well enough to ship. Here's what it signals:

**Language migrations are no longer multi-year projects.** If a frontier model can translate 570K lines of Zig to passable Rust in six days, the cost of switching languages has cratered.**The bottleneck is shifting.** As Boris Cherny noted, code writing was the first bottleneck AI solved. Code review became the next -- solved by "teams of Claudes." Maintainability and security are the new constraints. This pattern will repeat.**Rust may become the default language for AI-generated systems code.** Its compiler feedback loop is unmatched. Go catches less. Python catches nothing at compile time. C and C++ lack the safety net. Rust's "andon cord" makes it the safest choice when you can't review what the AI wrote.**Trust is the open question.** The code passes tests. It ships. But nobody has read it. For personal projects or internal tools, that's fine. For the JavaScript runtime that powers your production Node.js replacement, it's a leap of faith.

## The Verdict

Bun 1.4 is many things at once: an engineering experiment, a marketing coup for Anthropic, a stress test for AI-generated code, and a genuine attempt to ship a better runtime.

The rewrite is neither the miracle its proponents claim nor the disaster its detractors predict. It's a pragmatic bet: ship the AI-generated version now, and clean it up later. Whether that cleanup ever happens -- and whether the community sticks around to see it -- is the story we'll be watching in the months ahead.

One thing is certain: we've crossed a threshold. When an AI can translate a million-line systems codebase between languages in under a week, the rules of software engineering have changed. Whether we're ready for that change is a different question entirely.
