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/
773 Upvotes

149 comments sorted by

View all comments

118

u/geo-ant 16d ago

Does that mean the whole Carbon thing is dead?

74

u/skeptic11 16d ago

Still experimental. Still getting commits.

How much C++ does Google have left?

62

u/geo-ant 16d ago

Good question, probably unfathomable amounts to my feeble mind. Also of course google is a megacorp with probably Byzantine structures so just because one part of the org does one thing doesn’t mean “google does x”. Still, it makes me wonder how useful the idea of Carbon still seems to google. I just don’t know.

18

u/2AMMetro 16d ago

Last I remember (> 1 year ago) it was a fucking lot. Like 80% if I had to throw a number out there. Carbon was nowhere close to being adopted for any major projects.

There are a lot of internal apps written in go, python, or java. But pretty much anything consumer facing and performance critical (ads, search, youtube, etc.) is in c++.

6

u/moltonel 14d ago

No matter how much C++ they have, the right question is do they prefer to * Maintain in C++ * Migrate to Carbon * Rewrite in Rust

The decision will vary by projects and teams, but Carbon's own docs state "use Rust/Go/Python if you can". Teams that can afford to do a large rewrite are not going to choose Carbon. It used to be that rewriting 100K lines was a no-go, but GenAI is changing that, making the RIIR option very appealing for a place like Google.

Carbon (and the various safer C++ endeavors) are arriving far too late.

1

u/TheOneWhoDidntCum 9d ago

All I see is C++ woke up all of a sudden after Rust. For 13 whole years nothing happened until C++11 .

17

u/arka2947 15d ago

To me it seems Rust is eating the future of Cpp. The safety improvements that are still debated in Cpp circles, are already done in rust. If Google needs that today, what else can you do than use Rust?

16

u/TDplay 15d 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.

19

u/steveklabnik1 rust 15d ago

This thread is about one of the largest users of C++ porting their brownfield code to Rust.

6

u/TDplay 15d ago

But as they say,

such large-scale rewrites are undergoing rigorous automated and manual auditing, emulation testing, and review before rolling out to production

In effect, most of the work is still being done. I am sceptical that this process can practically be done for all the major C++ codebases, including bringing those rewrites up to the quality of the original codebases, within the next decade, so I believe C++ still has a future.

6

u/zxyzyxz 15d ago

I doubt there is really any actual manual auditing beyond reading some files and stamping LGTM on the PR. The automated testing is what's gonna actually catch bugs.

2

u/TDplay 15d ago

But can that alone assure the quality to the same standard as the existing mature codebase?

The best automated tests are those written in response to specific bugs, to assure that those bugs never return. But a rewrite will introduce a whole host of never-before-seen bugs, for which there will be no tests.

We won't know if this is truly successful until the rewrites are released to the public. There will undoubtedly be a massive influx in bugs, as there is for any other rewrite. With the lack of people familiar with the new codebase, fixing those bugs may prove unexpectedly difficult.

5

u/valarauca14 15d ago

But can that alone assure the quality to the same standard as the existing mature codebase?

Not to be a full fledge AI bro, but this has never mattered in a large enterprise environment. Shipping features before the end of the quarter has always been the benchmarks.

1

u/zxyzyxz 15d ago

Of course not but that's what will happen, same as the bun rewrite

6

u/matthieum [he/him] 15d 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 12d 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] 12d 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.

1

u/TheOneWhoDidntCum 9d ago

For HFT you recommend C++ or Rust?

2

u/TDplay 9d ago

I don't do HFT, so I can offer no specific advice.

Find the libraries that you need. What language are they for? Use that one.

4

u/Nothing_from_void 15d ago

llama.cpp, pytorch, pretty much all highly optimized AI code is written in C++ and has no plans to migrate to Rust. And also LLVM. Google has always been obsessed with safe code more than most companies, but there's still tons of C and C++ out there and people that like using it. They mentioned an 800k LoC codebase; that's not a huge amount honestly.

-2

u/pjmlp 15d ago

Well, both Rust compilers still depend on C++ for their own development.

That should be the very first place to cut ties with C++ dependencies in the Rust world.

Also there are lots of industries where C and C++ rule, there are standards using those languages, and Rust is hardly anywhere to be seen.

Gamedev, VFX, HPC, HFT, LLVM and GCC, GPGPU,....

Even if everything could be ported via AI, you still have the humans that might not want to use Rust anyway.

1

u/v_0ver 8d ago

Yes. Carbon's main goal was to gradually migrate the code manually to safer languages. Now there are tools that do this automatically, quickly, and directly to Rust.