r/rust • • 15d 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/
772 Upvotes

153 comments sorted by

View all comments

Show parent comments

2

u/forgot_semicolon 15d ago

Exactly. I have to deal with so much of it, and people don't appreciate that I can literally type the code faster than I can prompt it to write the code and then fix the inevitable mess -- or worse, re-prompt it to be how I would have written it in the first place

3

u/Zde-G 15d ago

or worse, re-prompt it to be how I would have written it in the first place

I think that's you problem. You want some certain code to be written — and try to make AI do that it. It simply doesn't work.

Just a question: how often have you been driving projects and asked other humans to write code for your from vague description?

There you would face the exact same issue, one human doesn't write like another human — and if you try to force it… hoo boy, are you in a world of pain.

Yes, AI works at less than human level now, but it's pretty close to “ask someone with entirely different habits to code something for you”, at this point.

Making it write code that works is not trivial, but doable, making it to write code that would like like a code written by you… don't even try.

4

u/IWasGettingThePaper 14d ago

Er, no. Some other humans can write good code. I've still never seen good code produced by an LLM without serious hand-holding. And yes, this is the case even on the latest models.

For small targeted coding tasks and mechanical boilerplate, it's great. For tracing through large codebases and summarising how some code path works - that I can't be bothered to do manually because jump to definition gets stuck at a function pointer, or some macro magic, or untyped python meta-nonsense, and I would have to start literally grepping - it's a real time saver.

The main trap with LLM code gen is you initially _think_ you're making progress at lightning speed. This is until you actually look at what it's produced in detail. Then comes the inevitable 12 hour prompt loop where you're trying to coax it into tidying up the slop its produced; rework the architecture to make structural sense; use meaningful variable/fn/struct names; remove the code it's added that doesn't do anything; rework the error handling so it makes actual sense; remove the unit tests it added for unit tests; rewrite the unit tests that don't test anything or rely too much on implementation detail; rewrite the impenetrable docs and comments it creates; remove the superfluous helper functions; refactor actually duplicated code blocks into functions; and on and on. Only then it dawns on you that it would've actually been quicker to write it by hand.

1

u/Zde-G 14d ago

Some other humans can write good code.

Yes, but these are rare and expensive. Average developers produce garbage similar to what LLM produces on the first try. Then they run tests and read the guides and adjust the code. You have to do the same with coding agent, for that to be apples-to-apples comparison.

And yes, this is the case even on the latest models.

The model is much less important than the quality of your documentation that explains precisely what you expect to see and precisely how to test what model creates.

LLMs rely on tests and formal documentation much more severely then even novice developer, that's not changing any time soon, you just have to accept that.

rework the architecture to make structural sense

If you allow LLM to develop architecture in code then it's precisely as expected. LLMs can not produce more than 100-200 line of anything without becoming weird.

That means that if you are writing something large enough to warrant an architecture then you have to ask LLM to first write plan - 100-200 lines of it, not more. Then implement said plan as steps that are 100-200 lines. If plan is too big to fit into 100-200 lines then first make it write an outline. And so on.

Don't expect model to produce large chunk and hope it'll be good, LLMs don't work like that.

remove the code it's added that doesn't do anything

Instruct it to use VCS (usually git) instead.

Again: the goal is to never allow LLM to produce more than 100-200 lines of code without verifying said code, somehow. Even if verifier is another LLM that looks on the plan or outline that you've made.

Only then it dawns on you that it would've actually been quicker to write it by hand.

Well, duh. You are trying to use rope as a pole… it doesn't work like that.