Bun's AI Rust Rewrite: Stability Fix or New Risks?

Theo - t3.gggo watch the original →

Bun team uses AI agents to port 960k Zig lines to Rust in 6 days, passing 99.8% tests amid Zig woes, Windows instability, and Anthropic acquisition fears prioritizing Claude Code over general users.

Bun's Stability Challenges and User Exodus

Bun, a high-performance JS runtime and bundler, faces mounting stability issues, particularly on Windows, Electron compatibility, and memory management. Users like Dax from OpenCode are ditching Bun-specific APIs (e.g., faster bun.file()) for Node.js shims due to persistent crashes post-version 1.3.10, poor embedding in desktop apps, and negligible bundled runtime perf gains (Node ~20k req/s to Bun ~60k with Express—impressive but not transformative for most). Theo notes personal frustrations with memory leaks during Advent of Code and monorepo package management edge cases in T3 Code. Bun's bundling as single binaries powers tools like Claude Code, amplifying these pains to millions, but Node/Deno flexibility wins for embeddability and future-proofing.

Post-Anthropic acquisition (Dec 2024), optimism faded as Claude Code "shitified": reduced reasoning effort, stale sessions, prompt regressions, and OpenClaw billing exploits via commit messages. Anthropic's postmortem admitted product-layer faults, but declining dogfooding raises fears Bun integration could import similar policy-driven neglect. William Johnson captures this: "Bun is great software... fast and practical... I want Bun to win... but I'm worried about Bun's future." Prioritization skews toward Claude Code paths, deprioritizing monorepo/package bugs affecting broader users like T3 Code.

Zig's Footguns Undermine Bun's Ambitions

Bun's Zig foundation, while enabling compile-time magic (e.g., multiplatform tweaks via comments), exposes C-like risks: no inherent memory safety, leaks, crashes, Windows woes. Bun forked Zig for parallel semantic analysis and faster LLVM codegen (4x debug builds on Mac/Linux), yielding Bun 1.3.14. Yet community tensions and novel issues stalled progress. Jarred Sumner laments: "I am so tired of worrying about and spending lots of time fixing memory leaks and crashes and stability issues. It would be so nice if the language provided more powerful tools for preventing these things."

As solo authorship scaled to team/AI abstraction, low-level details slipped. Bundled tools (Claude Code ships Bun binary) inherit Zig's multiplatform pains, pushing migrations. Theo observes Bun excels in dev/package speed but falters shipped/bundled, where Node's maturity shines.

AI Agents Drive Audacious Rust Port

In a Claude-generated branch, agents parallelized a 960k-line Zig-to-Rust port in 6 days, passing 99.8% pre-existing tests on Linux x64 glibc (soon multiplatform). Jarred: "It's basically the same codebase except now we can have the compiler enforce the lifetimes of types and we get destructors when it makes sense... the ugly parts look uglier now because they all have unsafe everywhere which encourages refactoring."

No async Rust or heavy crates; line-by-line translation preserves perf (no slowdowns seen, closes 200+ issues). Bun's official account hints 1.3.14 as last Zig version if merged. Pipeline leverages agents for tedious lifts, but halfway in: 681k Rust lines (double comments, AI hallmark) vs. 571k Zig, with 13k+ 'unsafe' blocks—vs. UV's 70ish in 350k lines. Unsafe pollutes borrow checker safety, signaling C++-style port, not idiomatic Rust. Future: agent-refactor leaks bottom-up, enforcing safety subtree-by-subtree.

Charlie (UV creator, now OpenAI) pushes back: trading "200 known issues for an unknown number of unknown issues... even a great test suite only covers some portion." Theo agrees: tests miss behaviors, rewrite risks accruing debt in non-Claude paths.

Rewrite Risks: Prioritization and Technical Debt

Pre-rewrite: 10 bugs split Claude-impacting vs. general (monorepo/package). Team focuses Claude; others languish. Post-rewrite: 100 bugs, 50/50 split, but Claude tests dominate—new debt piles on general paths. Community forks unlikely (Node.js history proves complexity). Anthropic funding ties Bun to Claude Code excellence, but shitification policies could creep in, eroding dogfooding.

Theo weighs: Rust's borrow checker prevents leaks/crashes at scale, but port's unsafe density (13k vs. UV's sparse) scares. Viable for Bun's speed focus, but confidence in shipping unproven.

"Notable Quotes"

  • Jarred Sumner (Bun creator): "99.8% of Bun's pre-existing test suites pass on the Linux x64 glibc." Context: Measures rewrite fidelity, signaling merge viability despite risks.
  • Jarred Sumner: "The ugly parts look uglier now because they all have unsafe everywhere which encourages refactoring." Context: Highlights Rust's visibility into Zig's unsafety, guiding iterative cleanup.
  • Theo: "Bun went from forking Zig to forking itself in Rust very quickly." Context: Captures rapid pivot from language fork to self-rewrite amid stalemates.
  • William Johnson: "Anthropic has direct incentive to keep Bun excellent... but now that Claude Code is falling apart it feels less so." Context: Ties Bun's fate to declining Claude Code post-acquisition.
  • Charlie: "Are you trading 200 known issues for an unknown number of unknown issues that users will end up discovering over time?" Context: Questions test coverage limits in massive rearchitecture.

Key Takeaways

  • Audit Bun usage: If relying on Windows/Electron/monorepo stability, benchmark Node/Deno migrations now—perf deltas shrink bundled.
  • Watch Rust ports warily: Line-by-line translations breed 'unsafe' pollution; prioritize idiomatic refactors post-port.
  • AI agents excel at parallel tedium (960k lines/6 days), but validate with full test+bench suites—coverage gaps loom.
  • Post-acquisition: Monitor Claude Code as Bun canary; funding skews prioritization to embedded paths.
  • Favor memory-safe langs at scale: Rust's borrow checker trumps Zig's trust for team/AI-led maintenance.
  • Dogfood ruthlessly: Anthropic postmortem shows prompt/regression slips kill UX—apply to runtimes.
  • Forks rarely thrive: Invest in upstream signals over community splits for complex tooling.
  • #news
  • #review
  • #rant

summary by x-ai/grok-4.1-fast. probably wrong about something. check the source.