---
title: "Bun is being rewritten in Rust, moving away from Zig"
url: https://daily.dev/posts/bun-is-being-rewritten-in-rust-moving-away-from-zig-4ty7usyvh
source_url: https://daily.dev/posts/bun-is-being-rewritten-in-rust-moving-away-from-zig-4ty7usyvh
type: collection
source: "Collections"
published: 2026-05-14T13:44:42.476Z
updated: 2026-06-08T16:15:12.090Z
tags: ["rust", "anthropic", "zig", "bun"]
reading_time: 4
upvotes: 105
comments: 17
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Bun is being rewritten in Rust, moving away from Zig

**[Collections](https://daily.dev/sources/collections)** · 4 min read · 105 upvotes · 17 comments

## Summary

Bun's creator Jarred Sumner used Claude as a coding agent to port over one million lines of Zig code to Rust in roughly six days, shipping the result as a near-complete rewrite. The port passed 99.8% of Bun's test suite, reduced binary size, and matched or slightly exceeded performance benchmarks. The motivations were Zig's persistent memory bugs, its pre-1.0 instability, and a no-AI contribution policy that conflicted with Anthropic's (which acquired Bun's parent company) working style. However, the rewrite contains ~10,000 unsafe blocks, is non-idiomatic Rust, and critically, no human has fully reviewed the codebase — it was written and reviewed by Claude. Several security bug reports have already appeared, yt-dlp deprecated Bun support above 1.3.14 citing reliability concerns, and Electrobun announced it's decoupling from Bun. The episode raises unresolved questions about AI-generated codebases: test suites validate known paths but can't catch subtle invariants or concurrency bugs, and the gap between generating a million lines of code in six days versus understanding what it does remains a fundamental challenge.

## Content

## What happened

Bun 1.3.14 shipped as the last Zig-based release. Shortly after, Jarred Sumner merged a pull request adding over one million lines of Rust code — a near-complete port of Bun's Zig codebase, accomplished in roughly six days using Claude as the primary coding agent. A follow-up PR removing 600,000+ lines of Zig was automatically flagged by GitHub as "AI slop" and closed.

The port was guided by a `porting.md` document with around 300 rules for the AI agents to follow. The strategy was intentional: do a direct line-by-line translation first to avoid regressions, then improve idiomaticity later. The rewrite passed 99.8% of Bun's test suite across all platforms, reduced binary size by 3–8 MB, and benchmarks neutral to slightly faster than the original — the Three.js bundling benchmark came in 10% faster.

Sumner also noted a few unexpected wins. TOML and YAML parser stack overflow tests failed because the Rust port could recurse deeper than the tests expected. At least one critical memory leak was fixed in the process, and the team expects the port to close around 200 open GitHub issues.

## Why they did it

Two things pushed this along. First, Bun has had persistent memory bugs — use-after-free errors, double-frees, segfaults — that Zig's tooling made hard to track down. Rust's compiler-assisted memory safety addresses that class of problem directly. Second, Zig's project has a strict no-AI contribution policy, which conflicts with how Anthropic (which acquired Bun's parent company Oven in late 2025) wants to work. Zig is also pre-1.0 and has introduced breaking changes that created friction.

Sumner had previously committed a Zig-to-Rust porting guide to GitHub before the full rewrite, which sparked early speculation. He described the initial exploration as experimental, but it moved fast.

## The legitimate concerns

The Rust code contains roughly 10,000 `unsafe` blocks. That's partly justified — faithful porting from Zig and FFI bridges to C++ libraries require it — but it does undercut the memory safety argument somewhat. Critics point out that the code is non-idiomatic Rust throughout, which is expected for a first-pass translation but raises questions about long-term maintainability.

The deeper concern is harder to dismiss: no human has fully read this codebase. It was written by Claude and reviewed by Claude. Tests validate known paths, but they don't catch subtle cross-function invariants, edge cases nobody thought to test, or concurrency bugs that only surface under specific load patterns. Bun already had over 5,000 open issues before the rewrite. Several PRs reporting new security bugs have already appeared, and there are reports that Bun's AI triage bot was closing some of them.

Electrobun, a framework built on top of Bun, announced it's decoupling from Bun for version 2.0. The maintainer cited Anthropic's approach of skipping human review and a "rational rollout" as the reason, not the Rust migration itself.

The observation that's stuck with people: the port took six days. The blog post explaining it still wasn't finished four weeks later. There's something telling about that gap — it takes almost no time to generate a million lines of code and much longer to understand what it actually does.

## The broader argument

yt-dlp has already responded by deprecating Bun support above version 1.3.14, citing the AI-assisted rewrite as a future compatibility and reliability risk. That's a pretty direct vote of no-confidence from a major downstream project.

On the other side, Sumner's position is that the Rust port is already better than what it replaced, and that it's going to keep improving. The architecture and data structures are the same. The test suite passes. Memory leaks are getting fixed. The bet is that AI-assisted migration makes language choice more reversible than it used to be — you can experiment, translate, and iterate in ways that weren't practical when humans had to write every line.

Andrew Kelly, Zig's creator, banned AI contributions partly because he views code review as mentorship — a way to identify future core contributors, not just merge patches. Bjarne Stroustrup has argued that LLMs are structurally backward-looking, producing remixes of existing code with existing bugs. Both have pointed to the same downstream problem: if AI handles the coding, junior developers stop getting trained, and the pipeline of people who actually understand systems dries up.

Whether Bun's rewrite works out long-term is genuinely unknown. The test suite passing is real evidence. So is the fact that nobody has read the code. Those two things are both true at the same time, and the industry doesn't have a good framework yet for deciding how much weight to put on each.

## Community discussion

Top comments from developers on daily.dev.

**@andradei** · 14 upvotes

> Makes sense given Bun was purchased by one of the biggest AI companies. The initial merge was filled to the brim with AI slop. I wonder how good the project will be when the migration is over.

**@bobbyiliev** · 9 upvotes

> Claude, rewrite Bun in Rust. Make no mistakes.

**@serdarbuyukdereli** · 4 upvotes

> Last 5 years world is change :) Who is the imagine this :)
>
> ![Screenshot 2026-05-15 at 10.02.30.png](https://media.daily.dev/image/upload/s--09DQHJgR--/f_auto/v1778828554/ugc/content_4014bd57-1e98-43ed-92c1-4545a7504db8?_a=BAMAMiWQ0)

**@texpert** · 3 upvotes

> Actually, this is just Sumner's branch - [https://x.com/jarredsumner/status/2051595933704761618/photo/1 :D](https://x.com/jarredsumner/status/2051595933704761618/photo/1)

**@kkurko** · 2 upvotes

> Makes sense, but let's wait for the results to arrive

---

Tags: [#rust](https://daily.dev/tags/rust), [#anthropic](https://daily.dev/tags/anthropic), [#zig](https://daily.dev/tags/zig), [#bun](https://daily.dev/tags/bun)

[View this post on daily.dev](https://daily.dev/posts/bun-is-being-rewritten-in-rust-moving-away-from-zig-4ty7usyvh)
