Buz: A Modern Zig Fork of Bun

Buz: A Modern Zig Fork of Bun

Buz is a work-in-progress fork of Bun designed to be a drop-in replacement that prioritizes code quality and developer experience. Based on the last commit of Bun before its Rust rewrite, Buz aims to modernize the codebase using current upstream Zig, reducing technical debt and implementing sub-1s incremental builds.

Sub-1s Incremental Builds

Buz achieves sub-1s incremental builds by moving the entire build graph into build.zig, including the vendored sources of JavaScriptCore. This significantly improves the developer loop compared to the original Bun codebase.

While some platform limitations exist—such as Zig incremental compilation not yet supporting aarch64 and binary patching being limited to the Linux linker—the project demonstrates that fast build times are possible for a runtime of this scale.

Codebase Modernization and "Deslopping"

The primary goal of the Buz project is to create a "saner codebase" by removing technical debt and "slop" (low-quality or AI-generated code). The project lead has already removed over 11,000 lines of dead code and is rewriting parts of the codebase to rely more heavily on the Zig standard library.

To manage the magnitude of this cleanup, the project is employing a specific development strategy:

  • AI-Driven Refactoring: LLMs will be used extensively to untangle the existing 600K lines of code.
  • No Human Contributions: The author has explicitly stated they will not accept human-coded contributions until the codebase reaches a state of sanity and idiomatic Zig patterns are established.
  • Test-Driven Alignment: All new tests from the Rust version of Bun have been imported to ensure feature parity and bug fixes are maintained as the project evolves.

Architecture and Dependencies

Buz continues to rely on the core C/C++ dependencies that power Bun's performance, such as JavaScriptCore (JSC), uWebSockets, brotli, and tinycc. The project lead acknowledges that while Bun contains significant "glue" code, a large portion of the project—including the package manager (approximately 40K lines) and the implementations of Node and Web APIs—is written in Zig.

Regarding compatibility, Buz follows Bun's strategy of using partial V8 API shims to maintain compatibility with popular packages, rather than implementing a full V8-compatible API for JavaScriptCore.

Community Perspectives

Discussion among developers has sparked a debate on the value of such a fork. Some view the project as a Herculean task of code stewardship, while others question the utility of "performative performance programming" when build times are not the primary bottleneck for users.

"To me the most interesting fact about this fork is that it has proven that Bun could have had fast builds all along."

Other critics argue that maintaining a JavaScript runtime is a massive undertaking that may struggle to find a long-term ecosystem without the official Bun team's resources. Some also pointed out the irony of using LLMs to "deslop" code that was allegedly ruined by LLMs in the first place.

Sources