<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/rewriting-bun-in-rust-epqvep14y" -->

---
title: Rewriting Bun in Rust | daily.dev
description: Bun's creator Jarred Sumner details how the entire Bun JavaScript runtime was rewritten from Zig to Rust in 11 days using Claude Code with 64 parallel AI...
canonical: https://daily.dev/posts/rewriting-bun-in-rust-epqvep14y
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Rewriting Bun in Rust | daily.dev
og:description: Bun's creator Jarred Sumner details how the entire Bun JavaScript runtime was rewritten from Zig to Rust in 11 days using Claude Code with 64 parallel AI...
og:url: https://daily.dev/posts/rewriting-bun-in-rust-epqvep14y
og:image: https://api.daily.dev/og/posts/ePqvEp14y.png
og:image:alt: Rewriting Bun in Rust
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.

# Rewriting Bun in Rust

**[Bun](https://daily.dev/sources/bun)** · 28 min read · 5 upvotes · 0 comments

## Summary

Bun's creator Jarred Sumner details how the entire Bun JavaScript runtime was rewritten from Zig to Rust in 11 days using Claude Code with 64 parallel AI agents. The motivation was systematic memory safety: Zig's lack of RAII-style Drop semantics led to persistent use-after-free, double-free, and memory leak bugs. Rather than enforcing style guides, the team leveraged Rust's borrow checker and Drop trait to make these bugs compile-time errors. The rewrite used dynamic workflows with adversarial review agents, a PORTING.md guide, and a LIFETIMES.tsv file to ensure behavioral fidelity. The result: Bun v1.4.0 fixes 128 bugs, reduces memory usage dramatically (e.g. 6.7 GB → 609 MB for 2,000 builds), shrinks binary size by ~20%, and improves HTTP throughput by 2–5%. The process cost ~$165,000 in API tokens and took one engineer 11 days instead of an estimated 3 engineers for a year.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://bun.com/blog/bun-in-rust>

## Questions this post answers

### Is Bun's runtime now written in Rust instead of Zig?

Yes, Bun v1.4.0 is the first version of Bun written in Rust, replacing the Zig codebase used since v1.3.14 and earlier. The rewrite covered 535,496 lines of Zig code across 1,448 files, ported mechanically to preserve architecture and behavior while gaining Rust's borrow checker and automatic Drop-based cleanup instead of Zig's manual defer-based memory management.

_Track ecosystem-shaping runtime changes like Bun's language rewrite as they land, right where developers already read updates on daily.dev._

### How much faster and smaller is Bun v1.4.0 compared to v1.3.14?

Bun v1.4.0 is roughly 2-5% faster on HTTP throughput and CLI workloads and about 20% smaller in binary size on Linux and Windows compared to v1.3.14. HTTP throughput with Bun.serve rose from 169.6k to 177.7k req/s, and binary size on Linux dropped from 88 MB to 70 MB, largely from the Rust rewrite plus ICU and linker optimizations.

_Developers deciding whether to upgrade a runtime can weigh real benchmark deltas like these on daily.dev before committing._

### What memory leak issues did rewriting a JavaScript runtime in Rust fix compared to Zig?

Rust's automatic Drop-based cleanup fixed memory leaks that Zig's manual defer-based approach left unresolved, including a leak where every in-process Bun.build() call leaked about 3 MB of parsed source text and AST symbol tables, causing dev servers that rebuild on every request to run out of memory over time; after 2,000 builds, memory usage dropped from 6,745 MB to 609 MB.

_Anyone debugging leaks from manual memory management can compare how Rust's ownership model changes that story 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

---

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

[View this post on daily.dev](https://daily.dev/posts/rewriting-bun-in-rust-epqvep14y)

```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":"Rewriting Bun in Rust","url":"https://daily.dev/posts/rewriting-bun-in-rust-epqvep14y","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/rewriting-bun-in-rust-epqvep14y"},"datePublished":"2026-07-08T21:49:28.870Z","dateModified":"2026-09-13T19:38:50.825Z","description":"Bun's creator Jarred Sumner details how the entire Bun JavaScript runtime was rewritten from Zig to Rust in 11 days using Claude Code with 64 parallel AI...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/524be9d1b9fe07969277f42e3963a384?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/524be9d1b9fe07969277f42e3963a384?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Bun","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":"Bun","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/9d715eb44dae4d74a2cebd8871d91a0d","url":"https://daily.dev/sources/bun"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/rewriting-bun-in-rust-epqvep14y","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":5},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"rust,claude,zig,bun","timeRequired":"PT28M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Bun","item":"https://daily.dev/sources/bun"},{"@type":"ListItem","position":3,"name":"Rewriting Bun in Rust"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/rewriting-bun-in-rust-epqvep14y#faq","mainEntity":[{"@type":"Question","name":"Is Bun's runtime now written in Rust instead of Zig?","acceptedAnswer":{"@type":"Answer","text":"Yes, Bun v1.4.0 is the first version of Bun written in Rust, replacing the Zig codebase used since v1.3.14 and earlier. The rewrite covered 535,496 lines of Zig code across 1,448 files, ported mechanically to preserve architecture and behavior while gaining Rust's borrow checker and automatic Drop-based cleanup instead of Zig's manual defer-based memory management. Track ecosystem-shaping runtime changes like Bun's language rewrite as they land, right where developers already read updates on daily.dev."}},{"@type":"Question","name":"How much faster and smaller is Bun v1.4.0 compared to v1.3.14?","acceptedAnswer":{"@type":"Answer","text":"Bun v1.4.0 is roughly 2-5% faster on HTTP throughput and CLI workloads and about 20% smaller in binary size on Linux and Windows compared to v1.3.14. HTTP throughput with Bun.serve rose from 169.6k to 177.7k req/s, and binary size on Linux dropped from 88 MB to 70 MB, largely from the Rust rewrite plus ICU and linker optimizations. Developers deciding whether to upgrade a runtime can weigh real benchmark deltas like these on daily.dev before committing."}},{"@type":"Question","name":"What memory leak issues did rewriting a JavaScript runtime in Rust fix compared to Zig?","acceptedAnswer":{"@type":"Answer","text":"Rust's automatic Drop-based cleanup fixed memory leaks that Zig's manual defer-based approach left unresolved, including a leak where every in-process Bun.build() call leaked about 3 MB of parsed source text and AST symbol tables, causing dev servers that rebuild on every request to run out of memory over time; after 2,000 builds, memory usage dropped from 6,745 MB to 609 MB. Anyone debugging leaks from manual memory management can compare how Rust's ownership model changes that story on daily.dev."}}]}
```

