r/cpp • u/Specific-Housing905 • Feb 26 '26
The Joy of C++26 Contracts - Myths, Misconceptions & Defensive Programming - Herb Sutter
https://www.youtube.com/watch?v=oitYvDe4nps&t=1s
75
Upvotes
r/cpp • u/Specific-Housing905 • Feb 26 '26
56
u/v_maria Feb 26 '26
yo i thought primeagen was presenting on C++ con
30
u/VictoryMotel Feb 27 '26
Now now C++, you can't have any more features until you finish the features you already have.
27
u/JuanAG Feb 26 '26
The "Myth" that contracts are broken is true and not a myth
At 37:00 https://youtu.be/oitYvDe4nps?t=2231
"Look your compiler, you should be able to do it" ... Yeah, and i now have to be checking my compiler on every version update to just know if the code will break or no (depending on if you have or not multiple TU support from it)
The "be aware" warning on the slide just says all, no, i refuse any longer to do the compiler job, i am using tools that do for me and there is 0 chance i will go back, i got tired of UB/corner cases everywhere and in this case we cant blame C or backwards compability
.
Joy wouldnt be the word i would use to describe a half broken feature...
10
u/[deleted] Feb 26 '26
the primeagon has hella influence ngl
7
u/Nobody_1707 Feb 26 '26 edited Feb 26 '26
So, what exactly is the benefit of C++26 contracts over defining something like:
4
u/_a4z Feb 27 '26
If the contract feature were so great, it would not need all the propaganda and advertising that is put out for it. The promise that this is version 1 and that there is more to come is more of a thread than an optimistic view of the future of C++. But at least, it's an argument that before 32, nobody needs to look at it.
The real sad story in this context is all the features that would have brought real improvements for everyone, like pattern matching, string interpolation, and others, that were down-prioritized because contracts took too much (and still do) of the committee's time.
2
u/RumbuncTheRadiant Mar 02 '26
So often discussion of contracts degenerates because everybody thinks they know what they are... but when you really really drill into to it, everybody has a different meaning.
One doesn't need to read far in this thread to see it happening here as well.
This talk https://www.youtube.com/watch?v=gtFFTjQ4eFU sums up the problem very well.