145 points · by dverlaeckt80 · 2d ago · 203 comments
The rejection was a moment for them to reevaluate their priorities but it doesn't seem that they've gotten the message.
There's a wisdom I got throughout life in various scenarios: You can't beat anyone in their own game. Currently memory safety is Rust's game. C++'s game is different: Being a high level language with tons of features, legacy (install base), a massive and well established ecosystem, and as a result of that shared knowledge.
Hence, from my personal perspective, C++ shall be C++. Getting useful features and cross-pollination is useful, but imitating or trying to beat something in its own game is waste of time and energy.
Because Rust and C++ are built different, and Rust's features doesn't replace battle-tested code. uutils shipped with 140CVEs at some point. That'll be my poster example for a very long time.
Safe C++ proposal (based on Circle compiler) was refused, and I don't believe in profiles as they are being sold, but lets see.
Reduce friction for adding packages to a project, and everyone imports everything in a whim.
sudo-rs was pulling in a couple of million LOCs at one point. Yeah, most of it was unused at the end of the day, but it's a massive surface for something like sudo of all things.
Cargo culting is considered harmful.
> Languages bringing in their own packaging ecosystem via their tool always fall prey to something I call "leftpad syndrome"
I'm not aware of such problem in C#, for example.About half of the things I want from CPAN are available through distribution packages, and things will usually work when I use the distribution packages I can get and then install the rest from CPAN.
If someone is considering writing in Rust, I doubt you will convince them that C++ is better instead. It's as if you're trying to tell someone going to the moon that Mars is the better choice.
The doubt about C++ over Rust isn't well founded either. For instance, someone might be considering Rust solely because of dissatisfaction with packaging or memory safety in C++.
It's a variation of the "apples to oranges" metaphor which is just as stupid. Like, those are both fruits, so they have very similar possible uses, you absolutely can compare them! It's comparing, I don't know, toasters and umbrellas — yeah, that'd be silly, but only because the result of the comparison would be instantaneously apparent. You want toasted bread? Use a toaster. Protection from rain? An umbrella is obviously superior. Painting a roof? Both are equally useless.
So, Rust vs. C++? You want language features, you want tooling, you want the library ecosystem, you want the resulting programs' performance. All of those are things that the languages can, and should, be meaningfully compared with each other on.
C++ already has the tools needed for memory safety, but it will never like Rust without serious compromises. Remember, C++ is C with extra features (except for a few minor details), C is not memory safe and will never be, so, for C++ to become memory safe, it has to depart from C, which to me is completely missing the point of C++. To me, the point of C++ is: "I want to write C, but I also want feature X", where is can be templates, classes, smart pointers, namespaces, etc... I don't have to use them all at once. For instance, if the only thing that interests me are templates, I just write my C code with raw pointers and all that, have my templates and compile it with a C++ compiler.
As for packages, there are already packages managers for C++, such as Conan. Unlike Rust, C++ is just a language, Rust is a trademarked brand, with a foundation that manages a whole ecosystem with the language itself but also a packet manager, build system, repository, community, etc... Different scope. For standardizing packaging, one would need a different committee, which may or may not align with the C++ revisions.
As for the "niche features", it is again the idea that C++ is C with extra features. Some people need contracts, give them contracts, others can simply ignore them. It is just another tool in the toolbox. Unlike Rust-like memory safety, it won't affect those who don't need it.
If you want Rust, use Rust, don't make C++ be Rust. Or maybe try some of the alternatives like Carbon.
Which it did long ago.
> To me, the point of C++ is: "I want to write C, but I also want feature X"
You are part of a small minority.
C is not memory safe and will never be
On the contrary, C is far more easily made memory safe than C++, because it's a much simpler language with almost entirely explicit control flow. You have fil-c, CMBC, TIS that all work today, not to mention the profusion of annotation-based tools that have existed for years. Galois is working on C2Rust and other tools, though they're not fully safe/general yet.Your options for C++ essentially amount to sanitizers, less-accurate static analysis work, and paying experts like TIS for manual verification. C++ is also choosing to actively make the problem worse when it deliberately refrains from adopting C's verifiability improvements, like prohibiting time-traveling UB. It's not like this is solely a problem of legacy standards either. std::span could have been safe (as gsl::span is), but the decision was made to deliberately sacrifice safety for other considerations.
Except for all the ways in which it isn't, which are more applicable to the average codebase than any of those tools.
(The two most famous examples of this are type punning, which is well-defined in C but not in C++, and infinite loops without side effects, which were UB in C++ until this year because of C++'s stricter forward progress guarantee.)
I don't think you need a separate committee. There were efforts to create a standardized packaging system through the committee, but the author decided to pursue a different path outside of the committee after it was clear that the committee's priorities were elsewhere.
As a fan of functional programming, I love this as a language feature. I also appreciate that it's profoundly opt-in, and I agree that package management and memory safety are more pressing.
I'm curious, as a C++ outsider: what memory safety features are currently being discussed that look most promising? How many would retroactively apply to existing code bases if compiled against an appropriately recent `--std` setting?
However, I think it’s insane to allow them to modify values. I get it probably really hard to prevent that in C++, but man is that going to be insanely hard to reason about.
No, C++ contracts have nothing to do with the type system. It is purely predicate calculus using Hoare logic where subsets of state space are filtered from a larger program state space. The program is basically "steered" through the global state space using pre/post conditions.
Note however that theoretically (i.e. following from Curry-Howard correspondence) contracts can be thought of as dynamic counterparts to dependent types. But that is in a functional language with typing using constructive logic and not in an imperative language.
CMake 4.5 is the first stable release with support for it, and it still needs to widespread.
This is a really weird way of stating this.
It's like saying "hammer is losing to a screw driver". These are tools with different requirements spaces.
But in general agree it feels more academic than industrial.
The way I see it languages are industrial ecosystems.
There are several good reasons why a language should have "it's own" compiler chain.
While C++ is not going to disappear, piggybacking on C++ infrastructure means that Rust is not really standing on it's own feet institutionally or technologically.
These two have lots of second order effects as I see it. But the topic is too complex to fit to a brief comment :)
The pushback from the final rejection got the committee to add the bare minimum that could help C++’s safety story.
So the “fix” was to let the author mark individual contracts as always enforced at runtime, with pre<enforced>. That, in turn, means a library’s key safety checks (bounds, null, etc.) can’t be silently dropped in a “loose” build configuration, which pushes things down a safer path.
Clunky IMO, but rather reasonable as a response to Rust!
It brings things closer to a world where: if you use these “safe” libraries, your program will stop rather than run unsafely, no matter how it was built.
What they added is no different in practice to what contracts already were before. If a compiler adds `-fno-contracts` then they will not be enforced, which was already the case.
But hey, if it helps C++ make it past the ISO process then it will have been a value-added change even though it's not actually any different.
Contracts are an optional debugging tool. They are literally designed to assert pre and post conditions. They are no better than the assert macro in asserting memory safety.
The most trivial example of this is a check that a caller has provided non-null inputs ( hence allowing 'safe' unchecked access in most cases)
There really is a smaller, more beautiful language within C++ getting smothered by committee design, despite Bjarne's wishes.
I agree, this is the worst possible outcome. Proponents of contracts failed to address substantial concerns and invested only on "practicing" answer rounds, which means they opted to double down and bey on a petry politics showdown akin to a game of chicken.
This is exactly what ends up killing a language. Talk about shooting yourself in the foot.
Something is terribly-wrong with the standardization committee if such useful feature as labeled loops (proven to work fine in other languages for decades) are still not in the standard, but questionable things like std::regex or contracts are.
Labeled break/continue is in some way better than unlabeled break/continue because they can carry more meaning and tell you which loop you are operating on.
You can of course write some ugly soup with this, but so can you right now with some extra variables.
And even then this does not have the full "power"s of goto. You cannot even create irreducible control flows with it.
Finally, labeled break/continue has been supported in many languages for a long time (Java supported it in its 1.0 release!) and I have never seen it being considered harmful there.
Historically, goto was used where we would now use function calls, or braced if/else statements. (early programming language didn't even have these constructs)
The famous "Go To Statement Considered Harmful" paper from Dijkstra was published before C was created. The "goto" from C and C++ is mostly fine.
Deprecating 0-prefix octal literals is probably setting up many popular repositories for cleanup churn.
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2026/p00...
Seems like if a piece of code wants to compile free of diagnostics before and after C++29, it will need to avoid octal literals altogether, or maybe select the octal literal based on `__cplusplus` version, both seem ugly.
Ho-lee, guys. We just needed pre(x > 0)
A shame, but that's life.
Nearly 30 years after D:
The problem with contracts is that everyone has a slightly different notion of what contracts is supposed to solve, and it took years (really, over a decade) to come a consensus that almost everybody was happy with. Except for a small, vocal minority who are so upset over contracts that they're willing to spike the entire process to kill it. While this trip report is putting a positive spin on it, if you look at the dissenting vote counts in the plenary votes, they're not really going down, and I'm dubious that any of the dissenters were actually mollified by the latest changes. My suspicion is that C++26 NB balloting round 2 will come back the same way--failure, just with a couple thousand extra man-hours wasted on debating it.
As for why WG21 is so broken, well, I hope you'll forgive me a bit of rant:
It was one of the papers I was listening to during this meeting, about a new proposed standard library feature. And as the author is droning on about how good their implementation is, thanks to their thousands of lines of inline assembly, I just wanted to stop and shout at them "I don't give a flying fuck about your implementation." When you propose adding something to the C++ standard library, it's not your implementation that's going to be added. No, each of the standard libraries is going to reimplement it themselves because they have to--and given that all of their maintainers seem to be running on the ragged edge of burnout because the new library additions just keep coming, it's probably going to be the minimum work necessary to get something working.
And yet every library paper author comes in with their wistful stories of how good their implementation is, how nice it would be if everyone could take advantage of their work, and of course, since it's in the standard library, you get the best possible implementation, as if <linalg> is going to be implemented by a BLAS expert who's been studying it for 30 years and not some guy who hasn't touched numerics in 30 years but needs to check off a C++26 feature. Or hey, maybe even the compiler will get super special awesome sauce for optimization for the feature, because obviously that kind of integration is just free, right?
And yet... you just can't actually bring any of this stuff up to the committee. WG21 is so compartmentalized that trying to bring it up in any room is going to just result in "that's not relevant for this vote, bring it up in <insert study group here>." The only thing you can do is be a curmudgeon who votes against everything because it's really poorly motivated, and yet you'll be outvoted by everybody else who is bringing their own library features into the standard, which all of the same flaws and thus their authors are equally blind to the issues, so they'll vote in favor because it sounds like a really cool thing to add.
I also don't get what purpose does BLAS into the standard library.
Catching Bugs Early: Validating C++ Contracts with Static Analysis - https://news.ycombinator.com/item?id=50379283
Meanwhile, back in reality, the committee did its job: it addressed the NB comments, kept contracts, and C++26 is back on track. Imagine that.
Before: 114 in favor, 12 opposed, 3 abstaining
After: 111 in favor, 9 opposed, 8 abstaining
Fewer are opposed, but there are also fewer in favor and more abstaining. This is another gamble on getting contracts past the NBs.
What actually imperils memory safety in C++ is primarily cultural, not technical. In Rust, we have a lot of both stdlib and third-party library code that is properly designed and works well. Borrowck and the unsafe keyword are the primary technical enforcement of Rust's safety requirements, both of which could be grafted onto C++, but it probably would not do nearly as well of a job in C++ as it does in Rust.
Take, for example, the C++ contracts feature. The reason why the ISO vote on C++26 failed is because the ISO spec for contracts specifically allows compilers that do not enforce them. This is absolutely, obviously stupid; but it is also fairly typical of C++ culture. C++, being derived from C, is plagued with the notion that the programmer is ultimately responsible for performance, even though optimizing compilers have been a thing for decades and it is genuinely difficult to find performance improvements just by shuffling lines of code around. That's why they would consider it acceptable to add a safety feature and allow it to be turned off.
In Rust, you can't turn off the borrow checker. No, not even in unsafe code. Unsafe lets you lie a little to the borrow checker and type system - you can construct references from raw pointers or transmute types. But you are ultimately still beholden to those rules and you'd better make sure everything you do lines up right regardless of what happens in safe Rust.
[0] Rust traits can do inheritance-like things, so bindings to object systems with inheritance (such as GObject) will use them a lot. This still, however, results in a lot of boilerplate needing to be written - at the very least, every subclassable type needs its own trait for override implementation, etc.
[1] In Rust, all types are movable at any time. This makes self-referential structs impossible to implement safely, which means linked lists are a pain and async is basically impossible to do soundly. Pin<T> implements immovable types as a special kind of smart pointer, which is good enough to make async sound (albeit at the cost of a lot of compiler magic). But in C++ all types manage their own movement: this would be the equivalent of having a Move trait that gets called every time a struct gets moved.
[2] Specifically, "composition is preferred over inheritance." Inheritance requires developers invent a taxonomy of parent types and much early C++ code was plagued with nonsensical taxonomies.
I am all for having safer languages, but this advocacy line needs some reality check.
And you get to actually use it 5 years later too!
That last point is what makes C++ a different league than any other language. New features can be integrated because the language itself is built around extensibility. And yeah, the downside of this is too many features over time.
And, yeah, full disclosure, I LOVE C++.
I'd love an example of what you're talking about.
you have to somehow guarantee that across a big org/team working on a codebase. spoiler alert: it's not gonna work
when you can use GC'd languages for the most part and Rust for the hot paths, what is left for C++?
Personally, I want a safer C++, not the Rust Evangelism Strike Force.
For everything else, C#, Java, Swift, Typescript, and co already solve my safety problems.
Actually I think the more likely path forward is that compiler teams move gradually to Rust.
> Personally, I want a safer C++ I personally don't want to keep C++ or be constrained to a subset of the language that no one agrees what it is and has 10s of foot guns everywhere.
This criticism is as fresh as the people complaining that Java was in no way any safer than C/C++ because the JVM is implemented in C++ and might contain bugs.
I think were moving way faster that a lot of people anticipate in a direction where nobody really cares what is under the hood of Software. I think the only things that probalby will matter in the new reality are:
- Security - Usabiliity - Clean Processes - Speed - Funcionality - Bugfreeness
In this Context, the whole ordeal realy seems to be just a anachronism of the old reality.