Memory Safety Won’t Build the Missing Stack

331 points•simonask•1 day ago•358 comments•

358 comments

tehabout 23 hours ago
I feel almost every single point in this article. I spent the last 5 years of my life fighting c++ in a finance place. Something that should be a 20 minute job becomes 20 minutes & several hours of cmake because abseil in some deep dependency does c++ version detection and segfaults because std::string_view isn't compatible with its own version.

What makes this worse in finance is that you sometimes only get a binary library to link against so you have to add another 2 days to run the library in a subprocess with some kind of rpc interface on top because it's not link compatible.

I can't speak to the standardization saga but IMHO that really feels like they are arguing over areas that ultimately should be in libraries and where the exact details don't matter that much. There are interesting areas like verification (rust verus e.g.) where c++ contracts might help but by the time I'm getting value from that years will have passed when I can have 3 different tools right now in rust.

c++ has the weight of history and many large projects like llvm etc I can really tell the dam finally broke. I am currently interviewing and number of companies now have or are starting rust teams to replace their internal c++.

I think the author thinks it's possible for c++ to catch up but IMHO it's too late for that now. There are too many people like me who have burnt years on c++ and don't really want to go back.

oiveyabout 16 hours ago
> Something that should be a 20 minute job becomes 20 minutes & several hours of cmake because abseil in some deep dependency does c++ version detection and segfaults because std::string_view isn't compatible with its own version.

> I can't speak to the standardization saga but IMHO that really feels like they are arguing over areas that ultimately should be in libraries and where the exact details don't matter that much.

The string_view issue is directly related to the lack of common functionality in the standard library. Holes like that deeply damage the ability for libraries to interoperate.

sufficientsoupabout 21 hours ago
> several hours of cmake because abseil in some deep dependency

The hours I've spent in CMake trying to get an instance of Abseil to play nice with an instance of Protobuf (which uses Abseil), an instance of gRPC (which uses Protobuf), and an instance of LibTorch (which uses Protobuf)... To this day, I don't know if my CMake was bad or if theirs was. Maybe both.

klodolphabout 17 hours ago
Sounds like you’re reconstructing a snapshot of google3
Vaushiteabout 16 hours ago
cmake is just a wrapper that generates build commands. If it's not working for you, you can use something else
superxpro12about 15 hours ago
ive gone to war with cmake to the point that i was convinced there was some deep temp cache file hidden on the pc that nobody knew about.

Ive had cmake problems that werent fixed by a clean and rebuild, or a nuke of the entire cmakecache, but instead by re-cloning the entire project. it make no sense.

lenkiteabout 16 hours ago
The funny thing is that after ALL that hoopla, C++ stdlib is actually smaller than Rust std. Rust has TCP networking, UDP networking, IP address manipulation, Child process management, Environment variables, Concurrent channels, Unicode-aware strings, proper Futures, limited Date and calendar operations, Lazy iterator pipelines.

Incoming: Rust allocators, std::random, std::simd, ByteStr, ByteString, zerocopy (longer term)

Rust just moves far faster than C++ standardization.

gfasterabout 16 hours ago
Allocators were stabilized in 1.100!

https://blog.rust-lang.org/2026/11/12/Rust-1.100.0/

SkiFire13about 15 hours ago
TBH however C++ has locales, time, random, regex, multi-dimensional array spans, simd and more.
vinniefalcoabout 21 hours ago
The Standardization Committee needs to get its priorities in line and solve problems that people actually have, instead of niche problems that corporations have. "Contracts" and "std::execution" are not going to help us build the tower of library abstractions.
hinkleyabout 16 hours ago
The chances of the former happening after the latter has become common is pretty low. This is what regulatory capture looks like when it hits a standards body.
zarzavatabout 23 hours ago
C++ is dying. The only thing keeping it going pre-AI was the large number of experienced C++ developers who had invested decades into learning the language, and I say this as one of those people.

AI makes it easier to write new code in Rust, easier to rewrite old code from C++, and easier to exploit C++ code.

There's no way back for the language, inertia will carry it for the next 10+ years but its eventual irrelevance is a certainty.

fwsgonzoabout 23 hours ago
Indeed. I've converted one of my projects to Rust via LLMs and it was completely painless and ~same performance. LLMs found a swathe of issues that I ended up porting back as well. I still maintain the C++ library, but it's mostly for my own and existing usages now. I think newer projects will be looking for the Rust crate. I've also noticed that LLMs are doing better with Rust overall: Building, testing, formatting, linting and publishing is all standardized. As it should be.

