<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/bun-rewrites-535k-lines-of-zig-into-rust-in-four-months-eliminates-numerous-memory-leaks-rbhvdbhty" -->

---
title: Bun Rewrites 535K Lines of Zig into Rust in Four Months,...
description: Bun creator Jarred Sumner announced that Bun&#x27;s entire codebase (535,496 lines of Zig) was rewritten into Rust using AI agents, primarily a pre-release Claude...
canonical: https://daily.dev/posts/bun-rewrites-535k-lines-of-zig-into-rust-in-four-months-eliminates-numerous-memory-leaks-rbhvdbhty
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Bun Rewrites 535K Lines of Zig into Rust in Four Months, Eliminates Numerous Memory Leaks | daily.dev
og:description: Bun creator Jarred Sumner announced that Bun&#x27;s entire codebase (535,496 lines of Zig) was rewritten into Rust using AI agents, primarily a pre-release Claude...
og:url: https://daily.dev/posts/bun-rewrites-535k-lines-of-zig-into-rust-in-four-months-eliminates-numerous-memory-leaks-rbhvdbhty
og:image: https://api.daily.dev/og/posts/rBHvdbhtY.png
og:image:alt: Bun Rewrites 535K Lines of Zig into Rust in Four Months, Eliminates Numerous Memory Leaks
og:image:width: 1200
og:image:height: 630
og:locale: en
---

