Ladybird adopts Rust, with help from AI
TL;DR Highlight
Ladybird ported 25,000 lines of LibJS to Rust in two weeks using Claude Code and Codex.
Who Should Read
A backend developer who wants to use coding agents to port legacy code to another language
Core Mechanics
- Rust replaces C++
- Swift's C++ interop fell short and its platform support outside Apple was limited.
- Rust has a far more mature systems ecosystem and many contributors already know it.
- Ladybird will rewrite parts of the engine in Rust.
- First target: LibJS parser and bytecode
- They started with the lexer, parser, AST, and bytecode generator.
- These are self-contained and well covered by test262.
- Hundreds of small human-directed prompts
- The translation used Claude Code and Codex.
- The human decided what to port, in what order, and how the Rust should look.
- After translating, they ran multiple adversarial review passes with different models.
- Byte-for-byte identical output was required
- Every AST from the Rust parser matches the C++ one.
- All Rust bytecode matches the C++ compiler's output.
- About 25,000 lines of Rust took two weeks, versus multiple months by hand.
- Zero regressions
- There were no regressions across test262 (52,898 tests) or Ladybird regression tests (12,461 tests).
- No performance regressions on tracked JS benchmarks.
- They also browsed the web in lockstep mode running both pipelines at once.
- The code deliberately looks translated from C++
- The first priority is compatibility with the C++ pipeline.
- It even mimics C++ register allocation patterns to produce identical bytecode.
- Idiomatic cleanup is planned once the C++ pipeline can be retired.
Community Reactions
- Commenters called the side-by-side diff of old and new pipelines the smartest part
- They noted that improving things during a port makes bugs hard to trace.
- Another said translated-style Rust is fine as a start because the compiler still catches memory bugs.
- Commenters said assistants port languages well when tests exist
- One said AI changed the math on rewrites and that testing is now 10x as important.
- One commenter doubted adversarial review by models
- They said it finds obvious patterns and security mistakes but not deep logic errors.
- Some questioned the benefit of a partial port
- One argued that porting only the JS parser while keeping C++ heavily won't make it much more secure.
- Another asked whether translated-style Rust still gets most of the memory-safety benefits.
How to Apply
- Check test coverage of your port candidate today
- Run the module's existing tests and record the pass rate.
- Pick a self-contained module with clear inputs and outputs first.
- Build a diff harness for old vs new
- Feed the same input to both implementations and compare output byte for byte.
- Don't improve anything during the port and match the behavior exactly.
- Split the agent's work into small prompts
- You decide the order and the shape of the code.
- Translate one function or file at a time and verify with the diff.
- Run adversarial review with a different model
- Ask a model other than the translator to find mistakes and bad patterns.
- Confirm the findings with tests and diffs.
Try It
# Paste into Claude Code or ChatGPT (prompt adapted from the article's method)
Translate the {{source language}} code below into {{target language}}.
Rules:
- The goal is output byte-for-byte identical to the original. Do not improve or refactor.
- Follow the original algorithms, data structures, and processing order exactly.
- It doesn't need to be idiomatic. Compatibility comes first and correctness second.
- After translating, list the places where behavior might differ from the original.
{{source code}}
# Then paste into a different model (adversarial review)
Compare the original and the translation below and find translation mistakes, behavior differences, and bad patterns.
Original:
{{source code}}
Translation:
{{translated code}}Terminology
Related Papers
Frostbite: A new CPU architecture discovered, designed and verified by AI
AI agents designed a CPU from scratch, claiming 4.59x perf/W over a traditional core
Restricting AI agents in mobile operating systems platforms from capturing data
Signal now blocks OS-level AI agents from reading its screen on iOS 27 and Android
Actions Speak Louder than Words: Stateful Privacy Sniffing of LLM Agents via Behavioral Covert Channels in Web Interactions
Agents' link choices alone let attackers rebuild user queries at F1 0.89; SOR cuts it to 0.39.
Tracking and Limiting Unsupported Claim Propagation in Multi-Agent LLM Systems: A Provenance-Aware Framework
Passing claims with source, evidence and history kept equivalence at 5 agent stages at 96% versus 31%.
LLM assisted reverse engineering
Pointing an agent at binaries with skills and MD notes made years-long hacks feasible
Metrics-in-the-Loop: Complexity Feedback Reshapes Agent-Written Code
Injecting per-turn complexity reports into coding agents cut code erosion without changing correctness
Why is Gemini 4 Carbon taking so long?
Carbon took nearly an hour on bug fixes that Astra and Opus finished in minutes, mostly from extra unrequested work.
Weight-Space Programming builds neural networks like a 1990s researcher
LLM hand-wrote MNIST weights to 91.3%, using 1990s-style techniques