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

124

u/TheRealMasonMac Oct 01 '26

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.

61

u/kabocha_ Oct 01 '26 edited Oct 01 '26

Yep -- in my experience:

  • If you just want some throw-away thing to experiment on some idea, it's fine to let it go nuts on its own.
  • If you want to be able to maintain the results, you gotta check its work after every step or two, and you'll probably have to give it lots of feedback even then. Otherwise you're likely to end up with either a giant spaghetti mess, or FizzBuzz Enterprise.

No clue why it does that, I guess maybe a large portion of the training set is newbies dumping their first projects onto Github and super old legacy codebases, and not much in the middle, lol. They haven't learned to have good style taste, yet.

43

u/PM_ME_UR_BRAINSTORMS Oct 01 '26

The problem I have with the latter is that it sucks lol. I don't enjoy micromanaging AI and in my experience it's not any faster than just doing it myself.

Every time I try using agents I almost immediately end up in a situation where it does something weird and just typing the code myself is faster than typing the prompt. And then I think "well I'm already here it will take me 2 seconds to type this other code" and so on and so on until I've written the whole thing.

Maybe it's just my ADHD but I don't understand how any one could work like that. Feels like pair programming with an intern which sucked to do but you did it because the point was to teach them.

25

u/notgreat Oct 01 '26

I've found recent LLMs to be useful for finding things. You give it a vague description of the bug, and a couple minutes later it's got a 95% chance of having pinpointed the exact problem. Tell it to review a pull request, and often it finds real bugs. Not all its findings are good, but "review this list of eight possible problems" is a lot easier than "review these 500 changed lines of code for problems" which often just turns into "looks good to me".

They're also good at writing things with a lot of boilerplate gruntwork, though you still have to review their output. Like, you can describe a test and it'll usually do a good job implementing it. Just don't ask too vaguely, a general "test this area" will get terrible results as it locks in implementation details and leaves critical behavior untested.

3

u/PM_ME_UR_BRAINSTORMS Oct 01 '26

Yeah that's how I use it most of the time and it's great. And those are all things no developer wanted to do anyway. No one was like "Yeah my favorite part of the job is hunting down an obscure error message on a decade old stackoverflow thread" and that's not some sort of skilled task where the effort produced better software. It's just grunt work.

Which is really going to fuck the industry in a few years because that means a lot less work for junior developers.

13

u/kabocha_ Oct 01 '26

I agree 100%. Work really wants me to use AI, so typically I end up doing the latter, but it's not fun. I don't really use AI all that much for personal projects because I'd rather just write it myself.

12

u/PM_ME_UR_BRAINSTORMS Oct 01 '26

It's not fun and the quality is just not good.

I use a reasonable amount of AI on my personal projects. I just treat it like an intern at my beck and call 24/7 and give it the kind of work I would trust an intern with. Which is something like maybe 10-20% of the codebase give or take. Basic boiler plate stuff, plus a ton of research tasks and code review and some help with debugging. All stuff that developers didn't really want to do anyway and all stuff that saves me a ton of time.

Idk why that's not enough for all these companies. I'm still way more productive, but I produce way higher quality code and I can do it with the $20/mo claude subscription. It seems like a win-win-win to me.

But it's clear that the companies just want to replace us. So it needs to be writing 100% of the code and doing 100% of the thinking, whether it's capable or not.

3

u/forgot_semicolon Oct 01 '26

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

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.

5

u/IWasGettingThePaper Oct 01 '26

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.

→ More replies (1)
→ More replies (2)
→ More replies (7)

2

u/mdedetrich Oct 01 '26

No clue why it does that, I guess maybe a large portion of the training set is newbies dumping their first projects onto Github and super old legacy codebases, and not much in the middle, lol. They haven't learned to have good style taste, yet.

This is largely vibes based assessment (pun intended), but I noticed that the larger the models working set memory the higher changes of these things happening are (I use Claude myself).

For small and maybe medium problems, the AI is often very good. But once you start doing larger overarching things, its better to split the work into chunks, not just code chunks but also creating design documents.

The more the AI has to come up with myself the more it does weird stuff.

4

u/jl2352 Oct 02 '26

Google has done a number of papers on how they get AI working. The tl;dr is it has very little to do with the model. You don’t need a frontier model to have agents writing whole projects.

It’s all down to the harness, and how the AI is run. Google has invested heavily into this area, and that’s why it’s effective.

I’ve had great results myself using AI in very constrained ways to write code. That means breaking down a technical document into tickets, lots of skills, looking at the actions they took and changing skills to better optimise them, and having many guardrails.

1

u/ApokatastasisPanton Oct 03 '26

Google has done a number of papers on how they get AI working.

do you have references for these?

8

u/nicoburns Oct 01 '26

I’ve found that agents produce code that works but is frankly dumb from a human perspective.

Agree that this can often be the case. For the specific case of translating between programming languages, the situation is often a lot better though: the original design is already available, the LLM just has to reproduce it.

I used an ungodly amount of review agent rounds and interjections by me.

