Ladybird Browser Migrating to Rust with AI Assistance
The indie web browser project Ladybird is transitioning its codebase from Swift to Rust. The development team is reportedly using large language models (LLMs) to assist in translating C++ code as part of the migration, demonstrating a practical use of AI for large-scale, cross-language refactoring projects.
- The move to Rust follows a previously abandoned effort to adopt Swift, which was halted due to challenges with C++ interoperability and inadequate platform support outside the Apple ecosystem. - The project's founder, Andreas Kling, noted that the team had initially evaluated and rejected Rust in 2024 because its ownership model was not a natural fit for the object-oriented programming style common in web platform APIs. - The first major component to be ported is the LibJS JavaScript engine; the initial AI-assisted translation of its compiler and bytecode generator took approximately two weeks and produced around 25,000 lines of Rust code. - To ensure correctness, the translated Rust code was designed to be a direct-to-C++ mirror, intentionally preserving patterns like register allocation to produce identical bytecode, and it successfully passed over 65,000 tests without regressions. - Ladybird originated as the browser for SerenityOS, a Unix-like operating system built from scratch, and was spun out into an independent, cross-platform project in 2022. - The project operates as a non-profit and is funded by donations, with notable sponsors including GitHub co-founder Chris Wanstrath, Cloudflare, and Shopify, explicitly promising not to take revenue from search engine deals. - This migration to Rust is not a complete, immediate rewrite; core development will continue in C++, with Rust being incrementally adopted in various subsystems over an extended period. - Ladybird is one of the few web browsers building its entire engine from the ground up (LibWeb for rendering, LibJS for JavaScript), rather than using existing open-source engines like Blink (Chrome) or Gecko (Firefox).