Jarred Sumner, the creator and lead developer of the Bun server-side JavaScript platform, acknowledged the successful experiment of rewriting the project from Zig and Rust using the AI assistant Claude Code, and decided to transition Bun to Rust. The rewritten version in Rust has already been accepted into the main project repository, while the Zig code is slated for removal. The Bun author also announced the hiring of employees to support Bun, who have over five years of experience in C/C++ and Rust development.
Currently, the Rust implementation is a direct port from Zig, which includes many blocks of unsafe code, retains the same architecture, the same data structures, and previous external libraries. It has been noted that the Rust port has successfully passed the existing test suite across all platforms. Along the way, several memory leaks and test failures have been resolved.
After building the Rust version, the executable file turned out to be 3-8 MB smaller than the Zig version. In performance tests, the Rust version was found to be either faster or on par. According to Jarred, the most significant advantage of the Rust version was the ability to detect and prevent memory errors, the diagnosis of which has cost Bun developers a lot of time in recent years.
The reasoning behind the rewrite in Rust previously cited the desire to eliminate issues in Bun caused by memory leaks, disagreements with the Zig authors regarding the use of AI for code writing, and Zig's unacceptable policy for large projects regarding acceptance of changes that break compatibility.
The JavaScript platform Bun is evolving as a high-performance alternative to Node.js and Deno platforms. The project is developed with an eye towards ensuring compatibility with server applications for Node.js and supports most of the Node.js API. The platform includes a set of tools for creating and running applications in JavaScript and TypeScript, as well as a runtime for executing JavaScript applications without a browser, a package manager (compatible with NPM), testing toolkit, a system for building self-contained packages, and a layer for embedding handlers written in C. In terms of performance, Bun significantly outperforms Deno and Node.js (in tests based on the React framework, Bun platform is twice as fast as Deno and almost 5 times faster than Node.js). The JavaScript engine JavaScriptCore and components from the WebKit project with additional patches are used for executing JavaScript.
Source: opennet.ru
