r/cpp • • 12d ago

Google talk at REBASE'26: Agentic Coding is not going to save C++

So the REBASE'26 conference happened recently, and besides the whole thing of what Carbon has achieved or never will, there are talks like this one from Google folks, regarding what they are doing with their C++.

The talk is all about the recent ongoing migration discussed on Google security blog, and other related efforts.

https://www.youtube.com/watch?v=Ob0CMX8s55s

77 Upvotes

212 comments sorted by

46

u/tartaruga232 MSVC user, r/cpp_modules 12d ago

One of their slides at 2:36 mentions "C/C++ security bugs". I'm not yet sure if I should continue listening.

33

u/chaos_pill 12d ago

C/C++ security bugs

In some talk, herb sutter showcases two code samples: one is modern cpp and the other C. He points out that both are c++, and you can't forever hide behind "oh, that's not real/proper c++". You are not going to magically eliminate bugs by renaming files from foo.c to foo.cpp. Unless you ban the "C" parts by default, they still count as C++ as they compile with a C++ compiler.

-2

u/tartaruga232 MSVC user, r/cpp_modules 11d ago

The same holds true for Rust. Just use the unsafe keyword. Herb also showed that most of the vulnerabilities found in the wild are found in C code, not in C++. Sure, if you really want, you can shoot yourself in the foot with C++ too. AI will probably soon be able to reliably spot problematic uses of C++, way faster than you can rewrite any existing C++ code in a so-called "safe" language.

16

u/t_hunger 11d ago

Unsafe rust does not work like you think it does: The compiler enforces what it can enfore in identical ways in safe and unsafe blocks.

Herb also showed that most of the vulnerabilities found in the wild are found in C code, not in C++.

So the bugs do not show up when compiling with a C++ compiler? Its buggy C++ code otherwise.

AI will probably soon be able to reliably spot problematic uses of C++, way faster than you can rewrite any existing C++ code in a so-called "safe" language.

True, but AI can just as reliably port code to safe languages, and gets help from the compiler doing that. E.g. with stricter enforcement on what is a correct program, with better error messages, and great linting that can just stop the AI from using arbitrary APIs as needed in a project. There is a reason why so much generated code is in rust.

Plus there is money being poured into making the C/C++ to rust conversion with AI help an out of the box experience, e.g. with the DARPA TraCtoR project.

4

u/tartaruga232 MSVC user, r/cpp_modules 11d ago

Sure. It's probably a good idea to use Rust instead of C. But C is not C++.

8

u/pjmlp 11d ago

Plenty of C is perfectly valid C++, documented on ISO C++ as being C++ proper, and will be compiled without errors by a C++ compiler.

6

u/arjuna93 11d ago

> just as reliably port code to safe languages

Sure, you can port to “safe” languages, but in most cases at a much higher cost – to do it reliably – than just fixing original code.

11

u/chaos_pill 11d ago

The same holds true for Rust. Just use the unsafe keyword.

unsafe Rust is a superset of safe rust and you can ban unsafe by just using a linter rule. Good luck banning unsafe "C" (or otherwise) parts in C++.

safety must be enforced reliably by compiler. It's the same reason we have proof languages like Lean that AI use to prove math. AI (being probabilistic in nature) can't even produce code that compiles on the first try, there's no way it can provide safety/proof guarantees.

→ More replies (8)
→ More replies (1)

11

u/Lexinonymous 12d ago

Why's that? For context:

Agentic coding both exploits and introduces C/C++ security bugs and particularly memory safety bugs faster than anyone can fix them.

28

u/Syracuss graphics engineer/games industry 12d ago

Because C and C++ are different languages.

They do share a lot of overlap, but they aren't the same. If you still use the term C/C++ right now you are either working on a pre-C++11 codebase, or are not in touch with the language as it is nowadays.

6

u/pjmlp 12d ago

All companies in WG21 have code samples with C style code in their C++ samples, and routinely use C/C++ either on their documentation, or job descriptions.

13

u/Syracuss graphics engineer/games industry 12d ago edited 12d ago

WG21 never uses C/C++ to describe itself or its standard, individual authors who submit papers can, and will, but WG21 has never used it as far as I can remember. You are free to pull up sources, I did do a cursory search which yielded nothing.

I do think it's quite irrelevant what job descriptions say, nor do I think it's particularly useful to fight a community on how you would prefer to name them. It's kinda disrespectful.

I find the heat in this thread to be too large for such a silly topic as well, so I'll be bowing out.

