跪拜 Guibai
← All articles
Bun · Rust · Node.js

Bun v1.4 Lands After an 11-Day AI Rewrite from Zig to Rust

By GitLqr ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

A JavaScript runtime that installs dependencies 5x faster than npm, starts in 5ms, and bundles a native image processor, SQL client, and headless browser eliminates entire categories of third-party packages. The Rust rewrite also removes the memory-safety risks that made earlier Bun versions a gamble for production.

Summary

Bun v1.4 is the first production release running entirely on a Rust engine, replacing the original Zig codebase. The migration, driven by up to 64 Claude agents, turned 535,496 lines of Zig into over a million lines of Rust in under two weeks. The result is a 20% smaller binary, a drop in Bun.build() memory leaks from 6,745 MB to 609 MB, and a p99 CPU usage reduction from 24% to 10% in Anthropic's own Claude Code project.

The release also deepens Bun's native toolchain, baking in image processing (7x faster than sharp), headless browser testing, SQL clients for four databases, cron jobs, and archive handling. These additions push Bun closer to its goal of making node_modules largely unnecessary.

Benchmarks against Node.js v26 show a cold start of ~5.1ms versus ~19ms, HTTP throughput of 290k req/s versus 71k req/s, and install times that are 5x faster than npm on a fresh T3 Stack project. TypeScript support includes JSX, path aliases, enums, and namespaces without extra configuration, though static type checking still requires tsc --noEmit.

Takeaways
Bun was rewritten from Zig to Rust in 11 days using 64 Claude agents, producing over 1 million lines of Rust code.
The rewrite shrank the binary by 20% and reduced Bun.build() memory leaks from 6,745 MB to 609 MB.
Anthropic's Claude Code project saw p99 CPU usage drop from 24% to 10% after switching to the Rust-based Bun.
Bun.Image processes images 7x faster than sharp; Bun.WebView replaces Playwright and Puppeteer for headless testing.
Bun.SQL provides a single built-in client for PostgreSQL, MySQL, MariaDB, and SQLite.
Bun v1.4 cold-starts in ~5.1ms on Linux versus ~19ms for Node.js v26 and handles 290k HTTP req/s versus 71k.
A fresh T3 Stack install takes 7 seconds with Bun versus 38 seconds with npm.
Bun runs .ts files with JSX, path aliases, enums, and namespaces natively, but static type checking still requires tsc --noEmit.
Conclusions

The 13,000 unsafe blocks in the AI-generated Rust code and the lack of human review on the rewrite PR make this a high-stakes bet on AI-assisted systems programming that paid off in benchmarks but leaves open questions about long-term maintainability.

Bun's strategy of absorbing common tooling into the runtime itself—image processing, SQL, headless browsing—treats package ecosystems as a liability rather than an asset, which is a fundamentally different philosophy from Node.js and Deno.

The performance gap between Bun and Node.js is now wide enough that CI/CD pipeline cost savings alone could justify a switch, even for teams that keep Node.js in production.

Concepts & terms
Bun
A JavaScript and TypeScript runtime, bundler, and package manager written in Rust (originally Zig), designed as a faster, all-in-one replacement for Node.js and its associated tooling.
Type Stripping
The process of removing TypeScript type annotations from source code so it can run as plain JavaScript, now a default behavior in Node.js v24+.
N-API
A stable API for building native Node.js addons in C/C++; some complex modules depend on it and may not be fully compatible with Bun's native module layer.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