Memory Safety Won’t Build the Missing Stack
358 comments
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.
> 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.
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.
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.
Incoming: Rust allocators, std::random, std::simd, ByteStr, ByteString, zerocopy (longer term)
Rust just moves far faster than C++ standardization.
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.
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).
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.
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.
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.
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.
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.
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).
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?
> there is kind of the machinery via the new overloading for the promise
Any details?
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.
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.
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.
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.
C will make this obvious by stepping on your toes. C++ will help you along until it has enough leverage to break ‘em.
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.
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
- I have some questions for Mark Zuckerbergtheverge.comThe Verge · 0 points · 2 months ago
- Lobsters · 10 points · 4 months ago
- Scaling Memory Safety: AI-Assisted Rewrites of C/C++ Dependencies to Rustbughunters.google.comHacker News · 3 points · 2 months ago
- Memory safety for Postgres extensions in C/C++clickhouse.comHacker News · 1 points · about 2 months ago
- Memory safety for Postgres extensions in C/C++clickhouse.comHacker News · 3 points · 2 months ago
- Hacker News · 1 points · 2 months ago