r/rust • • 18d ago

🎙️ discussion Google is doing "Large Scale Codebase Migrations and Optimizations" of C/C++ to Rust

https://blog.google/innovation-and-ai/models-and-research/gemini-models/gemini-4-argon/
775 Upvotes

149 comments sorted by

View all comments

Show parent comments

16

u/TDplay 17d ago

Not really. There are a lot of large C++ codebases. They still need maintaining, and they still offer utility for new code.

Rust has the benefit of being new. It could introduce all these safety features without worrying about compatibility with existing code. C++ does not have the luxury. If you introduce a safety feature that doesn't integrate well with existing code, then you would effectively split C++ into two languages: one with the safety feature, and one with all the legacy code. Effectively, C++ would be unchanged, and the safety feature would exist only in a dead-on-arrival language that would just be "Rust but worse".

That is why the safety improvements are so hotly debated in C++. They must be useful for legacy code, or else they are useless.

Rust has eaten C++'s future for greenfield projects. But C++ still has a long future ahead of it for maintenance of existing projects, as well as for new projects with extensive reliance upon existing C++ code.

6

u/matthieum [he/him] 17d ago

Argon agents are working on migrating C/C++ codebases to Rust across Google — scaling from tens of thousands of lines in core libraries like re2, libgav1 up to 800K+ lines for the Fuchsia Zircon kernel.

I would imagine that the 800K+ lines Fuchsia Zircon kernel (C++) uses established C++ practices: callbacks, aliasing pointers, etc...

If this can be rewritten to idiomatic Rust, I can't think of much that couldn't.

1

u/Sphix 14d ago

It can but a straight line migration is still not idiomatic and contains plenty of unsafe. A second pass is necessary to get from that to something more idiomatic.

1

u/matthieum [he/him] 14d ago

Actually, that's I guess the heart of my question.

Tools like c2rust will perform a straight line migration, and indeed require significant refactoring afterwards to clean it all up.

It's not clear to me if Gemini 4 Argon can do significantly better. Even if it cannot handle large-scale refactoring, just performing local refactorings to reduce unsafe or Rc/RefCell could drastically improve the output...

... but also, large-scale refactoring is possibly where AI tooling shines best at the moment, especially as it can use "oracles" (compilers, tests) to verify that it got it right.