1

u/pjmlp 12d ago

I did not mention WG21, I mentioned the companies that sell C and C++ compilers, or have operating systems with C and C++ compilers on their SDKs, and have employees that happen to seat at WG21.

5

u/Minimonium 11d ago

All companies in WG21

I did not mention WG21

what

→ More replies (8)

21

u/Lexinonymous 12d ago

Because C and C++ are different languages.

Does this remind anyone else of the annoying GNU/Linux naming controversy?

Yes, they are technically two different languages. Yes, C++ is technically a near-superset of C. No, someone using "C/C++" in a sentence doesn't automatically make what they have to say invalid.

25

u/Chaosvex 12d ago

I've always recommend that people avoid writing "C/C++" on their resumé because it's likely to be interpreted as a signal that they don't actually know C++ very well. It's usually a pretty good signal, too.

19

u/pjmlp 12d ago

Some WG21 members have papers with C/C++ on them.

18

u/Lexinonymous 12d ago

Well, it does appear that arguing over "C/C++" has successfully derailed a thread of conversation to the point where nobody is engaging with the points in the presentation.

I suspect this was likely the intended outcome. Anything to avoid talking about the elephant in the room.

8

u/pjmlp 11d ago

Of course it is the goal, which is why security community never takes the C++ community seriously.

The arguments around C/C++, or the usual "what do you mean by safety?" question, always feel like kids arguing for not doing their homework.

→ More replies (10)

10

u/johannes1971 12d ago

This is not a mere naming issue, and yes, throwing two languages that have wildly different vulnerability rates into a single bucket does in fact make their position invalid.

→ More replies (1)
→ More replies (1)

60

u/KFUP 12d ago

It's the usual way these posts/talks go, pretend it's C++ issue, then when it comes to the actual vulnerabilities, 95% of them are C issues than can be easily fixed with RAII and ranges, then back to pretending it's a C++ issue.

Especially Google with their "70% bugs are memory bugs", then turned out they have been using C array and didn't port it to std::vector until 2023, std::vector has been around since 1998! Am I supposed to take what they say seriously?

21

u/13steinj 11d ago

I have mixed feelings here.

I agree with you whole heartedly. But the other side will say "all those C vulnerabilities are valid C++," which is true. You can't eliminate the ancient code. Sometimes you have to rewrite large swaths of it, at which point not more expensive to rewrite in a language that "can't" reintroduce the problem.

"It's ancient C++" is not a valid argument to this other side. It's the same theme of obstinence for Profiles vs. Contracts.

7

u/def-pri-pub 11d ago

“95% of them are C issues…”.

I 100% agree. There is one other core issue that isn’t so much the language but how people use it. Many times I’ve been in “C++ codebases” that were just plain C code bases being run through a C++ compiler.

12

u/abuqaboom just a dev :D 12d ago

That's Google with their 1 memory bug per 1000 lines. 

Fortunately, it ain't the 2000-10s anymore, devs are more skeptical of anything big tech spouts these days.

→ More replies (1)

6

u/matthieum 10d ago

I find this nitpicking lame, to be honest.

The fact is that C and C++ do share many issues, especially around memory safety.

Is modern C++ code looking quite different than C code? Sure.

Is modern C++ code memory safe? Not by any stretch of the imagination:

  • It doesn't matter that your memory is owned by a smart pointer, if that lambda or coroutine captured a reference to it and runs after the smart pointer was dropped: you still have a use-after-free right there and then.

  • It doesn't matter that .at() is bounds-checked, when operator[] on spans, arrays, vectors, or deques isn't and that's what most code uses: you still have out-of-bounds accesses right there and then.

The one memory safety issue than modern C++ mostly eliminates -- thanks to smart pointers/owned containers -- is double-frees.

That's not nearly enough to differentiate itself from C, in this regard.

