Jarred Sumner, a creator and lead developer of the JavaScript server platform Bun, has acknowledged a successful experiment in 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 repository, while the Zig code is scheduled for removal. Additionally, the author of Bun announced the hiring of staff with over 5 years of experience in C/C++ and Rust to support Bun.
Currently, a direct port from Zig to Rust has been implemented, which includes numerous blocks of unsafe code, uses the same architecture, the same data structures, and the previous external libraries. Notably, the Rust port has successfully passed the existing test suite on all platforms. Several memory leaks and test failures have been addressed along the way.
After building the version in Rust, the executable file turned out to be 3-8 MB smaller than when building the version in Zig. In performance tests, the Rust version was either faster or on par with the Zig version. According to Jarred, the most significant advantage of the Rust variant is the ability to catch and prevent memory errors, the diagnosis of which has consumed a lot of developers' time in recent years.
The reasons for rewriting in Rust previously included a desire to address issues in Bun caused by memory leaks, disagreements with Zig authors regarding the use of AI for coding, and Zig's unacceptable policy regarding changes that break compatibility for large projects.
A Bun JavaScript platformként a Node.js és a Deno platformok nagy teljesítményű alternatívájaként fejlődik. A projekt a Node.js szerveralkalmazások kompatibilitásának biztosítására figyelemmel készült, és támogatja a Node.js API-jának nagy részét. A platform tartalmaz egy eszközkészletet JavaScript és TypeScript nyelven történő alkalmazások létrehozására és végrehajtására, valamint egy runtime-ot JavaScript alkalmazások böngésző nélküli futtatására, egy NPM-kompatibilis csomagkezelőt, tesztelési eszközöket, önálló csomagok összeállítási rendszerét és egy interfészt, amely lehetővé teszi C nyelven írt kezelők beépítését. Teljesítmény szempontjából a Bun jelentősen megelőzi a Denót és a Node.js-t (a React keretrendszeren alapuló tesztek alapján a Bun platform kétszer olyan gyors, mint a Deno és közel ötször olyan gyors, mint a Node.js). A JavaScript végrehajtásához a JavaScriptCore JavaScript motor és a WebKit projekt komponensei, kiegészítő javításokkal kerülnek felhasználásra.
Forrás: opennet.ru
