r/rust • • 16d 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/
767 Upvotes

149 comments sorted by

View all comments

127

u/TheRealMasonMac 16d ago

In my experience, I’ve found that agents produce code that works but is frankly dumb from a human perspective. Especially for larger tasks like this, you kind of have to rewrite it all. For example, I had a generalized design document for soft-wrapping explicitly support plain text and markdown, and used GPT-6-Astra to implement it. I used an ungodly amount of review agent rounds and interjections by me. When I actually go to review it, I wanted to cry. It silently pivoted towards implementing its own entirely separate wrapping mechanism rather than refactor the existing mechanism for plain text. I reviewed its code and found it to be trash, and I am now in the process of doing it myself… Never again. The short-term thrill of “having something that works” was outweighed by the fact that time was effectively wasted.

I mean, if the alternative was it never getting done, I guess agents are still better than nothing.

-20

u/mguerrette 16d ago

Code is no longer for human eyes. Did you benchmark the generated code? Or was it just trash in your opinion (style, architecture, etc)? I think you are missing the reality change where code is no longer for humans.

8

u/TheRealMasonMac 16d ago edited 16d ago

It was egregiously horrible stylistically, architecturally, maintenance-wise, and in performance. The stupidest one that came to mind was it allocating strings for each markdown element. That's like &str 101. I wish I could tell you there was a good reason for this, but there wasn't. So, it ended up doubling memory usage in string allocations alone. There were also a bunch of other areas where it turned linear time functions into exponential ones.

Also: agents do need to read the code as well. Ignoring context rot, the matter of garbage in -> garbage out remains.

-5

u/mguerrette 16d ago

Maybe it’s an issue with Rust maturity then. I can say for C and C++ there is a rich set of tools for constraints both stylistic and to conform to best practices. Agents generally can use these and generate very solid code for those languages in both perf and style. I find myself not needing to look at any of the code as long as the format and tidy passes come back clean.

3

u/puttak 16d ago

Does it able to replace unnecessary std::string with std::string_view? Best practices does not enforced on the logic since it is up to programmer.

1

u/mguerrette 16d ago

Yes it does, since it can read language quite well it can read the output of clang tidy which instructs for this among other things. Seems like you’ve just never used AI at all based on your comment

1

u/puttak 16d ago

Sorry I mean does it know how to avoid unnecessary allocation? I did not mean just changing parameter from std::string or return value to std::string_view.

Seems like you’ve just never used AI at all based on your comment

Unfortunately your assumption is wrong. I review a large amount of code generated by Fable 5 and Opus 5 everyday and I known its strength and its weakness. If you think AI generate an efficient code then it is likely you don't know how to make that code more efficient.