LLMs are quite good at hand-written assembly though, so my C++ library still has a large lead for platforms where that work is done. I can probably port that to Rust as well, but I did start out with forbid(unsafe).

roflcopter69about 22 hours ago
I remembered your username, hello libriscv guy, cool to see you posting here! I suppose you are talking about https://github.com/libriscv/libriscv-rs ? Cool to see it!
oreallyabout 21 hours ago
bad mistake. would have been more productive to use that LLM to rectify your c++ instead.
VadimPRabout 12 hours ago
I used AI to make existing C++ code better, didn't pay for the increased compile times, and I think I'm better off this way.

It's a language I know, and I'm unlikely to learn ins and outs of Rust with LLMs around, neither are other devs stitching to Rust either I reckon.

In this scenario I really don't see a compelling argument to switch.

oofbeyabout 8 hours ago
The most compelling argument for me is safety. The infosec apocalypse we're all living through right now is almost entirely caused by people using languages like C++ that are unsafe. Rust can completely eliminate that risk, and I'm betting pretty soon that'll be expected for any software people need to trust.

It's true the compile times are often higher, but if you split crates aggressively and only use release builds when you really need to, the difference isn't that big.

ChrisRRabout 22 hours ago
I can't see it going anywhere soon. The amount of existing projects in C++ still need developers
neuwirthabout 22 hours ago
We live in a world where the labs are still training on Fortran! If Fortran hasn't gone C++ won't either. So no, it isn't going anywhere soon, just by nature of being an incumbent.
windwardabout 22 hours ago
What kind of existence? COBOL and Ada 'exist'.

The machine already knows the CPP core guidelines better than any human, so you won't be able to drop in on a project as a consultant just from knowing the language well.

There's a project I once worked on that would be unfeasible to rewrite because there is so much unwritten about how it should perform - there are too many features and targets to test exhaustively. But that company already did layoffs pre-AI, because it already didn't take many devs with domain knowledge to keep it ticking. That project won't demand much language support and an industry of these projects won't be desirable to work in.

trinix912about 22 hours ago
They've been saying C++ is dying for decades now but it's still here with (almost) all its problems :)
jibaltabout 23 hours ago
You seem to have missed a few things in TFA, as well as the amount of deployed C++ code and the number of installations, not just developer count (which is also massive).
zarzavatabout 21 hours ago
The transition will take a very long time, but it's happening. Deployed code will get rewritten by AI, nobody wants to maintain an insecure C++ codebase in 2026, it's too much of a liability for anything not airgapped.
modelessabout 12 hours ago
How many of those developers are still typing code daily? More importantly, how many will be two years from now?
jmyeetabout 16 hours ago
This is my belief as well.

We’ve seen recent examples of fairly rapid complete rewrites into other languages using AI. That’s only going to get better.

Rust isn’t a panacea but it solves a class of critical problems around memory safety and concurrency. AI has made those factors even more important. At the same time AI makes Rust easier to write, which has always been an issue.

nly1 day ago
C has most of the same problems raised in the article. You'll notice there's no "C SDK" on all those third party SDK lists either. There's no universal package manager for C. No standard library worth a damn.

My personal view is APIs and behaviours should be standardized, not libraries. In that respect C++s efforts to figure out universal async I/O is a noble one unmatched by other languages. And it's a hard problem.

That's not to say it hasn't gone off the rails. The Sender-Receiver model has never 'clicked' for me. I think the ideas is alien and overly abstract and I've never seen anything elegant fall out of it on a single page. Coroutines on the other hand make sense. The C++ language implementation of them is elegant and versatile.

std::execution is a verbose mess.

At my employer pretty much all of our code is C++ and threads aren't used anywhere. As a result, I/O tends to go through our own APIs written to use an Linux ioring backend behind C++ coroutines, which yield to our own main event loop.

whizzter1 day ago
Kinda disagree here about the "elegantness", superficially it's an elegant abstraction to unify generator-like coroutines and "tasks".

In practice it's bad, a generator (co_yield) is often an encapsulated object that will have a non-deterministic lifetime, thus it cannot be put into a fifo.

"Tasks" however (co_await / co_return) often live on a stack-fifo that could've been mixed with partial bump-allocators to allow pointer-stability for the stack-frame (there is kind of the machinery via the new overloading for the promise), but due to varying lifetimes it easily becomes a mess (Looked at some other task library that seemingly had low allocations like this but it feels like the entire machinery can easily break with "careless" usage).

And I think that's a part of why std::execution feels like a mess, it tries to make coroutines in task settings more "usable" for those writing things around tasks, but it doesn't really decide on a coherent direction for tasks (since the language primitive was left too abstract/messy).

