<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/the-real-lessons-behind-the-bun-rewrite-z4ng3eu7w" -->

---
title: The real lessons behind the Bun rewrite | daily.dev
description: Bun, the JavaScript runtime originally written in Zig, was acquired by Anthropic and subsequently rewrote 535,000 lines of Zig into Rust using an army of...
canonical: https://daily.dev/posts/the-real-lessons-behind-the-bun-rewrite-z4ng3eu7w
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: The real lessons behind the Bun rewrite | daily.dev
og:description: Bun, the JavaScript runtime originally written in Zig, was acquired by Anthropic and subsequently rewrote 535,000 lines of Zig into Rust using an army of...
og:url: https://daily.dev/posts/the-real-lessons-behind-the-bun-rewrite-z4ng3eu7w
og:image: https://api.daily.dev/og/posts/Z4NG3EU7W.png
og:image:alt: The real lessons behind the Bun rewrite
og:image:width: 1200
og:image:height: 630
og:locale: 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.

# The real lessons behind the Bun rewrite

**[Awesome](https://daily.dev/sources/awesome-coding)** · 11 min read · 1 upvotes · 0 comments

## Summary

Bun, the JavaScript runtime originally written in Zig, was acquired by Anthropic and subsequently rewrote 535,000 lines of Zig into Rust using an army of Claude AI agents over 11 days, generating 6,778 commits and consuming ~$165,000 in API costs. The rewrite fixed 128 bugs, reduced memory usage from 6.7 GB to 600 MB, shrank the binary by 20%, and improved performance 2–5%. However, Zig's creator Andrew Kelley fired back, arguing Bun's memory problems stemmed from poor engineering culture rather than Zig's limitations, pointing out that the test suite contradiction (good enough to validate 1M AI-generated lines but not to prevent original bugs), that performance gains came from engineering improvements not Rust itself, and that the rewrite conveniently doubled as a marketing demo for Claude. Three key lessons emerge: language choices must match team culture and discipline; AI dramatically changes the economics of large rewrites but requires robust surrounding engineering infrastructure; and changing multiple variables simultaneously makes it impossible to attribute improvements to any single factor.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.youtube.com/watch?v=U73TPeCCAMI>

## Questions this post answers

### Why did Bun rewrite its codebase from Zig to Rust?

Bun's engine sits between JavaScript Core's garbage-collected memory model and Zig's manual memory management, which repeatedly caused use-after-free bugs, double frees, and memory leaks despite address sanitizers, fuzzing, and safety-checked builds. Rust's ownership system and borrow checker turn many of these bugs into compile-time errors instead of production incidents, which Bun's team argued was a better fit than Zig's explicit defer-based cleanup.

_Developers weighing Rust against Zig for memory-heavy systems can follow this kind of real-world trade-off analysis on daily.dev._

### How did Bun use AI to rewrite over 500,000 lines of Zig code into Rust?

Bun's team ran around 50 automated agent workflows across 64 cloud instances and four git worktrees, using Claude to translate Zig files into Rust, fix compiler errors, run tests, and review code. Each batch was reviewed by at least two adversarial agents. The rewrite took 11 days, produced 6,778 commits, added over 1 million lines, and cost about $165,000 in API usage, starting from roughly 16,000 initial compiler errors.

_Teams considering AI-driven code migrations can track how large-scale agent rewrites actually play out via daily.dev._

### What did Zig creator Andrew Kelley say in response to Bun's Rust rewrite announcement?

Andrew Kelley argued Bun's own culture of prioritizing shipping over engineering discipline caused its bugs, not Zig itself, pointing to TigerBeetle's Tiger Style philosophy of eliminating memory bugs through architecture rather than language enforcement. He also noted Bun could have enabled Zig's existing LTO support earlier, that binary-size gains came from separate engineering changes, and that Bun's benchmarks omitted compilation speed entirely.

_Anyone judging language-migration claims against a critic's rebuttal can follow both sides of debates like this on daily.dev._

## Similar posts on daily.dev

- [Bun rewrite in rust](https://daily.dev/posts/bun-rewrite-in-rust-zff65rp1d) · Medium · 2 upvotes · 1 comments
- [Zig creator calls Bun's Claude Rust rewrite 'unreviewed slop'](https://daily.dev/posts/zig-creator-calls-bun-s-claude-rust-rewrite-unreviewed-slop--zlkefwvdc) · DEVCLASS · 11 upvotes · 6 comments

---

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

[View this post on daily.dev](https://daily.dev/posts/the-real-lessons-behind-the-bun-rewrite-z4ng3eu7w)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"The real lessons behind the Bun rewrite","url":"https://daily.dev/posts/the-real-lessons-behind-the-bun-rewrite-z4ng3eu7w","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/the-real-lessons-behind-the-bun-rewrite-z4ng3eu7w"},"datePublished":"2026-07-20T09:04:23.462Z","dateModified":"2026-09-14T08:45:36.759Z","description":"Bun, the JavaScript runtime originally written in Zig, was acquired by Anthropic and subsequently rewrote 535,000 lines of Zig into Rust using an army of...","image":"https://i.ytimg.com/vi/U73TPeCCAMI/sddefault.jpg","thumbnailUrl":"https://i.ytimg.com/vi/U73TPeCCAMI/sddefault.jpg","isAccessibleForFree":true,"articleSection":"Awesome","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Awesome","logo":"https://media.daily.dev/image/upload/s--mj_0cdD8--/f_auto/v1710506099/logos/awesome-coding","url":"https://daily.dev/sources/awesome-coding"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/the-real-lessons-behind-the-bun-rewrite-z4ng3eu7w","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"rust,ai-coding,zig,bun","timeRequired":"PT11M","video":{"@type":"VideoObject","name":"The real lessons behind the Bun rewrite","description":"Bun, the JavaScript runtime originally written in Zig, was acquired by Anthropic and subsequently rewrote 535,000 lines of Zig into Rust using an army of...","thumbnailUrl":"https://i.ytimg.com/vi/U73TPeCCAMI/sddefault.jpg","uploadDate":"2026-07-20T09:04:23.462Z","duration":"PT11M","url":"https://api.daily.dev/r/Z4NG3EU7W","embedUrl":"https://www.youtube.com/embed/U73TPeCCAMI"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Awesome","item":"https://daily.dev/sources/awesome-coding"},{"@type":"ListItem","position":3,"name":"The real lessons behind the Bun rewrite"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/the-real-lessons-behind-the-bun-rewrite-z4ng3eu7w#faq","mainEntity":[{"@type":"Question","name":"Why did Bun rewrite its codebase from Zig to Rust?","acceptedAnswer":{"@type":"Answer","text":"Bun's engine sits between JavaScript Core's garbage-collected memory model and Zig's manual memory management, which repeatedly caused use-after-free bugs, double frees, and memory leaks despite address sanitizers, fuzzing, and safety-checked builds. Rust's ownership system and borrow checker turn many of these bugs into compile-time errors instead of production incidents, which Bun's team argued was a better fit than Zig's explicit defer-based cleanup. Developers weighing Rust against Zig for memory-heavy systems can follow this kind of real-world trade-off analysis on daily.dev."}},{"@type":"Question","name":"How did Bun use AI to rewrite over 500,000 lines of Zig code into Rust?","acceptedAnswer":{"@type":"Answer","text":"Bun's team ran around 50 automated agent workflows across 64 cloud instances and four git worktrees, using Claude to translate Zig files into Rust, fix compiler errors, run tests, and review code. Each batch was reviewed by at least two adversarial agents. The rewrite took 11 days, produced 6,778 commits, added over 1 million lines, and cost about $165,000 in API usage, starting from roughly 16,000 initial compiler errors. Teams considering AI-driven code migrations can track how large-scale agent rewrites actually play out via daily.dev."}},{"@type":"Question","name":"What did Zig creator Andrew Kelley say in response to Bun's Rust rewrite announcement?","acceptedAnswer":{"@type":"Answer","text":"Andrew Kelley argued Bun's own culture of prioritizing shipping over engineering discipline caused its bugs, not Zig itself, pointing to TigerBeetle's Tiger Style philosophy of eliminating memory bugs through architecture rather than language enforcement. He also noted Bun could have enabled Zig's existing LTO support earlier, that binary-size gains came from separate engineering changes, and that Bun's benchmarks omitted compilation speed entirely. Anyone judging language-migration claims against a critic's rebuttal can follow both sides of debates like this on daily.dev."}}]}
```

