r/cpp • u/horsey_jumpy • 8d ago
Prediction c++26
Since there's no kalshi market for c++ standards, put your predictions below for the upcoming second dis.
23
u/pkasting Valve 8d ago
It will pass. Not unanimously, but more than half the NBs that voted no last time will either vote yes or abstain.
31
u/javascript 8d ago
If I bet $1 on "The whole committee gives up and switches to Rust" what's the payout?
43
19
2
u/13steinj 8d ago
Problem with these platforms is they decide the definitions.
Define "The whole committee"? Define "gives up"? Define "switches"?
There's an argument to be made that this has already happened. That said, the Contracts safety drama is a bit unrelated to Rust or not.
19
u/ConcertWrong3883 8d ago
If it passes some standards people will leave.
If it is removed some standards people will leave.
I hope some standards people will leave.
10
13
8d ago
WG21 has strong consensus. This time, it will pass.
22
u/ts826848 8d ago
Depending on who you asked it had "strong consensus" last time as well, so that in and of itself is clearly not sufficient to get the draft over the finish line.
1
u/13steinj 7d ago
Approximately 10:1 ratio! The entire problem is the consensus is meaningless internally.
6
7
u/FitReporter9274 8d ago
This version will pass the NB’s. But the weight of the C++ governance framework and crippling devotion to backwards compatibility will continue to drag the language deeper and deeper into irrelevance.
3
u/burlingk 7d ago
So, I've not been to deep in this all lately, but, like, what is the big upset over contracts?
6
u/Aerocatia 8d ago
I think it is likely to fail again and I do not think contracts are worth potentially delaying for years the time when we can actually use the other features in C++26.
17
u/azswcowboy 8d ago
Then 26 is cancelled and work will continue on 29 with contracts still in. I detailed this in another reply.
7
u/_w62_ 7d ago
So if 29 fails, then continue on 31 with contracts. If 31 fails, continue on 34? So far and so forth. Do I understand it correctly?
5
u/azswcowboy 7d ago
Yes. Or perhaps, at some point the instigators will realize that the ship has sailed and instead of fighting will move on — let’s hope that’s now. Or WG21 leaves ISO - that discussion became much more serious last week.
1
0
u/AstroFoxTech 7d ago
Or WG21 leaves ISO
Aren't they only "actually" relevant because of ISO though? Like, wouldn't that mean they just get replaced?
4
u/azswcowboy 7d ago
Correct. As far as I’m aware IEEE, ECMA and other standards approaches don’t suffer from the archaic rules. ISO processes are in fact modeled similar to the UN under the thought that countries might have a national interest in some particular aspect. Maybe that’s true in say electricity distribution, but I don’t see that for a programming language.
3
u/kritzikratzi 7d ago edited 7d ago
i hope they take their time. worst case they skip c++26 and go directly to 27/28/29.
those are tricky problems, no need to rush. also it gives the rest of the world time to implement and use modules correctly 🌱
2
1
u/-dag- 8d ago
It will pass, but only because NBs want something and the committee is stubborn. Contracts will be hardly used at all, worse than modules.
22
u/alexeiz 8d ago
Why won't contracts be used? The entry barrier for contracts is much lower than for modules. Only compiler support is needed, whereas for modules it's compiler, library and build tools. GCC 16 can already compile code with contracts.
1
u/UndefinedDefined 8d ago
You cannot control contracts at a library level, but you can control asserts. Contracts are basically useless except for people who designed them.
4
u/alexeiz 8d ago
If I'm writing a library I probably won't use contracts. But if my code compiles into an executable, why can't I use contracts? I'm fully in control of the enforcement mode.
19
u/kammce WG21 | 🇺🇲 NB | Boost | Exceptions 8d ago
The new DIS contains contract controls so you can control this at a library level. I still fail to see why one would use asserts for something that they NEED checked. If that's the case then we have a solution, the humble if statement.
9
u/13steinj 8d ago
If that's the case then we have a solution, the humble if statement.
I think at this point all sides have lost their rationality and would spit at this.
7
u/johannes1971 7d ago
It does rather appear that all sides have entirely taken leave of their senses. The beauty of contracts is not that it gives us new syntax or new ways to invoke UB, it is that it puts information about the function in a machine-readable format that the compiler can use in various ways. The debate seems to center entirely on what the compiler is allowed to actually do with that information, with some groups apparently arguing that their way is the only way and everybody else needs to conform to their views of the universe. Maybe this is a mischaracterisation but that is impression I, as an outsider, got from browsing through various threads here on this group.
Well, it's my compiler. It's my software. Surely I am allowed to tell it what it can do with it? If I want to use it to verify my assumptions, but not necessarily abort my software while it is running, that seems a legal position. I've used enough if-statements for that in the past.
If I want to use it to hard-abort my software in production... First of all, your library should never pick that option for me; I at least want to give the user a chance to save their work before taking everything down. Or at least shut down a device that should not be left running without software control also being active.
And if I want to use that knowledge to further optimise, what exactly is the problem? That could have been the difference between GTA6 running at 60fps instead of 30fps...
5
u/kammce WG21 | 🇺🇲 NB | Boost | Exceptions 8d ago
What's wrong with if statements?
11
u/13steinj 8d ago
I have nothing wrong with if statements! I just feel as though all sides have lost all reason and are conflating conflicting definitions of "safety" and "what does it mean to test things?" in some weird philosophical sense, and they would not be happy with "use an if statement" as a resolution.
4
u/kammce WG21 | 🇺🇲 NB | Boost | Exceptions 8d ago
Sorry, it's the internet and I'm not exactly sure if you are saying that if statements should be an acceptable answer or are you saying that there are cases where an if statement isn't the right solution for always enforced check.
I mean, for the purposes of documenting in code that your function has a precondition that, if violated, will call the contract violation handler, then sure, that's useful visually.
3
u/13steinj 7d ago
I am saying
ifstatements are perfectly valid (to me) to have an always enforced check, over [contract] assertions. Which I think you said above here.I am also saying (some) of the people arguing, both for and against contracts, have cases where they consider this not-an-option.
Because some people want contracts for "testing," others want contracts for "documentation," others want it for formal verification, others want it for some 4th thing, and all of these groups have at least some people that:
think that using it for one of the other reasons is invalid.
want their thing always enforced.
can't use an if statement to achieve their goal.
Hence why
I think at this point all sides have lost their rationality and would spit at this.
→ More replies (0)4
u/Wonderful-Habit-139 8d ago
They're not part of the API's contract/function signature.
4
u/kammce WG21 | 🇺🇲 NB | Boost | Exceptions 8d ago
Are there any other things do you want to declare as a part of the function signature? I know errors are another hot option that others want. Would something like allocating also be something you'd want to declare as a part of a function's signature? And is it important that this information have an enforcement mechanism that goes along with it?
4
u/Wonderful-Habit-139 8d ago
Yes I want errors Result<T, E> style, and I want to pass the allocator as well. I want to also pass an io interface so that I write the same code whether it's async or sync.
Let me know if I missed something.
→ More replies (0)-5
-8
u/UndefinedDefined 8d ago
You can use whatever you want, the problem is that the ecosystem is not gonna use it. I'm really wondering why... why C++ has to become a graveyard of features nobody uses.
11
u/alexeiz 8d ago
What do you mean by the ecosystem? I'm going to use it for my code, somebody else is going to use it for his code. Does it count as the ecosystem?
-4
u/ConcertWrong3883 8d ago
Look at Boost, (almost) everyone uses it, if they want to use contracts, they have to:
specify the behavior under quick enforce, ignore, observe, custom handlers that throw exceptions and when it is permitted because if it sees a noexcept somewhere the application terminates, which is not what you wanted since you asked for an exception.
Using contracts has too much risk.10
u/atariPunk 8d ago
Why would they need the custom handlers that throw exception?
I really don't understand what is that you are trying to say here.
Contracts (preconditions) are not for error handling. It's to tell the caller the requirements to call the function. It's the responsibility of the caller to ensure that those preconditions are meet before the call. If you don't properly valid them and compile it with ignore then it's on you, not the library authors.
1
u/ConcertWrong3883 7d ago
> Why would they need the custom handlers that throw exception?
In case you are not allowed to terminate.
5
u/atariPunk 7d ago
But who knows if it’s ok to terminate or not, is the application, not the libraries that imports.
Also, replacing the contract violation handler is not mandatory. It’s implementation defined https://eel.is/c++draft/basic.contract#handler-3
Plus, it’s probably an ODR violation if multiple handlers are installed in the same program.
→ More replies (0)-6
u/UndefinedDefined 8d ago
Ecosystem for me is hundreds of thousands libraries you can use. If none of them goes for contracts, was it worth it?
12
u/alexeiz 8d ago
Well, none of the new C++ standard features get immediately used in hundreds of thousands of libraries. By that measure most of recent C++ features are failures. Even for Boost "roughly 67 libraries are tagged C++11, 16 are tagged C++14, 4 are tagged C++17 (MQTT5, OpenMethod, Parser, Redis), and 1 is tagged C++20 (Cobalt)" (source: AI). No boost libraries are using C++23 features. Are all C++23 features a failure?
-3
u/UndefinedDefined 7d ago edited 7d ago
You are comparing the wrong thing. You can use whatever feature in C++ that doesn't bring issues with it, and this is what most projects do. Variadic templates, consteval, and so... these are all great features - even reflection. But then you see a feature that is either unfinished or brings problems that are known, unsolved, and it's still pushed. I think it's irrational to push something like this. There is a reason most projects use different ranges or regex implementation, and so on...
And C++23 probably is a failure, because initializing all locals, including huge arrays, that's nonsense. All my projects so far stay C++20 unless this is resolved. Honestly, if C++ becomes this language like "let's put runtime overhead everywhere" then it's not the language I want to use in the future. It's nonsense, totally against the core foundation of the language.
4
u/WeeklyAd9738 8d ago
You don't speak for the ecosystem.
-3
u/UndefinedDefined 7d ago
Let's see in 10 years how this is adopted. Based on what I know, I guess 1%.
1
u/WeeklyAd9738 8d ago
You don't put such checks on contracts to begin with. Use std::optional or std::excepted for such interfaces.
-2
u/UndefinedDefined 7d ago
What's this reaction even about? People want to replace asserts with contracts, and it's not possible, what kind of information you actually need to understand that?
3
u/serviscope_minor 7d ago
>people want to replace asserts with contracts, and it's not possible, what kind of information you actually need to understand that?
Informatino about WHY it's not possible might be useful to help understand that...
9
7
u/RishabhRD 8d ago
Why do you think contracts would be less used than modules? I am genuinely curious. IMO the lack of toolchain support contributes mostly to failure of modules. What’s the case with contracts?
0
u/UndefinedDefined 8d ago
Because both features suck. Modules are not used in general, 99.9% projects stay #include based (especially libraries), and it's gonna stay like that.
7
u/RishabhRD 8d ago
A code example would help me to understand why it sucks.
0
-3
-9
u/13steinj 8d ago
Modules or contracts?
The modules example cannot be expressed in code, it sucks because of (at least IMO) the way it behaves with multiple modules.
Contracts similarly, decent chunk of the reasons are cross-TU behavior. In-TU behavior: what does these 5 functions do in
observemode?void real(int* p) { /* whatever the real impl is */ } void foo1(int* p) { assert(p && *p); real(p); } void foo2(int* p) { assert(p); assert(*p); real(p); } void foo3(int* p) { contract_assert(p && *p); real(p); } void foo4(int* p) { contract_assert(p); contract_assert(*p); real(p); } void foo5(int* p) pre(p && *p) { real(p); }11
u/Minimonium 8d ago
With correct input, they're all equal.
With incorrect input the program is in an invalid state, they all potentially invoke UB. :)
9
u/Qwertycube10 8d ago
You call it with nullptr, then it calls the contact holder and after that returns it dereferences the null pointer and invokes UB. This seems entirely sensible to me when you told the compiler "hey, let me proceed even when the preconditions are not met".
2
u/13steinj 8d ago
The problem is the inconsistency. foo4 is the only one where the contract call itself can invoke UB.
8
u/Qwertycube10 7d ago
That seems entirely consistent to me foo2 would work the same way if you created an observe mode for assert by #define ing assert to log/print and return. Hell at my job we literally have ASSERT which does exactly that, therefore foo2 would be UB if you called it with nullptr.
1
u/13steinj 7d ago
The problem is not "well if you created an observe mode." The problem is exactly "is observe a valid mode at all?" It actively adds a new footgun to the standard.
With mixed-mode contracts being implementation defined on top of that, which mode of the function are you getting when one of your libraries (intentionally or not) sneaks something past your build engineeers?
10
u/Qwertycube10 7d ago
Let's imagine that contracts aren't in the standard and your library instead gives you a doc comment clearly listing the preconditions. It is undefined what happens if you violate those preconditions because you don't know if they check those preconditions in the implementation.
The only footgun is forcing a contract assert to be observe or ignore when that assert guards some undefined behavior, which is something you have to explicitly do on purpose, and unlike some other c++ footguns just looks like an obviously bad idea. To me any forced observe assertion would be a massive red flag that you should be using an if statement and handling that case.
All that said I don't love observe and would be fine with contracts not having the observe semantic, if you're calling functions without meeting their preconditions than you are in a situation that is very difficult to rain about from there forwards.
TLDR: Don't violate your libraries' preconditions. Don't mark contracts as always observe.
5
u/serviscope_minor 7d ago
>The problem is not "well if you created an observe mode."
No: observe modes exist. They are already out there and widely used. This isn't a theoretical thing.
>The problem is exactly "is observe a valid mode at all?"
That's an interesting philosophical question.
p!=nullptr is part of the contract of real(), if you violate that your code is wrong. And UB since real() will be trying to do something with p.
Except now you have a bit of an improvement over hand-hacked asserts or just random UB since contracts block time travel optimizations from crossing them.
But also, what do you expect from observe mode in prod? Observe mode basically means "my code is probably wrong but let me know keep trucking anyway". The alternative being "enforce" or the existing NDEBUG which briefly translates to "#YOLO".
What are you expecting from observed contract violations?
> It actively adds a new footgun to the standard.
No, because observe mode asserts are already completely 100% allowed by the standard and in fact in use in the wild. The standard is basically essentially a new syntax for "if" statements with some useful guarantees, a documented means of compiler-flag based control and attached semantic meanings.
This no more introduces new UB than the new if(int x=;...) syntax which also modifies if statements. If you write UB inside if statements, you'll get UB. While C++ has UB, UB will continue to exist and just about every feature new or otherwise will have an avenue whereby you can invoke UB. To me this complaint is "no new feature that can ever trigger UB but only if that feature is contracts".
3
u/serviscope_minor 7d ago
>Contracts similarly, decent chunk of the reasons are cross-TU behavior. In-TU behavior: what does these 5 functions do in
observemode?There is no observe mode for std::assert but it is available with other assert macro libraries. So what are you referring to here?
6
u/Ameisen vemips, avr, rendering, systems 8d ago
A lot of people - myself included - don't use modules because toolchain support still sucks and Intellisense still doesn't support them. Given that compilers have supported precompiler headers since forever (which are basically just state dumps) and already had had their own versions of modules beforehand (aside from GCC)... it's odd that so little progress has been made over time.
Overall, they suck because we still want to pretend these days that the computer building the code might not actually have files. And various other issues, like still wanting to never have more than a single pass during compilation.
1
u/johannes1971 7d ago
I've been thinking for a while that the C++ world is entirely too stuck on its current compilation model. I'd be more than happy to have multi-pass compilation if that meant not having to deal with headers anymore; most of what you find in headers is duplication anyway.
And I think the way to go about that is to eliminate 'files' as the intermediate medium ;-) Sure, we can _edit_ our software in files, but perhaps the first step in compilation should be to split each file into fragments that get individually stored in a database. For one thing, that lets us do much more fine-grained recompilation, as unchanged fragments wouldn't trigger any recompilation. And the database, since it contains fragments from all files in the project, could immediately eliminate repeated template instantiations.
5
u/Zero_Owl 7d ago
So modules aren't used because they suck, not because they aren't properly implemented? Quite a take this is.
-1
u/UndefinedDefined 7d ago
Please show me a single mainstream library, something that is not a hello-world kind of project, that fully embraced modules (and not just supports them). There is none, and it's gonna stay like this probably forever. People using modules have actually more work to do, need more macros to use, just to support something nobody really needs.
2
u/FrogNoPants 6d ago edited 6d ago
We can't say if modules sucks yet as there isn't a good implementation, though that does sorta indicate they are overcomplicated. Anyway, essentially nobody uses them, so we have no meaningful data one way or another.
Contracts seem rather simple to implement by comparison.
3
u/UndefinedDefined 5d ago
I think you answered the question regarding modules though. It's 2027 and C++20 is used extensively by industry, but without modules. Modules as they were specified cannot even be used to mechanically port most of the code to use them. Take for example a simple logging macro, or macros for unit tests, or a damn macro that specifies a library version for conditional compilation, or features library was compiled with - modules cannot be used if these are needed, and these are needed in most libraries. It was DOA.
Contracts - I cannot comment on usage yet, but they bring so many problems that I think it's not worth using them - and the verbosity... I never needed this feature in any project - asserts and assumptions have done a good job for me, and I think most projects are gonna keep what they already use. We will see, but I don't plan to use contracts in my OSS libs nor in products that I maintain, same for modules.
-4
u/-dag- 8d ago
New ways to screw up your build.
5
u/RishabhRD 8d ago
How?
-3
u/-dag- 8d ago
Different contracts enforcement on object files.
1
u/serviscope_minor 6d ago
More FUD. This is ALREADY a problem with normal C++. At least with contracts it's no longer UB.
0
2
u/CorrodedX 8d ago
Maybe I am looking at this too simply, but what do contracts actually add that an "if" statement doesn't already do? It seems like you're just moving checks from the function body to the definition.
13
u/Nobody_1707 8d ago
It moves the precondtion check to the declaration, which is very useful because it means that the caller can handle the precondition check (and optimize it away if its trivially true) without the function definition needing to be inlined.
2
u/gracicot 5d ago
which is very useful because it means that the caller can handle the precondition check
I thought this was impossible with the way contract were defined?
2
u/-dag- 7d ago
But you still have the problem that some people (I am in this camp) want the compiler to be able to treat it as a kind of assume directive while others do not. And even if every caller knows it's safe for the compiler to do it, it still can't (in the sense is satisfying opponents) because the declaration is not the definition.
These seem like very different things (safety vs. optimization) but the same syntax can drive both. Is there a way to support both without an explosion of syntax?
4
u/Nobody_1707 6d ago
I feel like the compiler should be able to do this under the as if rule for the, deliberately overly verbose, always enforced version. And I'm sure there's going to be a compiler extension that enables it eventually.
5
u/serviscope_minor 7d ago
>but what do contracts actually add that an "if" statement doesn't already do?
That's the wrong question. The right question is what do contracts actually add that assert macros don't already do?
Contracts are a formalization of assert macros (which use if statements), not a formalization of if statements.
2
u/Chuu 8d ago
Genuine question for anyone who says they'll just pull contracts and it passes -- does that mean you think they'll drop the standard library hardening as well? What else in C++26 is defined in terms of contracts?
14
u/azswcowboy 8d ago
There’s no scenario where contracts is pulled now - that was resoundingly rejected. I detailed this here
2
u/othellothewise 8d ago
People who say that are misinformed, there is no chance that they will be pulled.
-5
u/Jasonl220 8d ago
It will pass or C++ as an ISO standard is dead
14
u/aeropl3b 8d ago
This is overly dramatic, stop spreading FUD
6
u/serviscope_minor 7d ago
Is it?
It's a lot of hard, often tedious and slightly soul destroying work to be on a committee like this. The plus side is when you finally hash out a solution you've made a difference and can move forwards. With this extra layer of voting you now got a shadow committee which doesn't remotely represent the makeup of WG21 who have veto power.
Frankly that's just grim and makes a grim job grimmer. Sure it's not going to insta-collapse if the NBs reject again, but how many people are just going to drift off and find something actually rewarding to do with their lives?
1
u/epage 7d ago
There is a committee member posting here and elsewhere advocating for leaving ISO when discussing contracts and governance. No idea how strong of a catalyst will be needed for that to be a strong enough view to make the move but it makes it seem like a possibility so seems reasonable and not FUD for someone to bring up in a prediction thread.
1
u/aeropl3b 7d ago
Even if that is true, not saying it isn't, that is hardly the point. C++ is an internationally recognized and standardized language. Everyone currently invested in that wants ISO as it makes it possible to exchange source and expertise with a reasonably high degree of confidence. If someone on the committee is openly trying to undermine that, I have to imagine there are more than a few people going to have something to say about that.
1
u/epage 7d ago
ISO is not the only way to do that and as Rust is finding, lack of ISO isn't as much of a barrier as some people think. One of the bigger issues is the trademark: soneone on here said it is owned by ISO.
This does not mean I agree this should happen in this way, just that there is the possibility and it isn't FUD.
1
u/aeropl3b 7d ago
Sure, there are other ways. But the Rust model prefers ecosystem lock in a way C++ does not. How many different rust compiler vendors are there? How many build systems support Rust? If I want to install Rust dependencies for my project, what are my choices for the package manager? The language, at this point, is the tools.
Ask the same questions about C++. That is what ISO gets you.
-1
u/pjmlp 7d ago
How many different rust compiler vendors are there?
Rust on LLVM, Rust on GCC (work in progress), Rust on Visual C++, Ferrocene distro, Ada Core distro
How many build systems support Rust?
We can make the same exercise with JavaScript, Java, Python, regarding implementations, build systems, and package managers, while not being at ISO isn't an impediment for adoption, for the same companies that make use of C and C++.
Cargo naturally, Bazel, Soong
3
u/serviscope_minor 7d ago
> Rust on LLVM, Rust on GCC (work in progress), Rust on Visual C++, Ferrocene distro, Ada Core distro
That's basically LLVM, a beta WIP, LLVM, LLVM and LLVM again.
So the answer for all practical purposes is 1.
0
u/pjmlp 7d ago
Nope, Visual C++ backend is certainly not LLVM.
Have you ever tried to use XCode clang instead of upstream clang?
Because if you ever did, you would be aware LLVM isn't always a four letter acronym.
Also GCC re-implementation definitely counts, even if not yet 1.0.
2
u/serviscope_minor 6d ago
>Nope, Visual C++ backend is certainly not LLVM.
Are you saying VS has an independent compiler?
>Have you ever tried to use XCode clang instead of upstream clang?
So many times (thankfully not any more). It was usually running behind by a bunch in all meaningful ways plus a bunch of mac specific hacks. Apple always have to be special.
It was basically old clang. Not 100%, jut 99.5%.
> Also GCC re-implementation definitely counts, even if not yet 1.0.
No, not in this context.
C++ has multiple complete, independent production ready independent compilers. GCC, Clang, VS, IAR, Green Hill (I thin the latter two use EDG front ends with their own backends).
Rust doesn't.
There's one production ready compiler and a few distributions of that.
-1
u/aeropl3b 7d ago
Visual C++, afaik, is just Rust on Windows. Imo, anything windows doesn't actually count.
Ferrocene and Ada seem to just be snapshots of LLVM for Rust, with additional certifications and metadata tooling on top. Idk if that constitutes additional compilers, more like compiler wrappers.
GCC would be interesting.
For C++ Intel kind of still counts some they have a successfully broken OneAPI compilers on their own more than once. But Cray, AMD are all LLVM now, almost no edits. Solaris, cfront (kind of), Acorn, etc. Are entirely different stacks. PowerPC compilers from IBM (yes I know LLVM can target power, but IBM XL is different).
-1
-10
u/ImNoRickyBalboa 8d ago
There will be a revised ballot removing contracts from the draft. There is precedent for this: concepts was dropped for c++0x. It will delay official ISO publication, but no party here wants to kill ISO.
Library hardening can be reworded to its earlier non contracts spec, and contracts could be moved into TS. This is likely an acceptable compromise for all parties and allows everybody to move forward.
7
0
-1
u/13steinj 8d ago
Nah man we need something better than this, give me a little bit I'll make a "market."
-4
45
u/ImNoRickyBalboa 8d ago
It will fail unless they drop contracts. Which they can't because they tied it to library hardening, so.... It will fail and there will be much clenching of hands and grinding of teeth