r/cpp • • 6h ago

Prediction c++26

Since there's no kalshi market for c++ standards, put your predictions below for the upcoming second dis.

26 Upvotes

71 comments sorted by

9

u/[deleted] 5h ago

WG21 has strong consensus. This time, it will pass.

•

u/ts826848 2h 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.

5

u/pkasting Valve 4h ago

It will pass. Not unanimously, but more than half the NBs that voted no last time will either vote yes or abstain.

24

u/ImNoRickyBalboa 6h 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 

7

u/James20k P2005R0 5h ago

Removing the library hardening tie in isn't nearly as complex as it had been made out to be by some, there's earlier versions of the paper that were not based on contracts

https://isocpp.org/files/papers/P4446R0.pdf

1

u/ImNoRickyBalboa 4h ago

Yeah, there was some hyperbole (Tm) in that response 🙂 I added my more nuanced thoughts.

4

u/ImNoRickyBalboa 5h ago

Let me be more nuanced in what I think the actual outcome will be. The draft as initially proposed will/would fail, so there will be a compromise.

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

•

u/azswcowboy 3h ago

Uh, no. Assuming SC22 takes the wg21 recommendation a modified 26 with the changes from Brazil will go back to the NBs for approval. If approval fails the project will be cancelled and the committee will continue towards 29 with contracts still in. The covenor has already said that’s what he’ll do. The committee soundly rejected any removal of contracts and hated the TS option even more.

12

u/javascript 6h ago

If I bet $1 on "The whole committee gives up and switches to Rust" what's the payout?

25

u/Wonderful-Habit-139 6h ago

Programmer socks.

13

u/bearheart 6h ago

<dr evil voice> One MILLION dollars </>

0

u/javascript 6h ago

I'll take it

1

u/13steinj 4h 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.

9

u/ConcertWrong3883 5h 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.

4

u/Chuu 5h 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?

•

u/azswcowboy 3h ago

There’s no scenario where contracts is pulled now - that was resoundingly rejected. I detailed this here

https://www.reddit.com/r/cpp/s/CjEpA9E4zH

•

u/othellothewise 1h ago

People who say that are misinformed, there is no chance that they will be pulled.

5

u/Aerocatia 5h 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.

•

u/azswcowboy 3h ago

Then 26 is cancelled and work will continue on 29 with contracts still in. I detailed this in another reply.

6

u/-dag- 6h 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. 

10

u/alexeiz 5h 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.

2

u/UndefinedDefined 5h ago

You cannot control contracts at a library level, but you can control asserts. Contracts are basically useless except for people who designed them.

2

u/alexeiz 5h 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.

10

u/kammce WG21 | 🇺🇲 NB | Boost | Exceptions 5h 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.

3

u/13steinj 4h 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.

3

u/kammce WG21 | 🇺🇲 NB | Boost | Exceptions 4h ago

What's wrong with if statements?

6

u/13steinj 4h 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.

•

u/kammce WG21 | 🇺🇲 NB | Boost | Exceptions 3h 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.

•

u/Wonderful-Habit-139 1h ago

They're not part of the API's contract/function signature.

•

u/kammce WG21 | 🇺🇲 NB | Boost | Exceptions 1h 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?

•

u/Wonderful-Habit-139 57m 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

-3

u/UndefinedDefined 4h ago

I don't think we are talking about the same thing.

4

u/kammce WG21 | 🇺🇲 NB | Boost | Exceptions 4h ago

What are you talking about?

-4

u/UndefinedDefined 5h 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 5h 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?

-1

u/ConcertWrong3883 5h 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.

•

u/atariPunk 3h 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.

0

u/alexeiz 4h ago

I agree with you regarding the library code. But for application code (and maybe even header only library code) the contract behavior can be fully controlled, right? Therefore it can see contracts being used for the application code.

-4

u/UndefinedDefined 4h ago

Ecosystem for me is hundreds of thousands libraries you can use. If none of them goes for contracts, was it worth it?

8

u/alexeiz 4h 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?

•

u/WeeklyAd9738 1h ago

You don't speak for the ecosystem.

•

u/WeeklyAd9738 1h ago

You don't put such checks on contracts to begin with. Use std::optional or std::excepted for such interfaces.

6

u/RishabhRD 5h 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?

1

u/UndefinedDefined 5h 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.

5

u/RishabhRD 5h ago

A code example would help me to understand why it sucks.

1

u/Wonderful-Habit-139 5h ago

It's not the code that sucks.

-3

u/13steinj 4h 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 observe mode?

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); }

•

u/Minimonium 3h ago

With correct input, they're all equal.

With incorrect input the program is in an invalid state, they all potentially invoke UB. :)

•

u/Qwertycube10 3h 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".

•

u/13steinj 2h ago

The problem is the inconsistency. foo4 is the only one where the contract call itself can invoke UB.

3

u/Ameisen vemips, avr, rendering, systems 4h 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.

-2

u/-dag- 5h ago

New ways to screw up your build. 

4

u/RishabhRD 5h ago

How?

•

u/-dag- 3h ago

Different contracts enforcement on object files. 

•

u/NewLlama 3h ago

Modules are great, btw.

•

u/-dag- 3h ago

Never said they aren't. 

•

u/WeeklyAd9738 1h ago

I'm already using them with modules. C++26 contracts are awesome.

•

u/FitReporter9274 1h 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. 

1

u/13steinj 4h ago

Slopped up a market real quick for some lols.

https://13steinj.github.io/cpp26_predictions/

-3

u/Jasonl220 6h ago

It will pass or C++ as an ISO standard is dead

6

u/kitsnet 5h ago

Not so fast. We still have a few years to switch to C++20 in production.

9

u/aeropl3b 6h ago

This is overly dramatic, stop spreading FUD

-6

u/ImNoRickyBalboa 5h 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.

•

u/Minimonium 2h ago

Nah, doesn't work like this

0

u/13steinj 5h ago

Nah man we need something better than this, give me a little bit I'll make a "market."

•

u/CorrodedX 3h 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.

•

u/Nobody_1707 1h 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.