Skip to main content
  1. Blog/

Bun Rewrites Its Core in Rust — What It Means for the JavaScript Runtime Wars

Osmond van Hemert
Author
Osmond van Hemert
Table of Contents
JavaScript & Node.js - This article is part of a series.
Part : This Article

On May 14, 2026, Jarred Sumner merged PR #30412 into Bun’s main branch. The title is straightforward: “Rewrite Bun in Rust.” The diff is not — 1,009,257 lines added, 4,024 deleted, 2,188 files changed across 6,755 commits. In roughly one week, the Bun runtime went from being one of the most prominent Zig codebases in production to a Rust project.

This is one of those moments that reshapes the conversation around JavaScript runtimes, language choice, and — whether you like it or not — AI-assisted development at scale.

The Background
#

Bun launched in 2022 as an all-in-one JavaScript runtime, bundler, package manager, and test runner. Its big differentiator was performance, and its implementation language was Zig — a systems language designed as a pragmatic alternative to C and C++. Zig gave Bun low-level control without the complexity of Rust’s borrow checker, and it was a deliberate choice by Jarred Sumner at the time.

But Zig also meant manual memory management. No compiler enforcing lifetimes. No borrow checker catching use-after-free bugs at compile time. For a small, fast-moving team building a runtime that handles untrusted user code, that trade-off became increasingly painful.

As Jarred put it in the PR description:

“Most importantly, we now have compiler-assisted tools for catching & preventing memory bugs, which have costed the team an enormous amount of development & debugging time over the years.”

That’s the kind of sentence that only comes after years of late-night debugging sessions.

What Actually Changed
#

This was a faithful port, not an architectural overhaul. The Rust version keeps the same architecture, the same data structures, and the same approach to minimizing third-party dependencies. Notably, there’s no async Rust — Bun continues to use its own event loop and concurrency model rather than adopting Tokio or similar frameworks.

The preparation was methodical. Before the actual rewrite began, the team committed a detailed Zig-to-Rust porting guide that maps Zig idioms to their Rust equivalents. Internal smart pointer types were pre-mapped to Rust counterparts. A bun_collections Rust crate was already in place. This wasn’t a spontaneous decision — the groundwork was laid carefully.

The concrete results:

  • Binary size shrinks by 3–8 MB depending on platform
  • Benchmarks are “between neutral and faster” according to the PR
  • The rewrite fixes several existing memory leaks and flaky tests
  • 99.8% test suite compatibility on Linux x64 glibc before merge

The AI in the Room
#

Let’s talk about the branch name: claude/phase-a-port. That’s not subtle. Claude, Anthropic’s AI model, was heavily involved in the actual code translation. Given that Bun is now part of Anthropic’s portfolio, this is as much a showcase of AI-assisted development as it is a runtime upgrade.

The timeline makes this clear. Jarred first floated the idea publicly around May 5, describing it as experimental:

“I’m curious to see what a working version looks like, what it feels like, how it performs and if/how hard it’d be to get it to pass Bun’s test suite and be maintainable.”

He also added:

“There’s a very high chance all this code gets thrown out completely.”

One week later, it was merged. A million lines of Rust, passing the full test suite.

Whether you’re impressed or skeptical, this is worth paying attention to. Translating a codebase 1:1 between two systems languages — with detailed porting guides as context — is arguably the sweet spot for current LLM capabilities. It’s repetitive, pattern-heavy work where the source and target languages have similar levels of abstraction. It’s very different from asking an AI to design an architecture from scratch.

Community Reaction: Polarized
#

The GitHub PR tells its own story through the reaction counts: 1,254 thumbs up and 1,010 thumbs down. That’s an unusually polarized ratio for a merged PR from a project’s creator.

On Hacker News, the discussion was massive. The merge announcement pulled in 652 points and 724 comments. An earlier thread about the Zig-to-Rust porting guide hit 722 points with 554 comments. The 99.8% test compatibility announcement got 716 points and 692 comments.

The skepticism falls into a few camps:

“One week is misleading.” Several commenters pointed out the extensive preparation — the porting guide, the pre-mapped types, the bun_collections crate. As one Hacker News user put it: “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.”

“This is marketing for Anthropic.” With Bun now under Anthropic’s umbrella, the rewrite doubles as a proof-of-concept for Claude’s coding capabilities. Some community members questioned whether the narrative was being shaped to serve that purpose.

“AI-generated code at this scale is concerning.” A million lines of AI-translated Rust is a lot of code that no human has read line by line. The test suite passes, but test suites don’t catch everything — especially subtle concurrency bugs or edge cases in memory management that might only surface under specific workloads.

On the other side, plenty of developers see this as pragmatic. Memory safety matters. Rust’s ecosystem is mature. And if AI can handle the mechanical translation while humans focus on architecture and correctness, that’s arguably a better use of everyone’s time.

What This Means for the Runtime Landscape
#

The JavaScript runtime space now has an interesting dynamic:

  • Node.js: C++ core, the incumbent, massive ecosystem
  • Deno: Rust core (from the start), TypeScript-first, security-focused
  • Bun: Now Rust core (migrated from Zig), performance-focused, all-in-one

Two out of three major runtimes are now built on Rust. That’s a strong signal about where the industry is landing on the systems programming language question for this class of software. It also means Bun and Deno now share a compilation target, which could eventually lead to shared libraries or tooling.

For existing Bun users, the migration should be transparent. The rewrite is available via bun upgrade --canary, and the team has been clear that it won’t ship as a stable release until the remaining optimization and cleanup work is done.

My Take
#

I think the Rust rewrite is the right call for Bun’s long-term health. Memory safety bugs in a JavaScript runtime aren’t just developer inconveniences — they’re potential security vulnerabilities that affect everyone running Bun in production. The borrow checker catches entire categories of bugs that manual auditing misses.

The AI angle is the more interesting conversation. One week to port a million lines is genuinely remarkable, but let’s be honest about what “port” means here. This was a mechanical translation with detailed instructions, not a creative engineering effort. The hard work — the architecture, the algorithms, the test suite — was already done. That doesn’t diminish the achievement, but it does scope it accurately.

What I’m watching for: how the Rust version evolves after the initial port. The real test isn’t whether AI can translate Zig to Rust. It’s whether the resulting Rust codebase is idiomatic enough that human developers can maintain and extend it without fighting the code. A faithful port preserves behavior, but it doesn’t always preserve readability.

The 1,010 thumbs-down reactions on the PR are worth taking seriously too. When roughly half the community pushes back on a technical decision, it usually means something beyond “I don’t like Rust.” In this case, I think it reflects a broader anxiety about the pace of AI-driven changes in open-source projects and about Anthropic’s influence on a tool many developers depend on.

Either way, the JavaScript runtime wars just got more interesting. Bun ships with memory safety guarantees now, and the bar for every runtime in the space just went up.

JavaScript & Node.js - This article is part of a series.
Part : This Article

Related