News for hackers. Stuff that matters.
Re:C++26 Disapproved by drivebyhooting on Tuesday November 03, 2026 @10:58PM (#50361350)
Your comment just made me realize contracts is different from concepts (which are basically bounded genetics, right…?)
Re:C++26 Disapproved by stingraycharles on Tuesday November 03, 2026 @11:03PM (#50361382)
Concepts are evaluated compile time and make a lot of TMP more elegant. Contracts are runtime check, akin to assertions.

Phrased differently, contracts are to concepts what assert is to static_assert.

Re:C++26 Disapproved by mikepurvis on Wednesday November 04, 2026 @01:08AM (#50361968)
Too bad it couldn't have been contract and static_contract.
Re:C++26 Disapproved by rerdavies on Wednesday November 04, 2026 @05:26AM (#50363579)
[delayed]
Re:C++26 Disapproved by MFHava on Wednesday November 04, 2026 @06:27AM (#50364122)
Funny how often I read online that Coroutines are abandoned/useless, yet we ship products based on them and their application in our codebases grows continuously...
Re:C++26 Disapproved by rerdavies on Thursday November 05, 2026 @11:34AM (#50381190)
[delayed]
Re:C++26 Disapproved by MFHava on Thursday November 05, 2026 @02:38PM (#50383437)
> You can write your own library to use the C++20 feature, but the standard APIs are raw and brutally complex.

I wouldn't put it that way, but I've written several coroutine wrapper types at this point, so my perspective is certainly not objective here.

> Finally, C++26 provides std::execution, and std::task, which finally makes the feature usable with only standard C++ feature, and provides facilities for executing coroutines on thread pools, or message pumps. Significant features and problems have been deferred to C++29.

I remain unconvinced mere mortals will use std::execution.

It's a marvellous example of proving what is possible with TMP without needing language support.

Naturally, it's template hell - heck, the main designer even wrote a Visual Studio Extension to understand the cryptic error messages it can generate.

Apart from that: it interacts badly with Coroutines. Even though the author of std::execution::task reached quite a good design (there are some warts that could only be fixed by delaying to C++29 as it needed a change to the language feature), std::execution has poor support for it - which is unsurprising as key features of coroutines (like symmetric transfer) are not even discussed in P2300...

Re:C++26 Disapproved by rerdavies on Thursday November 05, 2026 @11:24PM (#50388180)
[delayed]
Re:C++26 Disapproved by MFHava on Friday November 06, 2026 @06:13AM (#50390921)
Maybe I'm too pessimistic.

WG21 could realistically fix some issues as DRs before S/R is even implemented (and marked stable) anywhere (they have done so before for other features - notably std::format).

Thanks to the C++29 fix you could even remove hacks like `co_yield execution::with_error` as a non-exception-based abort-mechanism inside task.

But ... the problem with symmetric transfer is deeply rooted in the design of std::execution and would require large surgery ...

Re:C++26 Disapproved by bluGill on Wednesday November 04, 2026 @09:05AM (#50365690)
Today the compiler is allowed to fail to compile any code that will break a contract. However the details of what this means is very complex, and the ability of compilers to detect things that break the contract at still evolving. Thus forcing anything on a compiler would force an easy subset on the compilers while shutting down innovation in what we can do in the future.
Re:C++26 Disapproved by rramadass on Tuesday November 03, 2026 @11:14PM (#50361435)
Concepts are for Types at compile time while Contracts are for Values at runtime.
Re:C++26 Disapproved by jandrewrogers on Tuesday November 03, 2026 @11:19PM (#50361455)
C++ concepts evaluate the properties of types at compile-time. You can inject arbitrary constraints on type properties anywhere in the code including conditional codegen. It is a way of asking if a type “can express this complex set of abstract things or has this enumerated set of properties” with almost arbitrary detail. They are extremely powerful in terms of expressiveness and specialization of code. Insanely good for performance and reliability engineering.

One of the best features to be added to C++ in many years.

C++ contracts are an attempt to bring C asserts into the C++ age. The weakness of C++ contracts is that they are mostly syntactic sugar over C asserts. If you really care about this type of thing, you probably already have a custom C++ assertion framework that is at least as nuanced if not more.

The promise of C++ contracts is that they can aid formal verification, which would be great. As delivered, it can’t do much more than was already possible, which will inhibit adoption.

Re:C++26 Disapproved by AlotOfReading on Tuesday November 03, 2026 @11:37PM (#50361548)

    The weakness of C++ contracts is that they are mostly syntactic sugar over C asserts. 
That's actually one of my issues with them. The evaluation semantics are much more complicated than C asserts because of the sugar, and why you would have to pay those costs isn't obvious at first glance. Lisa Lippincott's excellent talk on the design of contracts [0] is what switched me from a sort of neutral support to disliking it. I think it's a stupid place for the national bodies to draw the line though. std::regex is acceptable, but a nothingburger like contracts tanks the vote?

[0] https://www.youtube.com/watch?v=yhhSW-FSWkE

Re:C++26 Disapproved by jandrewrogers on Tuesday November 03, 2026 @11:43PM (#50361576)
To be clear, I have a lot of issues with the contracts proposal. I probably wouldn’t use despite living out on the standards frontier. I don’t even use C asserts already because they are not expressive enough in important ways. This proposal kind of reifies the inadequacies.

I think the risk is that C++ contracts become an evolutionary dead-end that hang around forever in code bases because they were standardized. It wouldn’t be the first time this has happened.

Re:C++26 Disapproved by randomNumber7 on Wednesday November 04, 2026 @04:05AM (#50363034)
What do you do instead of C asserts? Throwing exceptions?
Re:C++26 Disapproved by amluto on Wednesday November 04, 2026 @12:07AM (#50361692)
I maintain a codebase that I’ve migrated from C++98 to C++11 and all the way to C++23 and even a bit of draft 26 (the latter for some minor library improvements). Few things made me quite as happy as moving from using SFINAE to using requires clauses and concepts.

(IMO the single best improvements over the years have been atomics and maybe variadic templates.)

Re:C++26 Disapproved by jandrewrogers on Wednesday November 04, 2026 @12:16AM (#50361732)
I think you are right to position atomics and variadic templates as among the most consequential features of C++ in the last couple decades. It made an enormous number of things possible.

One thing I give the C++ feature gods credit for is recognizing material deficiencies in systems languages and unapologetically trying to fill those gaps starting with C++11. The addition of atomics, strict variadics, constexpr, lambdas, concepts, lifetime annotations, etc has been transformative for C++.

Re:C++26 Disapproved by aw1621107 on Wednesday November 04, 2026 @02:10PM (#50370140)
> lifetime annotations

Say what!?

Re:C++26 Disapproved by throwaway2037 on Wednesday November 04, 2026 @02:49AM (#50362532)

    > the single best improvements over the years have been atomics...
Of course, libatomic and friends have existed for a long time. Real question: Do you feel that the standardisation of atomics within the C++ base library is a material advantage over using libatomic? Also, maybe there are atomic APIs in the C++ base library that are better than libatomic. If so, please kindly share an example or two. I would like to learn more.

EDIT

I forgot to give a hat tip to your big upgrade from C++98 to C++23. In some projects, that can require an enormous amount of effort! Can you share a "stories from the trenches" that were difficult in that upgrade?

Re:C++26 Disapproved by pocksuppet on Wednesday November 04, 2026 @02:52AM (#50362550)
libatomic is a GCC implementation detail that implements atomic math operations that are not available on the target platform by using non-atomic math and compare-exchange. Are you sure that's the one you mean?
Re:C++26 Disapproved by bluGill on Wednesday November 04, 2026 @09:03AM (#50365664)
Standards work best when they can take a bunch of existing slightly different implementations and pick the best of them all, with input from people who understand the compromises, and with input from the real world experience of the different ways those compromises work out in the real world.

Atomics could work that way. However many other things cannot - we knew modules were a good idea, but they are a everything on a project must use them before anyone can benefit and so they were forever doomed to not be in widespread use until there is a standard. Even today we see adoption is slow because while there is a standard that works everybody is waiting on some other part to adopt before they can get any benefit. (and those who need to go first see the least benefit), but there are signs that things are moving.

Re:C++26 Disapproved by Shorel on Wednesday November 04, 2026 @03:16AM (#50362697)
I want to read your blog describing these experiences.
Re:C++26 Disapproved by YuechenLi on Tuesday November 03, 2026 @11:54PM (#50361627)
A concept is a compile time requirement that bounds templates which are the generics in C++, so you are close.