
I wish this was clickbait
Audio Summary
AI Summary
Bun, a technology I've supported since its inception, is undergoing a significant transition, moving from Zig to Rust. This decision, while promising a brighter future, also introduces considerable uncertainties. Several prominent users, including Dax from Open Code, have expressed concerns, with Dax even deciding to migrate Open Code off Bun in favor of Node.js due to stability issues on Windows, Electron compatibility, and, most importantly, uncertainty about Bun's future.
The core of the issue lies in Bun's original language, Zig. While Zig is powerful and innovative, it presents challenges, particularly in memory safety and cross-platform stability. Bun, being one of the largest Zig projects, has encountered these issues, especially on Windows, leading to memory management problems and crashes. The decision to rewrite Bun in Rust aims to address these fundamental problems, leveraging Rust's memory safety features.
Jared, Bun's creator, confirmed that 99.8% of Bun's existing test suites pass in the Rust rewrite on Linux x64. This rewrite, initially conceived as a side project exploring AI's capability to refactor code, has gained significant traction and is likely to be merged. This move is particularly noteworthy given Bun's history of forking Zig to address its limitations, and now it's effectively forking itself into Rust.
The rewrite is driven by a desire for greater stability and maintainability. Jared explicitly stated his frustration with constantly fixing memory leaks, crashes, and stability issues in Zig, expressing a wish for a language that provides more powerful tools to prevent such problems. Rust, with its robust borrow checker and memory safety guarantees, offers a compelling solution.
However, this ambitious rewrite introduces several layers of problems. First, there are the inherent issues with Zig itself, which Bun has been grappling with. Second, the specific challenges Bun faces, such as Windows stability and API compatibility, which have prompted migrations like Open Code's. Third, and perhaps most critically, the problems associated with rewriting an entire codebase.
The acquisition of Bun by Anthropic in December 2025 initially seemed reassuring, with promises of continued open-source development, the same team, and a focus on high-performance JavaScript tooling. Anthropic's Claude Code, which ships as a Bun executable, provided a direct incentive for Bun's excellence. However, recent issues with Claude Code, including a decline in quality and perceived "enshittification," have raised concerns about whether similar problems could eventually affect Bun as it becomes more integrated into Anthropic's ecosystem. The fear is that Anthropic's policies, which led to Claude Code's decline, might eventually influence Bun, potentially deprioritizing general user issues in favor of those directly impacting Claude Code.
This prioritization concern is significant. If Bun's primary purpose and funding become tied to Claude Code support, issues not affecting Claude Code, such as those related to package management for large monorepos, might be neglected. A complete rearchitecture could introduce new categories of bugs, and if these don't impact Claude Code, they might not be addressed swiftly, leading to a new form of technical debt.
Jared's approach to the Rust rewrite involves a direct, line-by-line port of the existing Zig codebase. This is a critical detail. Instead of a complete redesign to leverage Rust's idiomatic patterns from scratch, the team is essentially translating Zig code into Rust. This is evident in the extensive use of the `unsafe` keyword in the Rust rewrite. While Rust's borrow checker enforces memory safety at compile time, the `unsafe` keyword allows developers to bypass these checks, similar to writing C++ with Rust syntax.
A comparison with UV, a Rust-based package manager, highlights this. UV, with 350,000 lines of Rust, has about 70 instances of `unsafe` calls. In contrast, the Bun Rust rewrite, with 681,000 lines of Rust code (and still containing 571,000 lines of Zig), has over 13,000 calls to `unsafe`. This suggests that the rewrite is not fully embracing Rust's memory safety paradigm but rather porting potentially unsafe Zig patterns directly, necessitating the frequent use of `unsafe`. While this might be a temporary measure, with the long-term goal of refactoring these sections to be memory-safe, it currently represents a significant technical debt.
The use of AI agents in this rewrite is groundbreaking. Jared mentioned that the rewrite was not simply "Claude, rewrite Bun in Rust." This 960,000-line code rewrite, initiated just six days prior to his statement, would be a massive undertaking manually. AI tools are likely playing a crucial role in this rapid porting process. The ability to give an agent a task like "this unsafe function is causing issues; make it not unsafe" and have it iterate until borrow checker errors are resolved could be a powerful way to address memory safety progressively.
However, concerns remain. As Charlie, a respected figure in the community, pointed out, trading 200 known issues for an unknown number of unknown issues is a risk. While passing existing test suites is excellent, even comprehensive tests don't cover all program behaviors. The complexity of Bun means that community forks are unlikely to be a viable solution if the main project's focus shifts away from the broader community's needs.
Jared acknowledges the challenges, stating that the rewrite is currently structured with many dozens of crates to speed up compile times and block cyclic dependencies. He is actively seeking advice on idiomatic Rust approaches for certain patterns, indicating a learning process during the port. The high number of likes and few replies on his technical queries underscore the niche nature of this low-level knowledge, suggesting that even AI agents might struggle with these complex problems.
Despite the concerns, Jared's commitment to delivering a measurably better product in terms of performance, memory usage, and stability, with stability being the priority, provides some reassurance. The sheer ambition of rewriting a core system like Bun in a new language in such a short timeframe, potentially leveraging AI, is groundbreaking and a testament to the team's dedication.
This rewrite represents a bold experiment in using AI for large-scale code migration and refactoring. While there will undoubtedly be benefits and new issues to address, the lessons learned from this process will be invaluable for the entire software development community, pushing the boundaries of what's possible with current technologies.