As someone who writes high-reliability C++ but is completely outside the standards process, I see the issues with C++ Contracts. It isn’t clear that it solves a problem that anyone has in real codebases, especially after C++20 concepts.
If you were already writing high-reliability C++ then the benefits are difficult to quantify. If you weren’t writing high-reliability C++ then it saves you almost nothing over doing the standard idioms of high-reliability C++ that were already available to you at very marginally more cost. It does standardize expression of it in narrow cases but the payoff seems minimal.
Most of what C++ Contracts delivers is a mashup of what you can already do with constexpr and C++20 Concepts. I like reliability features but this feature, as delivered, looks fairly useless if you already use reliability features. A compelling standard would need to make much deeper guarantees out of the box. And the compiler can already see through most compositions of constexpr and C++20 concepts, which is already very expressive.
C++ Contracts looks a bit like a feature that was designed long before current standard features existed.
drivebyhooting 1 minutes ago [-]
Your comment just made me realize contracts is different from concepts (which are basically bounded genetics, right…?)
drivebyhooting 2 minutes ago [-]
I used to be a C++ programmer but I haven’t done it in a few years.
I pretty much do all my low level vibe coding in Rust. Is C++ still relevant? What prevents Rust from completely supplanting it?
LugosFergus 31 minutes ago [-]
I get why some folks would like to see contracts in the language, but C++ is also buckling due to the shear complexity that's getting tacked on to it. I'd rather see more proposals such as C++26's "erroneous behavior" that attempts to reign in the language's shortcomings.
airstrafer 4 minutes ago [-]
Agree. There's an argument that Contracts reduces the complexity of using the language because it offers a more readable alternative to template metaprogramming (also, it has better error messages). But the argument really falls apart when you review WG21's track record for other features.
Like for example, Coroutines were billed as an easier way to write concurrent code, but personally I think it completely failed and ended up being hopelessly complex and confusing. Modules are the same - superficially they make things simpler, but when people actually go to adopt it, the details are so complex that nobody bothers.
skrrtww 24 minutes ago [-]
Personally I'd like to see C++ chill out on new features and maybe sort out the shitshow that is char8_t and std::filesystem.
wahern 3 minutes ago [-]
Correct me if I'm wrong, because I don't follow C++ very closely, but based on previous discussions on HN, the opposition paper obliquely referenced in the blog post was presumably Bjarne Stroustrup's, who IIRC had already said he would work behind the scenes to make sure the final pro forma vote to standardize C++26 would fail.
SP3269 18 minutes ago [-]
Time to cancel the project. C++ acquired sufficient set of features over the years, becoming very PL/I-esque.
voakbasda 38 minutes ago [-]
I feel like this is a bellwether event for society at large. Growing impasses between more and more segments of society. Diminishing trust leading to the inability to reach consensus. Maybe it’s just me though.
SolarNet 32 minutes ago [-]
Perhaps it is, in this case it would be between money and everyone else specifically. Contracts is a pet project of Microsoft and the heavy money parts of the committee. They've basically shouted down the dissenters, hence the effectively unprecedented action of the rubberstamp portion of the process saying they dont think consensus was reached in a kosher way.
Maxatar 25 minutes ago [-]
No one who developed contracts works for Microsoft. Of the like 20 people who contributed to the feature, 4 of them work for Bloomberg, so you could maybe argue that Bloomberg has a vested interest in the feature, but that's really stretching things.
Support for contracts is fairly broad and spans numerous organizations.
hankbond 43 minutes ago [-]
Maybe my reading comprehension has just nosedived but I could not find where this article discusses what the heck Contracts refers to?
AlotOfReading 40 minutes ago [-]
You'll find plenty of info if you search for anything like "c++ contracts" [0], but the short of it is that they're just pre/post conditions on functions. Slightly improved assertions, basically.
cppreference is often a bit too technical for its own good :)
But I think there's a broader issue which is that if it took me multiple searches to find a good-enough visual "pitch" for what contracts look like in practice, its champions have not yet won hearts and minds - which brings us to the situation at hand.
bionhoward 2 minutes ago [-]
Oh im not a c++ guy but that actually looks pretty awesome because it’s like Hoare logic
SolarNet 37 minutes ago [-]
Its a very inside baseball article. Contracts is a proposed C++ language feature for improving programmable assertions of program state. E.g. a better c++ version of C's assert function. That in theory will improve both safety and performance by letting people add more complex assertions (e.g. pre/post conditions) to functions.
ranger_danger 52 minutes ago [-]
Maybe this time could be used to consider memory safety much more seriously.
EDIT: Would love to know why people are so angry about that?
SolarNet 29 minutes ago [-]
The issue that caused this to be voted down is often seen as a memory safety solution (not something I personally 100% agree with, but thats a broad view). And the rest of this release includes other memory safety work. And it was voted down and delayed for apparent political reasons (again not a view I agree with).
So most people will read your view as hypocritical/misinformed.
GalaxyNova 43 minutes ago [-]
Memory safety was solved in 1959 with the invention of lisp
youre-wrong3 3 minutes ago [-]
[dead]
vivzkestrel 41 minutes ago [-]
- since you are a part of the voting group, i have a doubt
- let us say tomorrow everyone were to consider removing all unsigned variables across c++
- what is the impact in terms of compatibility for all the old c++ applications which i believe would be millions of them if not billions?
- the reason i ask is they say do not unsigned anything as much as you can because overflowing the bottom below 0 is easy
- has there ever been any consideration to get rid of unsigned xyz in c++?
Rendered at 03:59:36 GMT+0000 (Coordinated Universal Time) with Vercel.
If you were already writing high-reliability C++ then the benefits are difficult to quantify. If you weren’t writing high-reliability C++ then it saves you almost nothing over doing the standard idioms of high-reliability C++ that were already available to you at very marginally more cost. It does standardize expression of it in narrow cases but the payoff seems minimal.
Most of what C++ Contracts delivers is a mashup of what you can already do with constexpr and C++20 Concepts. I like reliability features but this feature, as delivered, looks fairly useless if you already use reliability features. A compelling standard would need to make much deeper guarantees out of the box. And the compiler can already see through most compositions of constexpr and C++20 concepts, which is already very expressive.
C++ Contracts looks a bit like a feature that was designed long before current standard features existed.
I pretty much do all my low level vibe coding in Rust. Is C++ still relevant? What prevents Rust from completely supplanting it?
Like for example, Coroutines were billed as an easier way to write concurrent code, but personally I think it completely failed and ended up being hopelessly complex and confusing. Modules are the same - superficially they make things simpler, but when people actually go to adopt it, the details are so complex that nobody bothers.
Support for contracts is fairly broad and spans numerous organizations.
[0] https://en.cppreference.com/cpp/language/contracts
cppreference is often a bit too technical for its own good :)
But I think there's a broader issue which is that if it took me multiple searches to find a good-enough visual "pitch" for what contracts look like in practice, its champions have not yet won hearts and minds - which brings us to the situation at hand.
EDIT: Would love to know why people are so angry about that?
So most people will read your view as hypocritical/misinformed.
- let us say tomorrow everyone were to consider removing all unsigned variables across c++
- what is the impact in terms of compatibility for all the old c++ applications which i believe would be millions of them if not billions?
- the reason i ask is they say do not unsigned anything as much as you can because overflowing the bottom below 0 is easy
- has there ever been any consideration to get rid of unsigned xyz in c++?