[InfoQ](https://daily.dev/sources/infoq)

[Read post](https://api.daily.dev/r/rBHvdbhtY)

# [Bun Rewrites 535K Lines of Zig into Rust in Four Months, Eliminates Numerous Memory Leaks](https://api.daily.dev/r/rBHvdbhtY "Go to post")

Bun creator Jarred Sumner announced that Bun's entire codebase (535,496 lines of Zig) was rewritten into Rust using AI agents, primarily a pre-release Claude model, completing in four months instead of an estimated year with a small human team. The process used around 50 dynamic workflows, adversarial reviewer agents, fuzzing, and security review, costing roughly $165,000 in API tokens. The resulting Rust implementation, shipped in Bun v1.4.0, fixed 128 longstanding bugs, eliminated native memory leaks (609 MB stable vs. 6.7 GB climbing in repeated build tests), and improved HTTP throughput by 2-5%. Zig creator Andrew Kelley published a sharply critical response questioning whether AI-driven mass rewrites actually reduce bugs or just shift risk into unreviewed code, while a Hacker News commenter framed Bun as an industry test case for whether massive LLM-generated codebases stay maintainable long-term.

[#rust](/tags/rust "Check all #rust posts")[#ai-coding](/tags/ai-coding "Check all #ai-coding posts")[#zig](/tags/zig "Check all #zig posts")[#bun](/tags/bun "Check all #bun posts")

Sep 20 • 5m read time • From [infoq.com](https://api.daily.dev/r/rBHvdbhtY "infoq.com")

[![Post cover image](https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/8f765e1722941b990e5e42282c4cf261?_a=AQAEuop)](https://api.daily.dev/r/rBHvdbhtY "Go to post")

Questions this post answers

Did Bun rewrite its codebase from Zig to Rust and why?

Yes, Bun's creator Jarred Sumner rewrote the entire 535,496-line Zig codebase into Rust to eliminate recurring memory safety bugs like use-after-free and double-free errors, which Rust's borrow checker catches at compile time. The AI-assisted rewrite, using a pre-release Claude model across roughly 50 workflows, took four months instead of an estimated year and shipped in Bun v1.4.0\. Track how Bun's Zig-to-Rust migration evolves and impacts your builds on daily.dev.

What bugs and performance changes came from Bun's Rust rewrite in version 1.4.0?

Bun v1.4.0 resolved 128 longstanding bugs present in v1.3.14 and eliminated native memory leaks: running 2,000 consecutive Bun.build() operations plateaued at 609 MB in Rust versus climbing past 6.7 GB previously. HTTP throughput also increased by 2% to 5%. The rewrite introduced 19 subtle semantic regressions later caught through security review and fuzzing. Developers weighing a Bun upgrade can follow real-world benchmarks like this on daily.dev.

How much did it cost to use AI to rewrite Bun from Zig to Rust?

Getting the full test suite passing cost around $165,000 worth of API tokens, consuming 5.9 billion uncached input tokens, 690 million output tokens, and 72 billion cached input token reads. Jarred Sumner estimated the equivalent manual rewrite would have taken three engineers with full codebase context about a year, using 64 parallel Claude instances across four workspace shards. Anyone comparing AI-assisted rewrites against manual engineering effort can follow cases like this on daily.dev.

4 Upvotes1 Comment

Comment

Bookmark

Copy

![Placeholder image for anonymous user](https://media.daily.dev/image/upload/s--qsFuKGv_--/t_logo,f_auto/public/noProfile)Share your thoughts Post

Share this post

[![InfoQ's image](https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/afc3bced3e1e4b188dd9127017a60e0c)](https://daily.dev/sources/infoq)

[InfoQ](https://daily.dev/sources/infoq "https://daily.dev/sources/infoq")

InfoQ is a leading online platform for software developers, architects, and technical leaders, provi... Read more

1.4K Followers

•

6.6K Upvotes

#### Would you recommend this post?

Copy link

Slack

WhatsApp

Facebook

X

New Squad

Copy linkShare with your friends

4

1

```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":"Bun Rewrites 535K Lines of Zig into Rust in Four Months, Eliminates Numerous Memory Leaks","url":"https://daily.dev/posts/bun-rewrites-535k-lines-of-zig-into-rust-in-four-months-eliminates-numerous-memory-leaks-rbhvdbhty","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/bun-rewrites-535k-lines-of-zig-into-rust-in-four-months-eliminates-numerous-memory-leaks-rbhvdbhty"},"datePublished":"2026-09-20T20:08:16.579Z","dateModified":"2026-09-21T06:57:58.077Z","description":"Bun creator Jarred Sumner announced that Bun's entire codebase (535,496 lines of Zig) was rewritten into Rust using AI agents, primarily a pre-release Claude...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/8f765e1722941b990e5e42282c4cf261?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/8f765e1722941b990e5e42282c4cf261?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"InfoQ","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":"InfoQ","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/afc3bced3e1e4b188dd9127017a60e0c","url":"https://daily.dev/sources/infoq"},"commentCount":1,"discussionUrl":"https://daily.dev/posts/bun-rewrites-535k-lines-of-zig-into-rust-in-four-months-eliminates-numerous-memory-leaks-rbhvdbhty","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":4},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":1}],"keywords":"rust,ai-coding,zig,bun","timeRequired":"PT5M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"InfoQ","item":"https://daily.dev/sources/infoq"},{"@type":"ListItem","position":3,"name":"Bun Rewrites 535K Lines of Zig into Rust in Four Months, Eliminates Numerous Memory Leaks"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/bun-rewrites-535k-lines-of-zig-into-rust-in-four-months-eliminates-numerous-memory-leaks-rbhvdbhty","comment":[{"@type":"Comment","text":"This will be cool to see how it goes. Big loss for Zig though","datePublished":"2026-09-21T13:05:11.725Z","url":"https://daily.dev/posts/rBHvdbhtY#c-ntslmhVjg","author":{"@type":"Person","name":"Peter Cruckshank","url":"https://daily.dev/petecapecod","image":"https://media.daily.dev/image/upload/s--ZJhQyKws--/f_auto/v1721235024/avatars/avatar_A9xh33q0QoxtkGoJRCosp"}}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/bun-rewrites-535k-lines-of-zig-into-rust-in-four-months-eliminates-numerous-memory-leaks-rbhvdbhty#faq","mainEntity":[{"@type":"Question","name":"Did Bun rewrite its codebase from Zig to Rust and why?","acceptedAnswer":{"@type":"Answer","text":"Yes, Bun's creator Jarred Sumner rewrote the entire 535,496-line Zig codebase into Rust to eliminate recurring memory safety bugs like use-after-free and double-free errors, which Rust's borrow checker catches at compile time. The AI-assisted rewrite, using a pre-release Claude model across roughly 50 workflows, took four months instead of an estimated year and shipped in Bun v1.4.0. Track how Bun's Zig-to-Rust migration evolves and impacts your builds on daily.dev."}},{"@type":"Question","name":"What bugs and performance changes came from Bun's Rust rewrite in version 1.4.0?","acceptedAnswer":{"@type":"Answer","text":"Bun v1.4.0 resolved 128 longstanding bugs present in v1.3.14 and eliminated native memory leaks: running 2,000 consecutive Bun.build() operations plateaued at 609 MB in Rust versus climbing past 6.7 GB previously. HTTP throughput also increased by 2% to 5%. The rewrite introduced 19 subtle semantic regressions later caught through security review and fuzzing. Developers weighing a Bun upgrade can follow real-world benchmarks like this on daily.dev."}},{"@type":"Question","name":"How much did it cost to use AI to rewrite Bun from Zig to Rust?","acceptedAnswer":{"@type":"Answer","text":"Getting the full test suite passing cost around $165,000 worth of API tokens, consuming 5.9 billion uncached input tokens, 690 million output tokens, and 72 billion cached input token reads. Jarred Sumner estimated the equivalent manual rewrite would have taken three engineers with full codebase context about a year, using 64 parallel Claude instances across four workspace shards. Anyone comparing AI-assisted rewrites against manual engineering effort can follow cases like this on daily.dev."}}]}
```