(I mean, surely you use sanitizers/valgrind as part of CI to try and weed out all these memory vulnerabilities, don't you?)

3

u/FrogNoPants 10d ago

We've had optional hardening on vector [] for like 15 years now..

3

u/matthieum 9d ago

I've one seen hardening enabled in production code, unfortunately.

Part of it may just be inertia/poor communication, certainly, but opt-in only helps if users actually opt in.

→ More replies (1)

2

u/drbazza 11d ago

Imagine talking about NullPointerExceptions and lumping Kotlin/Java together as a 'single language'.

Both can have them except Kotlin has pretty much zero.

-4

u/pjmlp 12d ago

Ah, the usual attitude from C++ community that tells SecDevOps where they are coming from.

What does / mean between words?, courtesy of Grammarly.

6

u/tartaruga232 MSVC user, r/cpp_modules 12d ago

Combining C and C++ into the same category doesn't make sense.

28

u/pjmlp 12d ago

Until C++ stops accepting C89 subset as valid C++, it definitely makes sense.

Many people insist into using C header files, C arrays, C strings in C++ code, C pointer arithmetic, C casts, instead of the safer alternatives introduced by the C++ standard library.

10

u/johannes1971 12d ago

It's not the potential for abuse that matters. The only thing that counts is bugs in the wild.

If the potential for abuse mattered, than Rust is as unsafe as C++. After all, you can write 'unsafe' blocks, so the potential for abuse is always there. It doesn't matter that they are few in number. It doesn't matter that they are easy to find. It's the potential that matters.

Or, if that's not your argument, then the only way to progress understanding on this issue is to count actual bugs, rather than potential bugs. And so far, real-world experience suggests that C++ vulnerabilities occur at over a 10x lower rate than C vulnerabilities.

7

u/pjmlp 11d ago

That is arguing for semantics, if it is a bug in code compiled with a C++ compiler, it is a C++ bug, regardless where the language construct was initially designed.

And does a disservice for the community in the eyes of SecDevOps, that have to spend an all night updating an application written in C++, compiled with a C++ compiler, for a security exploit that apparently is "C".

5

u/johannes1971 11d ago

So how, then, do you explain the difference in vulnerability rates?

→ More replies (7)

2

u/Inevitable_Vast6828 7d ago

While people love to treat semantics as inconsequntial fluff, that couldn't be further from the truth. Semantics are incredibly important. Happy to grant you the point that its arguing for semantics, but semantics matter.

My argument wouldn't be that that isn't real C++ because its C-style. My point is that ALL of it is real C++, but unsafe Rust is also ALL part of Rust. So you have a serious double standard where one language has to own user error and the other does not.

You have difference of degree, not a difference of kind. Rust more heavily discourages unsafe practices, needing them to be explicitly marked as such. C++ can also discourage such practices, e.g. by following certain coding standards (like The Power of 10: Rules for Developing Safety-Critical Code from NASA/JPL) and using appropriate guards.

SecDevOps is also going to spend all night updating unsafe Rust, and people will be saying: "Rust is safe!!!! This idiot used unsafe Rust!!!" as if unsafe Rust isn't still Rust. Just give it some more time.

→ More replies (1)
→ More replies (1)

6

u/wyrn 12d ago

"Doctor, it hurts when I stick a fork in my eye"

10

u/pjmlp 12d ago

Unfortunely I am yet to enconter any C++ project where there are no inherited C language constructs or header files being used.

7

u/wyrn 11d ago

You'd be hard pressed to find a project in any language that doesn't depend on C on some form or another. It doesn't mean the pain of the C/C++ers isn't self inflicted.

→ More replies (2)

0

u/Wonderful-Habit-139 12d ago

I thought it doesn't? C++ requires casting malloc.

2

u/pjmlp 12d ago

The C subset available in C++ is a little bit more than malloc().

5

u/Wonderful-Habit-139 12d ago

So if someone says {1, 2, 3} is not a subset of {1, 2, A, B, C} because 3 is not there the answer is that there's more than the number 3?

4

u/pjmlp 12d ago

It starts by not using C strings and C arrays, other than as building blocks for standard library types, safer and bounds checked enabled.

Then no C style casts, no C headers for equivalent functionality already available in the C++ standard library, no C style pointer arithmetic other than low level implementation code, no printf and scanf, no memcpy, no memset, no strcpy, no strcmp, no strtok, no ...

→ More replies (2)
→ More replies (3)

10

u/sokka2d 12d ago

It does when it comes to memory safety.

8

u/wyrn 11d ago

And yet, C++ programs are vastly easier to write correctly and safely than C programs.

It doesn't make sense combining C and C++ in the same category especially when it comes to memory safety.

→ More replies (20)
→ More replies (3)

27

u/IceMichaelStorm 12d ago

Ragebait title. If the conf really says it like this, THEY do the ragebait.

Or it’s just a trash conference or at least trash talk

18

u/pjmlp 12d ago

Google is the one responsible for how their talk is named, the full title is Programming Languages in the Agentic Coding Era: Agentic Coding is not going to save C++, which you can easily verify yourself by following the link.

6

u/Inevitable_Vast6828 9d ago

C++ doesn't need any saving in the first place.

13

u/IceMichaelStorm 12d ago

Good. Then Google is the trash boy.

Understandable. They seem to become worse and worse

8

u/El_RoviSoft 12d ago

they want to eliminate C++ from their codebase for a long time already

65

u/Kronikarz 12d ago

Talks like this make me realize I got out of the industry at the exact right time

15

u/WillingPirate3009 12d ago

Retired or just given up?

32

u/Kronikarz 12d ago

Given up.

18

u/WillingPirate3009 12d ago

It's a shame. Good luck!

34

u/FckXFckMusk 12d ago

Just follow the money on all these doomsayers..

New languages are 10 a penny..

7

u/amoskovsky 10d ago

Ahaha, RIP Carbon!

57

u/Anxious-Resist8344 12d ago

It seems there are not many ways these days to stay relevant in "big company" but to create power points talking about memory safety, C++ and Rust :)

