Ladybird browser integrates Rust with AI help

The independent browser project Ladybird has ported its JavaScript engine LibJS from C++ to Rust. AI tools significantly accelerated the translation.

listen Print view
Globe with network connections, yellow background

(Image: heise medien)

3 min. read
Contents

The free browser project Ladybird has taken an important step towards memory safety: the developers have ported central components of their JavaScript engine LibJS from C++ to Rust. The port comprises around 25,000 lines of code and was implemented within two weeks with the support of AI tools.

Specifically, the lexer, parser, abstract syntax tree (AST), and bytecode generator of LibJS were translated. These components were particularly well-suited for the initial port, according to lead developer Andreas Kling, as they operate relatively independently and can be extensively tested using the test262 suite. All 52,898 tests from the test262 suite, as well as 12,461 Ladybird-specific regression tests, passed without issues – the Rust and C++ implementations produce byte-identical output.

Kling relied on the AI models Claude Code and Codex for the translation, but emphasizes that it was a human-directed effort. He guided the process through hundreds of small prompts and decided himself which parts should be ported in what order. After the initial translation, he performed several “adversarial” reviews, where different AI models checked the code for errors and bad patterns. What would have taken several months manually was completed in two weeks.

Videos by heise

The resulting Rust code deliberately carries the style “translated from C++”, meaning it is not idiomatic Rust. This decision was made in favor of compatibility with the C++ pipeline. The project intends to convert the code to idiomatic Rust only when the C++ implementation is completely replaced.

The decision for Rust is remarkable, as Ladybird had rejected the language in 2024. At the time, the developers argued that Rust's ownership model did not fit well with the object-oriented style of the web platform, with its deep inheritance hierarchies and garbage collection. Swift was evaluated as an alternative but failed due to insufficient C++ interoperability and limited platform support outside the Apple ecosystem.

After a year of stagnation, Kling has now pragmatically opted for Rust. He cites the more mature ecosystem for systems programming, the widespread Rust knowledge within the contributor community, and the fact that Firefox and Chromium are already integrating Rust. Most importantly, however, Rust offers memory safety guarantees that C++ lacks – a critical factor for browser engines, which are frequent targets of attacks.

Ladybird does not plan a complete exit from C++. According to Kling, the language remains the project's main development language. The Rust port is a “sidetrack that runs long.” New Rust code coexists with existing C++ through defined interop boundaries. The core team consciously controls which components are ported and when.

Ladybird is developing a completely independent browser engine as an alternative to the established engines Gecko (Firefox), Blink (Chromium), and WebKit (Safari). The open-source project is still in its early stages, with a first alpha version for Linux and macOS scheduled for release in 2026.

(fo)

Don't miss any news – follow us on Facebook, LinkedIn or Mastodon.

This article was originally published in German. It was translated with technical assistance and editorially reviewed before publication.