Bun's Experimental Rust Rewrite Reaches 99.8% Test Compatibility, Nears Production Readiness

code screen

99.8% and Counting: The Bun Rust Rewrite Milestone

On Tuesday, Bun creator Jarred Sumner posted on X (formerly Twitter) that the experimental Rust rewrite of the JavaScript runtime now hits 99.8% test compatibility on Linux x64 with glibc. The announcement, which garnered 622 points on Hacker News in under 24 hours, marks the most significant public progress report since the rewrite was first teased earlier this year. Bun, a popular all-in-one JavaScript runtime, bundler, and package manager, is being gradually ported from Zig to Rust to improve performance, memory safety, and ecosystem compatibility.

The 99.8% figure refers to the proportion of Bun's existing test suite that the Rust-based binary passes. The test suite covers core runtime behavior, npm compatibility, HTTP handling, and bundling logic. That leaves only 0.2% of tests still failing — a strong indicator that the Rust port has reached near feature parity with the original Zig version on the most common deployment platform. Sumner did not specify the total number of tests, but Bun's repository historically contains thousands of unit and integration tests.

For developers tracking Bun's development, this is a critical gauge of how close the Rust version is to replacing the Zig version as the default. The community has been eagerly awaiting benchmarks and stability data. While Sumner has not yet released performance numbers, the 99.8% threshold suggests the rewrite is in its final polish phase before potentially being merged into the main branch.

Why a Rust Rewrite?

Bun originally launched in 2022 as a Zig-based runtime, ambitious in scope but sometimes constrained by Zig's smaller ecosystem and tooling. Rust, on the other hand, offers a mature async I/O story (e.g., tokio), a vast crate ecosystem, and a strong memory safety model that appeals to infrastructure software. The decision to rewrite in Rust aligns Bun with other high-performance tools like Deno (which uses Rust for the engine via V8), Turbopack (Next.js bundler), and SWC (the Speedy Web Compiler).

By moving to Rust, Bun can potentially reduce memory overhead, improve parallelism for bundling, and make it easier to contribute —Rust's larger developer pool reduces onboarding friction compared to Zig. However, the rewrite is not trivial; Bun's internals include a custom JavaScript parser, a built-in SQLite client, native TLS, and a WebSocket library. Reimplementing all of those in Rust while maintaining the exact same behavior is a multi-month engineering effort.

code screen

The 99.8% compatibility on Linux glibc is especially important because that is the dominant platform for server-side JavaScript execution. Windows and macOS compatibility are likely to follow once the Linux baseline is stabilized. Bun already supports macOS and Windows, but the Rust rewrite may initially ship only for Linux, with platform-specific patches added later.

Implications for the JavaScript Ecosystem

If Bun's Rust rewrite reaches production quality, it could accelerate the ongoing trend of JavaScript runtimes leveraging systems languages for performance-critical paths. Node.js itself is written in C++ and JavaScript; Deno uses Rust for its core (but TypeScript/JavaScript for other parts); Bun started with Zig and now shifts to Rust. The common thread is that native language components are essential for delivering sub-millisecond startup and low memory footprints.

For developers using Bun today, the Rust version promises faster cold starts, better concurrency during bundling, and potentially smaller binary sizes. Early tests in the community have shown that Rust-based tools like SWC can be significantly faster than their Zig or C++ counterparts for parsing and transformation. If Bun's Rust port achieves similar gains, it could make Bun the fastest runtime for serverless functions, edge compute, and local development tooling.

Moreover, the Rust rewrite could help Bun attract contributors from the large Rust community. Bun's Zig codebase, while well-crafted, had a smaller pool of potential maintainers. Rust's popularity in the systems programming world —especially among developers building databases, networking services, and WebAssembly tools— could accelerate feature development and bug fixing. Several Hacker News commenters noted that they would consider contributing to Bun now that it's Rust.

The 99.8% number also reassures users that the rewrite does not break existing workflows. Bun's test suite includes real-world npm packages, so passing it means that most common libraries and patterns will work out of the box. The remaining 0.2% likely represent edge cases around garbage collection, type coercion, or specific platform APIs that differ between Zig and Rust. Sumner has not disclosed which tests fail, but he previously mentioned that the main challenges involve accurately emulating Unix signals and handling asynchronous I/O exactly as the Zig version does.

Technical Details and Challenges Uncovered

code screen

From our analysis of public discussions and Bun's release notes, the Rust rewrite is not a line-by-line port but a rearchitecting of Bun's core event loop and memory manager. The Zig version relied on a custom allocator and async runtime; the Rust version leverages tokio for async I/O and the standard Rust allocator (jemalloc or mimalloc). Adapting Bun's bundler, which uses a recursive descent parser written in Zig, to a Rust-based parser (likely based on oxc or an internal port) required significant effort.

The fact that only 0.2% of tests fail suggests the architectural changes are stable. However, cross-platform testing remains limited to Linux x64 glibc. Bun users on musl-based Linux (e.g., Alpine Docker images), macOS, or Windows will have to wait for separate announcements. The 99.8% number also applies only to the test suite measuring functional correctness; performance benchmarks have not been published yet. It is possible that the Rust version is currently slower in some areas due to missing optimizations, which would explain why Sumner has not shared benchmarks.

Another technical challenge is bundling logic: Bun's bundler supports TypeScript, JSX, CSS, and asset modules, and must replicate Node.js module resolution exactly. Rust's stronger type system may have actually caught inconsistencies in the original Zig code. Sumner hinted at this in a previous blog post, stating that the rewrite uncovered several non-obvious bugs in the Zig implementation. The fact that those bugs were found and fixed is a net positive for the project's reliability.

Forward-Looking Analysis: What to Watch Next

The 99.8% milestone sets the stage for several important developments in the coming weeks. First, expect a blog post from Sumner detailing the performance characteristics of the Rust port, possibly with side-by-side comparisons to the Zig version. If the Rust version is even 10-20% faster on cold starts or bundling, that will be a strong incentive for existing Bun users to switch to the Rust branch.

Second, the Bun team will need to address the remaining 0.2% test failures. These may include edge cases in Node.js compatibility (e.g., the 'fs.watchFile' API, which behaves differently across platforms) or bugs in the new Rust ecosystem code. Third, we anticipate a beta release of the Rust-based Bun for Linux within the next month or two, followed by phased support for other platforms.

The larger question is whether the Rust rewrite will give Bun an edge in the runtime wars against Node.js and Deno. Node.js benefits from years of optimization and the OpenJS Foundation's stewardship. Deno has matured and now offers significant performance via its Rust core. Bun's advantage has always been its all-in-one design (runtime, bundler, package manager) and speed. If the Rust port can maintain or improve that speed while reducing resource usage, it could become the preferred choice for serverless and edge deployments.

For the tech community, Bun's journey is a case study in when to rewrite a successful tool in a different systems language. It demonstrates that even with a working codebase, strategic rewrites can pay off if they unlock a larger contributor base and better performance. The 99.8% milestone is not just a number—it's a signal that the JavaScript ecosystem's infrastructure continues to evolve, and Bun is positioning itself for the next wave of development.

Source: Hacker News
345tool Editorial Team
345tool Editorial Team

We are a team of AI technology enthusiasts and researchers dedicated to discovering, testing, and reviewing the latest AI tools to help users find the right solutions for their needs.

我们是一支由 AI 技术爱好者和研究人员组成的团队,致力于发现、测试和评测最新的 AI 工具,帮助用户找到最适合自己的解决方案。

Comments

Loading comments...