The components of the Ladybird browser are being rewritten in Rust with the help of AI

Andreas Kling, the founder of the Ladybird web browser, announced the decision to use the Rust programming language for the development of the project and the beginning of the rewrite of parts of Ladybird in this language. As an experiment, the LibJS JavaScript engine has already been rewritten from C++ to Rust. LibJS was chosen due to its good test coverage, which simplifies the assessment of porting quality.

To speed up the porting process, AI assistants Claude Code and OpenAI Codex were engaged, allowing the code to be rewritten in two weeks. The translation was carried out incrementally with the involvement of a developer, who sent several hundred prompts to the AI assistants during the process, determining the order of what to port and specifying requirements for the resulting code in Rust. After obtaining the code from different AI models, the results were reviewed and analyzed for errors and questionable decisions.

As a result, the rewritten Rust version of the engine successfully passed all 52,898 compatibility tests with ECMAScript from the test262 suite and 12,461 regression tests from the Ladybird project. The Rust version demonstrated a complete match of the generated AST and bytecode with the C++ version, and no regressions were identified. Additionally, there was no performance degradation observed in the JavaScript tests. Furthermore, the complete match was confirmed by comparative testing of website processing results using LibJS versions in C++ and Rust.

The rewrite of the browser components in Rust is considered a secondary project that may take a long time. Main development is still ongoing in C++. Decisions on which subsystems will be rewritten in Rust will be made by the main development team. The new Rust code will coexist with the existing C++ code through explicitly defined levels of interoperability.

Notably, in 2024, the developers of Ladybird decided to use the Swift programming language, but they encountered insufficient interoperability with C++ code and limited support for platforms other than Apple. As for Rust, this language has a more mature ecosystem for system programming and guarantees safety. Moreover, many developers at Ladybird are familiar with this language. In 2024, Rust was not approved for use in Ladybird due to the ownership-based development paradigm, which does not quite align with the object-oriented style of C++.

Andreas Kling once worked at Nokia and was involved in the development of KHTML, then at Apple, he was one of the developers of Safari. The Ladybird project was initially created as an application for the SerenityOS operating system, but in the summer of 2024, it was separated into its own project and received a donation of 1 million dollars. The browser is written in C++ and is distributed under the BSD license. The project develops its own engine, LibWeb, a JavaScript interpreter, LibJS, and related libraries.

Source: opennet.ru

Buy reliable website hosting with DDoS protection, VPS VDS servers 🔥 Buy reliable website hosting with DDoS protection, VPS VDS servers | ProHoster