Bun, the high-performance JavaScript runtime originally written in Zig, has been ported to Rust in a six-day code sprint. The rewrite passes 99.8% of Bun's pre-existing test suite on Linux x64 glibc, according to the project's lead developer. The port covers approximately 960,000 lines of code.
What changed
The Rust port maintains the same core codebase structure as the Zig version. The key difference is that Rust's ownership model and borrow checker now enforce lifetimes of types at compile time, and the language provides destructors when needed. Code sections that cannot be proven safe by the compiler are marked unsafe, which the developer says "encourages refactoring" of those parts.
Motivation
The stated reason for the port is to reduce time spent fixing memory leaks, crashes, and stability issues. The developer wrote: "I am so tired of worrying about & 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."
Build performance
When using Bun's own faster Zig compiler, the Rust port compiles at the same speed as the original Zig build. If built with the upstream Zig compiler, the Rust version compiles faster.
What's next
The developer has announced a forthcoming blog post covering benchmarks, memory usage, maintainability going forward, and the literal process of doing the port — noting it was not simply a matter of asking an AI to "rewrite bun in rust. make no mistakes." The port currently works on Linux and will be extended to other platforms.
Bottom line
A 960,000-line runtime rewrite completed in six days and passing nearly all existing tests is unusual. The port trades Zig's manual memory management for Rust's compile-time safety guarantees, which the developer expects to reduce long-term maintenance burden from memory-related bugs.