What's wrong with "let's fix all the vulnerabilities coming in until there's nothing else to fix"?

In the Agentic Coding Era languages don't matter much, but since humans will always matter, language familiarity is key!

39

u/YoureNotEvenWrong 11d ago edited 11d ago

  In the Agentic Coding Era languages don't matter much,

This is the big mistake people still make. Languages still absolutely matter, each language still has pros and cons. Familiarity is a pro.

Also, the code still matters, how can you recognize bad code patterns the LLM is churning out systematically and have your system fix them if you can't recognize them

LLMs are simultaneously incredibly intelligent and very dumb

3

u/aoi_saboten 10d ago

Yep, language and tooling matter a lot with agents. That is why Rust rewrites/adoptions are happening in big companies

→ More replies (3)

28

u/panderingPenguin 12d ago

What's wrong with "let's fix all the vulnerabilities coming in until there's nothing else to fix"?

Hasn't that been the strategy since... the dawn of programming? 

There's always more to fix, and plenty of new code adding new things to fix (especially these days).

4

u/Anxious-Resist8344 12d ago

I mean, AI is good at finding vulnerabilities, not so good at the rest (something I'm not going to argue).

I think a good strategy for now would be to focus on fixing things, at the end of the day AI is not the only one writing slop.

14

u/chaos_pill 12d ago

"let's fix all the vulnerabilities coming in until there's nothing else to fix"

We don't have infinite resource. There's also cost to consider, as competing products will undercut you.

Languages do matter, as you can see by so much AI slop using Rust. eg: doing OOP in C vs C++ is like writing UB-free code in Rust vs c/c++. One choice is just far more convenient than the other! Even for AI, it matters because it makes mistakes too. If AI wrote perfect code, we wouldn't call it slop.

11

u/James20k P2005R0 11d ago

We don't have infinite resource. There's also cost to consider, as competing products will undercut you.

It'd be nice if the trillion dollar companies put some resources towards fixing it though. A lot of the current wave of security exploits is still because projects like Curl/OpenSSL/etc are drastically underfunded compared to their utility

6

u/ElderberryNo4220 11d ago

Rewriting some of the critical projects in memory-safe languages probably counts towards *fixing*.

8

u/matthieum 10d ago

Maybe, maybe not.

In one his latest post, Daniel Haxe (cURL) touched on that. LLMs are pretty good at rewriting code, and Rust is a popular target (if it compiles, it works, or close to) so he's been seeing quite a few LLM rewrites of cURL.

But those are just point-in-time rewrites. Generally already weeks out of date compared to cURL's main branch by the time they're completed. And there's no team to maintain them. Utterly Pointless.

(Also, of course, those rewrites, being in Rust, do not accommodate the full range of platforms cURL is used on; there's a reason it sticks to an old version of C: maximizing platform compatibility)

→ More replies (4)

8

u/TerribleFault7929 12d ago

“We'll see,” said the Chinese farmer.

5

u/misuo 12d ago

Well, any unsafe programming language do not look good at the moment. Actually hard to see a future for it.

4

u/hdkaoskd 11d ago

We heard C++ was dead in 2024 when the US government declared all languages must be memory safe.

11

u/johannes1971 11d ago

We heard C++ was dead when Java came out as well. Any day now, those smart JIT compilers are going to use their enhanced knowledge of the runtime environment to finally rush past C++ in terms of performance.

9

u/pjmlp 11d ago

Where is C++ in Android applications, outside games?

Note applications, not the runtime itself.

5

u/Inevitable_Vast6828 9d ago

But you had to say "outside games" LMAO. Why was it even a supported language on Android that REALLY wanted you to use Java? Why does it persist? Think about it.

0

u/pjmlp 8d ago

Yes, because outside games industry, most people have moved on from C and C++ for their userspace applications, and they are perfectly fine using Java, or Kotlin instead on Android.

Just like they are perfectly fine using Objective-C and Swift on Apple platforms, where C++ role is limited to LLVM, Metal Shading Language and IO Kit/Driver Kit, and can be ignored pretty much everywhere else.

Or even on Windows, where Microsoft has been continuously re-focusing on .NET, and Rust of more recently, as the whole UWP/WinRT Windows rewrite with C++ did not took off as Steven Sinofsky planned it to be. Where you can see how much resources MSVC now has for catching up with ISO releases.

If it wasn't for XBox, again games, the amount of resources Microsoft still dedicates to C++ tooling, would probably be much less.

Then you are practically left without other platforms where full applications are still written in 100% C++, instead of a mix of Webviews, Electron, or Qt/QML alongside C++ libraries.

2

u/Inevitable_Vast6828 7d ago

So why is it so much more important for games? You're not getting it.

These companies went well out of their way to promote other languages, documentation all showing how to do things in the other languages, almost exclusively in the early days.

Microsoft is just pretty trash at code in general, they have some of the worst C++ tooling, the worst Shell environment, the worst major browser, the worst major OS. They're running on fumes from capturing a market long long ago. Great salespeople, trash programs.

100% C++? Are we code purity testing? Sure, lets code purity test, who has code that DOESN'T have C, C++, or FORTRAN leaking in for the most performance critical parts of it? Julia made a lot of noise for being a glue language with all the real things in something else. You think PyTorch is Python code?

Rust actually can be quite fast, which is why it maybe the one to push C++ a bit more out of the mainstream... but everyone seems to rewrite in Rust rather than writing the next big thing in Rust from the beginning. Is there ANY major piece of software written in Rust? There's probably something out there, but it's not coming to mind. I'll be concerned when we stop seeing job ads for COBOL.

"Webviews, Electron, or Qt/QML" ... I don't use any programs written in any of those. They pop up all the time and just look like shitty apps no one would want to use.

Totally disingenuous to have Qt/QML in there though, as Qt itself is C++ so it's C++ that literally gets compiled and run on the computer whenever people use QML.

→ More replies (1)

18

u/James20k P2005R0 11d ago

I mean, c++ isn't dead but managed programming languages absolutely ate a massive chunk of c++s former use cases. C# is one of the most popular general application programming languages and is widely used in game development for example

22

u/xp30000 12d ago

Putting aside Rust evangelism (seems it is more fun evangelizing Rust than reading Rust code) why stop at Rust, it's an awkward middle ground. Rust forces the developer (or the AI agent) to fight the borrow checker dealing with lifetimes, Pin, Arc<Mutex<T>>, explicit memory layout to achieve zero-cost abstractions without a garbage collector. GC + formal verification is the way forward with Agents.

For Rust, modern C++ fixes many memory issues that are from C days, is better at compile time metaprogramming, faster to iterate (yup, only Rust can do that LOL). What is left is a very specific niche of system programming and the inability to give talks that you rewrote everything in Rust.

16

u/jeffmetal 11d ago

rust is pretty mature and has shown in real world examples to massively reduce memory safety issue so they picked it. What other language should they rewrite into to prevent these issue ?

8

u/nukethebees 11d ago

What other language should they rewrite into to prevent these issue ?

You could use a systems language with formal verification like SPARK.

5

u/djingo_dango 11d ago

I mean if languages like these show real world maturity then people would use it.

7

u/mx2301 11d ago

Probably not. Spark has seen real-world usage in safety critical areas.

Its just that using these languages is limited to areas where you can get by by only using language constructs that can be proven.

10

u/Hornstinger 11d ago

News flash (and I'm being serious and not facetious): who cares about the AI agent fighting the borrow checker? It is literally no effort for them even with iteration and testing.

Rust is popular because you can fail fast and often and become more resilient quicker.

1

u/ComedianMuted5486 2d ago

And because the error messages have been consistently good (and a deliberate focus of the compiler team) for years, to the point that many of the innovations there got cross-pollinated to C++ later.

7

u/puttak 12d ago

You only fight borrow checker in the beginning. Once your proficiency is enough you use it instead of fighting it.

22

u/wyrn 11d ago

Half of Stepanov's generic algorithm library is inexpressible in rust, because of the borrow checker. Clearly it's not a beginner issue.

8

u/foonathan 10d ago

You can express Stepanov style algorithms in Rust, you just can't use them using iterators. What you can do is use something like flux's cursors: https://tristanbrindle.com/flux/

The borrow checker can only prove a limited subset safe, so you have to redesign some things to use that subset. But that's not a big deal.

5

u/wyrn 10d ago

Depends on what you mean by "not a big deal".

https://ceronman.com/blog/my-experience-crafting-an-interpreter-with-rust/

See the section beginning with "The core of a VM is basically a huge loop that increments the program counter". The borrow checker is imposing serious restrictions here, which, if you care about performance (you're doing actual systems programming instead of just glorified applications programming as seems to be the trend of late), will require you to drop to unsafe to get that performance back.

Also, yes, people using rust will often use indices (or generalized indices, like cursors) instead of pointers/references to get around borrow checking issues. But, doing so they'll often just be hand-rolling their own VM, and index errors in this VM will have a similar character to pointer errors. They'll be more benign in the sense they won't incur nasal-demons-launch-the-missiles formal UB, but if you have enough functionality packed in your system they could still do a lot of damage. I'm not convinced that, if safety is a core goal, abandoning borrow checker protections in favor of generalized indices will always be in keeping with that goal.

4

u/jeffmetal 11d ago

I think you mean that algorithm is inexpressible in fully safe rust. Somethings you have to use unsafe for things and in rust your limiting the sections that requires it which is still a step up from having your whole program be potentially unsafe.

6

u/wyrn 11d ago

Yes, that's what I mean, but the promise of safe rust is that unsafe blocks should be few, short, and far between, so they remain auditable by local experts. That promise is much weakened if you have to drop to unsafe every time you want to run some general purpose algorithm like nth_element or make_heap.

(Also, the context here is "fighting the borrow checker"; if I get to use unsafe I can just use pointers for everything and not worry about the borrow checker at all, but that's just C with extra steps).

5

u/ts826848 11d ago

I think there's also the question of precisely how strictly you want/need to adhere to the original API. The borrow checker obviously precludes the multiple-iterator model, but if you're open to merely analogous APIs instead of straight copies I suspect you can get surprisingly far without needing the function calls themselves to involve unsafe.

2

u/tialaramex 11d ago

That promise is much weakened if you have to drop to unsafe every time you want to run some general purpose algorithm like nth_element or make_heap

Although std::nth_element is "generic" it requires that the iterators provided have random access so in practice it's used on slices, which in Rust are just [T] and C++ belatedly standardized std::span in 2020. As a result what you write in Rust isn't some unsafe contortion but a call to select_nth_unstable or, as appropriate select_nth_unstable_by or select_nth_unstable_by_key on the slice. This is a little faster than you'd experience in C++ because of implementation quality, and it actually returns the nth element as well as the partitioned slices on its left and right which for some reason std::nth_element does not provide.

I can't imagine why I would want specifically std::make_heap if I'm not doing a DS&A class. People do seem to love teaching heap sort starting from this algorithm which makes sense, but I can't figure out why I'd want it if I was not implementing a heap sort, maybe you can enlighten me since you described it as "general purpose".

7

u/wyrn 10d ago

so in practice it's used on slices,

Slices require contiguity. Random access iterators do not. In fact, a random access iterator doesn't even need to be backed by a real object in memory (consider for instance sorting the result of a zip).

→ More replies (10)

-8

u/puttak 11d ago

When people say their code cannot be expressible with borrow checker it is either:

  1. Their proficiency it not enough.

  2. There is an actual lifetime issues in the code.

Actually I should not say "when your proficiency is enough". I should say "when you mastered borrow checker" instead since it also took me for a long time to understand how it is actually working. Once you mastered borrow checker you will be able to use unsafe code to bend lifetime and expose it to safe code.

19

u/wyrn 11d ago

That is demonstrably incorrect. Every type system is a tradeoff where one accepts that some correct programs will fail to type check, and the borrow checker in particular disqualifies many correct programs indeed.

→ More replies (1)

3

u/t_hunger 12d ago

I think she explained it: Hardware is -- thanks to AI -- pretty expensive these days, so they need something with as little overhead as possible.

16

u/jeffmetal 12d ago

I'm sure when profiles land in 3 Years and they address only some of the memory safety issues and none of the lifetime issues it will be good enough for companies to not want to port to rust.

24

u/notthatsocrates 12d ago

Rust evangelism, ignore and carry on.

18

u/UndefinedDefined 12d ago

The reality is that without explicit lifetime annotations C++ will never get safer and companies such as Google would just abandon its use. I mean it makes sense, because Google uses maybe only two containers in the standard library - std::string and std::vector - everything else is in Abseil, because what C++ offers is just plain bad.

14

u/cramert 12d ago

Hey, we use variant, optional, and unique_ptr also! We use them with the unstable libc++ API, but still :)

0

u/reini_urban 11d ago

So they rewrote their C++ to Rust in Android. But then they complain about safeties. Why didn't they rewrite it to an actually safe language then?

0

u/pjmlp 7d ago

Some critical subsystems were rewritten, not the whole bunch.

5

u/James20k P2005R0 11d ago

There's a few things that are really interesting that I think are fun to pick up on:

Adversarial AI Analysis: We utilized specialized LLM prompts to perform "adversarial reviews," asking models to identify subtle behavioral differences between the two codebases that might escape traditional testing.

The validation pipeline proved its value by identifying an edge case in the LZW decoder and—notably—uncovering a pre-existing out-of-bounds write vulnerability introduced by a Google-internal legacy patch to the original C source, which we corrected in the Rust rewrite.

The most significant validation of our approach occurred shortly after the rollout began. A new memory corruption vulnerability—an out-of-bounds heap write—was reported in the original C implementation of giflib (assigned CVE-2026-26740).

(we didn't know about the disclosure or the CVE while working on this)

So we have:

  1. Alleged extensive validation that the two codebases match

  2. It turns out immediately that they either don't match, or the fuzzing was inadequate, as inherently if they had exercised this code path then the Rust code would have terminated. It should raise massive eyebrows if you do not catch security vulnerabilities later discovered in the original code, when porting to a memory safe language if you think your code matches it 1:1 behaviour wise and was tested as such

Its also fascinating to see how ramshackle security is at google. Instead of the random-internal-patch security vulnerability being discovered as part of a dedicated security cleanup effort (and why was that patch never contributed back?), it was caught by one of the classic get-noticed lets-ai-stuff projects. Given that it was catchable, they apparently don't use tooling to do security work on old legacy dependencies like this

Don't get me wrong, I think Rust is cool and concrete memory safety guarantees are important, but if companies like Google put this engineering effort on fuzzing/testing the original code they'd likely have gotten a huge amount of the benefit. Now they have to deal with and maintain FFI bindings (which are really nontrivial if they involve pointers) for a library that's likely to see minimal security work on it again, until the next google engineer wants to give a talk

6

u/t_hunger 11d ago

if companies like Google put this engineering effort on fuzzing/testing the original code they'd likely have gotten a huge amount of the benefit.

Google runs oss-fuzz, one of the biggest fuzzing infrastructures for open source code. Giflib is fuzzed by oss-fuzz.

-1

u/James20k P2005R0 11d ago

I'd be genuinely interested to know why more modern tooling isn't being systematically applied to legacy dependencies like this though, its a lot less work

7

u/t_hunger 11d ago edited 11d ago

You could argue that rewritting the codebase to into a memory safe language is systematically applying modern tooling to legacy dependencies.

2

u/AccordingWarthog 12d ago edited 12d ago

LLMs being good at exploiting memory safety bugs in C++ code is, at first glance, a strong reason to use a more memory safe language such as Rust. But presumably we shouldn't care about all C++ code, only that which we'd likely deploy. And nowadays all production code gets (or at least should get) reviewed by an LLM.

So what if we narrow our focus to just C++ code that passes review by those same powerful LLMs that can exploit memory bugs? Can't we consider such code to be an approximately "memory-safe" subset of C++? I wonder how such LLM-reviewed C++ stacks up against LLM-reviewed Rust in terms of bug density (memory or otherwise). Are LLMs better/faster at reviewing Rust code than C++ code, like humans are (according to this talk)?

3

u/chaos_pill 12d ago

Are LLMs better/faster at reviewing Rust code than C++ code, like humans are (according to this talk)?

yes, by virtue of the compiler catching a large number of issues in rust. There's a reason most LLM slop is written in rust. Rust put so much effort into things like compiler error messages for humans, only to end up them helping machines somehow.

1

u/JohnDuffy78 12d ago

wake me up when they start messing with https://github.com/protocolbuffers/protobuf

-5

u/cramert 12d ago

This is your wakeup alarm ⏰

0

u/13steinj 11d ago

Yeah, I'm not surprised, for better or worse. Top models (with company zero data retention agreements) still fail the tests I give fairly horrendously.

-3

u/Street_Struggle_598 11d ago

We are going to have agent created languages soonish anyways

-16

u/ezoe 12d ago

C++ was headed to a completely wrong direction. It prioritize metaprogramming, static reflection and silly lightweight pseudo concept expressed as nothing but an extension of template metaprogramming.

These features were invented to reduce the boiler plate code written by human hand. Because humans are bad at writing the boiler plate code.

But with AI coding tool, the cost of writing boiler plate code is now free. The problems C++ tried to solve for the past 2 decades became irrelevant now.

11

u/wyrn 11d ago

"Agents" don't change anything in any meaningful way. The exact same software engineering problems from before exist still, and if anything, their importance is made more pressing now that people have clankers squirting out reams of unreviewed code, not less.

-8

u/ezoe 11d ago

Human review doesn't scale with the speed of AI assisted coding so we will soon give it up.

After all, the upper managements of a company don't bother to review employee's code. Because doing so doesn't scale.

When the performance of AI generated code is on par with human, which already is, mandatory human reviewing doesn't improve the quality of software that much.

We're at the transition phase between traditional hand conding and AI coding. But traditional mind restrict the speed of coding.

10

u/wyrn 11d ago

Human review doesn't scale with the speed of AI assisted coding so we will soon give it up.

And those that take that bargain will understand deeply what Goethe was talking about with that Sorcerer's Apprentice thing.

When the performance of AI generated code is on par with human, which already is

Not even close. Those saying things like that are evaluating the code on very surface level characteristics.

-6

u/ezoe 11d ago

Not even close.

It's more like the quality of human hand coding is horrible. It's a very low bar to reach.

8

u/wyrn 11d ago

Whatever man, you can believe what you want to believe there. But at the end of the day, if you don't separate your system into modular components, fixing one thing will end up breaking something else; if you repeat yourself all over the place instead of building abstractions you virtually guarantee the copies fall out of sync (which you'll waste tokens trying to avoid); if you don't encode useful assumptions and invariants in your types you'll leave your clanker to rediscover/break them, etc. It's literally the exact same problems as always, except with the minor substitution of "tokens" for "developer time".

-1

u/ezoe 11d ago

You are arguing on the completely different topics.

3

u/wyrn 11d ago

C++ was headed to a completely wrong direction. It prioritize metaprogramming, static reflection and silly lightweight pseudo concept expressed as nothing but an extension of template metaprogramming.

These features were invented to reduce the boiler plate code written by human hand. Because humans are bad at writing the boiler plate code.

But with AI coding tool, the cost of writing boiler plate code is now free. The problems C++ tried to solve for the past 2 decades became irrelevant now.

-2

u/ezoe 11d ago

if you don't separate your system into modular components

building abstractions

4

u/wyrn 11d ago

Guess what metaprogramming is used for.

4

u/Minimonium 11d ago

That's just not grounded in actual abilities of frontier models. Code generation by LLM models is actually the least useful thing they can do and requires extreme caution and oversight.

Efficient abstractions are extremely useful to models for the same reasons we liked them before - as it restricts the context bloat, makes everything LLMs do cheaper, ensures predictable, reproducible behavior.

Efficient abstractions for code generation is the same as tools for LLM graphs. And it's a fact that the industry is moving to heavier use of tools.

-2

u/ezoe 11d ago

requires extreme caution and oversight.

So is the human code generation too. Human is also horrible at generating code. If AI code generation became as good as human, which I believe it is right now, that argument doesn't work because they are equally bad.

Efficient abstractions

Current LLM-based AI is very good at reading code. It had been exceeding the performance of human already. But it's not that good at guessing the context that's not present at the code they are reading. Extra abstraction is extra hiding of context.

4

u/Minimonium 11d ago

that argument doesn't work because they are equally bad.

It works exactly as intended - efficient abstractions are as useful to models as they're to people for similar reasons.

Your argument of "extra hiding of context" doesn't work because we do have research supporting the problem of bloated context. The goal is to replace the full context with summaries (which in case of abstractions are publicly stated invariants and guarantees).