nly1 day ago
I'm not too familiar with generators. I've never really had much use for them. I've used co_yield once successfully to interleave two separate tree recursions in lock-step and I don't remember any issues.

It's also not at clear to me why you'd want to put a generator into a fifo. Any succinct code snippets that demonstrate the issue?

BeeOnRopeabout 17 hours ago
Well LLVM supports HALO optimization can remove frame allocations when the coroutine lifetimes are suitably nested, though you need to apply some specific annotations to assert this is safe in a given context before it will kick in.

> there is kind of the machinery via the new overloading for the promise

Any details?

Vaushiteabout 16 hours ago
C++ coroutines are always heap-allocated, precisely because their lifetime is so hard to predict.
silvestrovabout 22 hours ago
I think C and C++ always have suffered from wanting to support all kinds of weird architectures like 9 bit bytes and 80286 style segmented memory. So many people see this as a virtue rather than restricting the usefulness of C.

So char always means "byte" and never a real character. I don't think many C programs will work well if char is a 32 bit type so it supports full unicode.

int8_t came way too late and has a way too long name. It should be i8 or int8. There is a problem when C is more verbose than Java. Also: why did it take so long to get a boolean type and fix the "bools are ints" design mistake.

Lack of standard libraries and module system is just another layer of not wanting to standardize things.

foldrabout 21 hours ago
>I don't think many C programs will work well if char is a 32 bit type so it supports full unicode.

That's not really how unicode support works. It can be useful to have a specific type for storing unicode code points (like Go's 'rune' type), but strings are generally UTF-8 encoded these days, so having a wide char type plays at most a marginal role in a language's unicode support.

ghosty141about 22 hours ago
> C has most of the same problems raised in the article

Correct but I'd argue almost nobody builds desktop applications in C anymore and the places where C is the most common (embedded) they built full on frameworks including package managers around them.

ueckerabout 4 hours ago
Perhaps people should write desktop applications in C more, as ones I use that are written in C are the applications I like most.
Vaushiteabout 16 hours ago
No one does it, but I did do it recently and it was like a breath of fresh air being outside all these frameworks. Of course it brings problems that you don't have in a framework, too.
jayd16about 17 hours ago
I think you touched on the main issue but blew past it. There isn't a simple, universal package manager solution.

You can have all the standardization in the world but if you can't trivially swap one implementation for another then what's the point?

I also feel this is self fulfilling. If there's no simple way to pull in libraries then why worry about being compatible anyway? Every codebase has its own quirks and build setup and macros. Why not? There was no simple tool they broke by making those choices.

bee_riderabout 17 hours ago
C shouldn’t suffer from these problems. It is just not a language to write massive projects with a ton of complex dependencies in.

C will make this obvious by stepping on your toes. C++ will help you along until it has enough leverage to break ‘em.

filipdobro1 day ago
> Dependency friction in C++ is so punishing that authors advertise “header-only, zero dependencies!”

This article kinda sums up all frustrations I have with C++. Vcpkg seemed like a good fix at the time, but it needs so much more improvement and adoption.

A lot of good solutions to the raised issues in the article require us to rip the bandaid off, however I believe the community built around C++ has built their systems around the premise that it must remain stable and predictable.

Eji17001 day ago
> C++ still owns bare metal, low-latency trading, game engines, GPU inference kernels, and decade-spanning binary ABI stability

I wonder how long many of these will last.

AI is absolutely a predator to C++ not a benefit as the author notes, at least in my untrained eyes. Any language that gives you consistent “pythonic” standards and compile time “if it compiles it runs” guarantees (or tries to) seems to perform VASTLY better with AI than the ones that can’t.

C++ has, as an outsider who’s talked to C/C++ coders and written less than 1000 lines, felt like it decided “yeah but if you want fast on bare metal you’ll put up with it” and left it there.

Rust was designed to come for that lunch and it sure seems like that time is upon us. I’ve no doubt that the most performant code may still be theirs, but if it’s not on a rocket it’s probably going to be Rust not C++ sooner than later.

With that in mind I’m extremely curious how much longer it’ll be the standard for games. Yes if you want cutting edge graphics and physics you’re going to be managing your memory and might as well go deep, but as more and more of my backlog looks like Probably Stolen or say more “demanding” Caves of Qud or Nuclear Option i wonder where that line starts to blur.

Given the whole “shipping” goal I don’t see the next generation reaching for something so “hostile” when good enough and easy to work with get the job done and don’t have “must trade every nano second” needs

Read the full thread on Hacker News →

Related stories