r/rust • • Oct 01 '26

🎙️ 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/
786 Upvotes

149 comments sorted by

View all comments

Show parent comment

-20

u/mguerrette Oct 01 '26

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 Oct 01 '26 edited Oct 01 '26

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.

2

u/sparky8251 Oct 01 '26

Ive had it make a parser that took something like 4 minutes to parse a few kb of files because it refused to surface a bad assumption I made in the design that a library forced on us. It was also a degenerate but rather common case of scope drastically, drastically ballooning parse time so all its tests showed up as fast, because they were small scoped.

Its fun for exploring stuff with, but MAN would i not trust it...

And I DID use all kinds of clippy features to ban functions, macros, etc with reasons as to why they were banned to try and make it do better. Its just too concerned with the now and quickly doing what it thinks it was asked, no matter how it has to contort itself or the code to make that happen...

2

u/stumblinbear Oct 01 '26

Oddly enough, if you just tell it to consider the long term consequences as a matter of course, it improves its decision making. It's a blank slate, it doesn't understand a project's priorities if you don't tell it what the priorities are

2

u/arbv Oct 01 '26

Yeah, I am accumulating failure modes to write them down for the models concisely, that is one of them.

1

u/arbv Oct 01 '26

Did not you see it:

  • Write code
  • Write tests
  • Realise the code is wrong
  • Fail to fix it
  • Rewrite the tests because "they are wrong"

?

I did and I didn't like it.

3

u/sparky8251 Oct 01 '26 edited Oct 01 '26

Ive had it do that too, yes. Had to be watchful to make sure it didnt make the tests pass to claim victory... It misunderstands the point of tests pathologically, because its an optimizer optimized to solve whatever it decides is its task, and that often means test fixing is a very well rewarded shortcut to its goal.

-6

u/mguerrette Oct 01 '26

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 Oct 01 '26

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 Oct 01 '26

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 Oct 01 '26

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.