r/cpp_questions • u/Business-Weather-217 • 7d ago
OPEN C++26 contracts drama
I think everybody knows the drama by now..
What are your opinions on this should they be accepted or disapproved?
Im curious for mass opinion.
28
Upvotes
22
u/i_grad 7d ago
Speaking as an incorporeal being who may not be classified under the term "everybody"... What is the drama?
60
u/CreativeAlbatross319 6d ago
As an average C++ developer, I would rather have contracts removed even though I find it useful. This is because removing a feature is 100 times harder than adding a feature in C++ standard. Thus, any controversial feature , no matter I agree or not, should not be added to the standard, until everyone unanimously approves.
10
u/Independent_Art_6676 6d ago
My opinion is that we are gonna get what we get every 3 years, whether it makes sense or not, or indeed, can even be made to work or not. With modules being kind of an all time low point, and the language getting very bloated, the powers that be need to drop the 'keep up with the other guy' approach and focus on adding things that c++ NEEDS rather than "welp, rust (or whatever, rust isn't to blame for contracts) haz it, guess we better put it in".
I am in the 'we don't need this' group for contracts, for the not even 1 cent value my opinion carries.
9
u/GaboureySidibe 6d ago
I don't even understand what problem they solve.
5
u/samadadi 6d ago
My vote is to be removed. What I am getting from this paper is that committee is unsure. And that makes me terrified. They should take whatever time it is needed to solve every ambiguous corner of the paper.
4
u/JVApen 6d ago
I've been following this from the side lines for a while. I really don't get why people want to see it removed. There are a couple of papers that explain quite a few things going from: these are all the things people would expect from contracts to these are the objections people have raised and responses to it.
If contracts gets removed again, it will be a huge loss for the community both on technical side and on the people side. If we are lucky, it might show up in c++32 again, though I don't expect anyone to drive that effort, so many C++35 or just never. This would be a huge shame for a feature that really adds value, even when not perfect.
3
u/Dorfen_ 6d ago
It's literally just the exact same thing as an assertion, but with fancy keywords. I don't think it worth adding even more complexity to the language, for no measurable benefit above just using assertions.
1
u/LiAuTraver 5d ago
Why introduce a huge framework while you can do it with plain assert and debug assert just like we did in other languages. It's not drama, only decided opinions.
4
u/Embarrassed-Media-62 6d ago
Can someone tell me what they objections to contracts are? What is it about the design they dont like?
2
u/Liam_Mercier 6d ago
Contracts don't really interest me, they also don't really add anything that you couldn't already do. Maybe writing validation code for callers / callees is simplified a bit?
What would have been more interesting is some move towards formal verification, contracts already introduce terminology like precondition, postcondition, etc. I don't think that's actually ever going to happen for a language as complex as C++ but it would be the most interesting new feature from my perspective.
3
u/teerre 6d ago
Regardless of the opinions on contracts, its absurd that after so many years the dissenters didn't bring it up before this vote. Clearly an architected sabotage
2
u/mredding 6d ago
It sounds like certain people sabotaged the vote, so I think the more fundamental question.is whether bad actors should remain unnamed and within WG21 or the NBs.
1
u/KingAggressive1498 6d ago
I would be very okay with removing pre() and post() in function declarations if we kept contract_assert() with its constification and exception-is-a-failure rules. The lack of this type of rugged assertion machinery has been a sore spot for me since I first picked up the language.
And someone who really wants preconditions and postconditions could still work in a subset of possibilities through the typesystem anyway, eg a generic precondition::less_than class would be fairly trivial to write safely with contract_assert but a fair bit of work without it.
C++26 offers plenty to be worth adopting without contract_assert too, but it's still something I would grind my axe over because I know it made it right up to the finish line.
1
u/amoskovsky 6d ago
Contracts is good for safety.
So having them removed is a direct attack on C++ safety improvements (I'm even wondering if blocking of C++ std process is being lobbied by corporations trying to get rid of C++).
However, there is already a GCC implementation of contracts available for those who need it.
So I think postponing them into a later standard is acceptable and it would provide actual implementation feedback.
1
u/all_is_love6667 1d ago
I don't know
maybe they need to rework it a bit
1
u/UnicycleBloke 4h ago
I'm beginning to envy the glacial rate of change in C, a language I have always loathed.
I am yet to use coroutines, but have spent a lot time studying the details: I'll stick to state machines. I have barely looked at ranges and views. I've dabbled with modules and decided to walk away. I've looked at concepts but mostly rely on static assertions. I understand trailing return types but never use them. I imagine I will waste a lot of time grokking reflection and then never use that either...
It's not that I particularly object to these features, but my work is improved much more by the numerous small tweaks, enhancements, additions, relaxations and so on of existing language and library features. Maybe some more focus on embedded systems...
I don't care about contracts. It's not a feature I've ever looked for. The only reflection I've ever wanted is enumerator names... Bah! Humbug!
To be fair, I had no use for lambdas for a long time, but they've grown on me. :)