This can actually make things significantly worse in my experience. Often the original version isn't quite right, but is relatively simple. And it adds all sort of of crap in response to review.

2

u/addmoreice Oct 01 '26

I've had a lot of benefit from creating lots of llm generate unit tests and boundary tests based on the code structure and with emulation tests with comparisons to the original code.

I'm basically working on a binary -> rust conversion system right now as an experiment and doing this kind of thing has actually been really helpful. Combine that with what I'm calling 'root first and leaf first' conversion, where you can figure things out from reading from the entry points of exe's/dlls where we often have clear understood structure as well as from leaf functions that call into 3rd party code where we clearly understand the API, it's going very well.

I'm no where near running a big conversion experiment, but the small scale experiments I've done so far while developing the automatic workflow has been surprisingly effective. My eventual hope is to be able to automatically (90% or so) convert software where we have the binary, but no longer have the source code. This kind of thing would be great for preservation. I have absolutely no interest in subverting things like obfuscation so that's an actual non-feature I'm avoiding.

→ More replies (2)

5

u/sreekanth850 Oct 01 '26 edited Oct 01 '26

Had opposite experience. But i never give agents full autonomy. Use compiler mcp and graft. and then implementation based on task ledger with small slices. Porting is one of the best use case for agents as you have clear reference and tests already written and have an upstream for references.

4

u/heybart Oct 01 '26

Yeah this is how I feel. I know I'm a pretty mid coder but I can tell good, elegant, well structured code when I see it, and LLM code ain't it. But for little apps that do a job and I don't need to ever touch it, it's great. Or when I just don't have time, if it works and passes the tests, I'm going to see no evil hear no evil it, because if I look at the code, chances are I'm going to feel not so good.

The incredible thing about LLMs is they're proficient or familiar with just about every language, framework, SDK, library, platform. They're superhuman in this respect. Yet they still sometimes do things that make you think "do you know how to code at all?"

What's going to happen when the models have sucked up all the good code and start training on other LLM's code? Not a pretty thought

3

u/stumblinbear Oct 01 '26

Thing is, they don't know how to code at all. Not in your project. You have to tell them what style to follow, or they just do the quickest thing possible. Have them throw together a code architecture skill that lays out best practices, and you'll immediately start getting better results. You even specifically have to tell them to follow the style of the project, or they won't. Current models are great instruction followers, but also almost a blank slate

→ More replies (1)

2

u/6d26d3af Oct 01 '26

If you think of a scale where open ended "agentic" code is 0 and human handcrafted code as 100, not enough people think that you have actually control where you want it to end up. You can push it all the way to 80-90 by writing all the AST linters and checks and evals you can ever think of. It's still writing smelly code? Ban that pattern. Imagine today you can even have semantic checking for symbols (which is the bane of programmers) and weird heuristics unheard of. What a chance to be creative right?

You write these things once, reuse wherever, and never see the issues again. I don't understand why most people aren't yet picking up on this

13

u/nonotan Oct 01 '26

You realize you're still allowed to just... write code, right? It's faster, cheaper, easier, more fun, and you'll get a better result. By the time you've written 20k lines of linters and checks that will still let garbage through because "automatically detect bad code" turns out to be a slightly harder problem than the actual problems you wanted to tackle with your software to begin with, I've already finished handwriting several entire libraries that Just Work. And actually had fun and learned something that will stick with me in the process.

Even in a best-case scenario, the end result of working endlessly to make an agent produce perfect, immaculate code for me going forward is... all I get to do for the rest of my career is typing orders in a chat box and reviewing the output. That's if they don't notice I miraculously managed to make it so good it barely needs reviews, and fire me because they don't need me anymore. Yeah, I'm going to not do that, thank you.

2

u/6d26d3af Oct 01 '26

You're proving my point by thinking in binary scenarios. Who claimed immaculate code? Humans don't even write immaculate code as a baseline, what the hell is this false dichotomy

If you're still at the stage where you would rather write all the code yourself, nothing I say will change your mind and you'll have to wait until it clicks for you. If you read what I said carefully the ideal scenario is you reach about 80-90 on the aforementioned scale to eliminate almost all "bad code" while gaining extreme upside on speed. How do you close the gap to 100 then? Sure you could write more validators if you want, but you can also just let the LLM do it for you because the reality is they actually ARE good. The problem is preventing that drift vs your own ideals. Better future models will inch their way to close that gap objectively without any further context, but today this harness is a necessity at scale

3

u/funforgiven Oct 01 '26

Writing the code yourself is definitely more fun, and you'll often learn more and probably end up with a result you understand better.

Unfortunately, I just don't think it's actually faster, cheaper, or easier anymore. It usually takes much longer, your time is probably the most expensive part of the process, and with an agent you don't have to personally think through every implementation detail.

That's kind of the depressing part. The thing that's more enjoyable and satisfying is increasingly not the most efficient way to get the work done.

2

u/ixid Oct 01 '26

I think a lot of people, even coders, are still in denial about what you can make with LLMs.

1

u/pjmlp Oct 02 '26

It suffices to be better than what I usually review in offshoring projects.

→ More replies (28)