r/cpp • u/VinnieFalco wg21.org | corosio.org • Jan 28 '25
Networking for C++26 and later!
There is a proposal for what networking in the C++ standard library might look like:
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p3482r0.html
It looks like the committee is trying to design something from scratch. How does everyone feel about this? I would prefer if this was developed independently of WG21 and adopted by the community first, instead of going "direct to standard."
12
u/kalven Jan 28 '25
Are there code examples to look at? Like a basic server, a client etc.
-11
u/VinnieFalco wg21.org | corosio.org Jan 28 '25
Many ways to answer this.
Back to the Future: "Where we're going, we don't need code!"
Stonetoss: "Code?"
etc...
22
2
12
u/zl0bster Jan 28 '25
I dislike ASIO, I dislike PDF designs. ¯_(ツ)_/¯
So I would probably prefer for them to leave it alone and if something comes up based on S/R and gains wide adoption then standardize that.
I do understand it is a bit embarrassing that C++ does not have std:: networking, but I think it is better to leave it like this and let people pick the best library they can. S/R are too fresh to be building on top of them.
3
u/VinnieFalco wg21.org | corosio.org Jan 28 '25
Ah, "PDF Design" is what I refer to as "paperware." Thanks!
2
u/VinnieFalco wg21.org | corosio.org Jan 28 '25
What is a "PDF design?" I am unfamiliar with the term.
17
6
u/Natural_Builder_3170 Jan 28 '25
what's wrong with asio in your opinion, I used it once for a very small chat app with gtk and I had no problems. then again I'm not anywhere close to good in network programming so I don't know what to expect
→ More replies (1)4
u/azswcowboy Jan 29 '25
There’s a reference implementation being put in place as we speak https://github.com/bemanproject/net
Is it early, yes. Will it go to the standard soon, no. By the time it is adopted it won’t be a paper only design - already well past that. Dietmar did a cppcon talk where he live coded an http server with it. Study up, always possible you’ll end up liking it.
70
u/thisismyfavoritename Jan 28 '25
I would prefer if this was developed independently of WG21 and adopted by the community first, instead of going "direct to standard."
so ASIO?
5
12
u/je4d Jeff Snyder Jan 29 '25
Just a quick note on the title of this post, commenting as chair of SG4/Networking: It is already far too late for this to become part of C++26. Please don't get your hopes up!
The meeting in Hagenberg coming up in a couple of weeks is the deadline for C++26 features being approved by EWG/LEWG (see http://wg21.link/p1000), and this is arriving as a brand new large paper to SG4 this meeting. We'll be looking at it in Hagenberg, and if all goes well we'll continue to look at it at further meetings and it could be forwarded to LEWG, and from there it could become a candidate for C++29 inclusion.
3
-1
u/vulkanoid Jan 29 '25
What many of us are hoping is that something like this never makes it into the library. I hope there's people in the committee that steadfastly refuse to add this type of bloat.
9
u/LongestNamesPossible Jan 29 '25
Networking is bloat? The thing that every language and every OS has and a huge percentage of programs use is the bloat and not everything else in C++ like coroutines?
→ More replies (5)
29
u/PhilosophyMammoth748 Jan 28 '25
If ASIO goes to the std, I will use std.
If ASIO not goes, I will use ASIO.
10
u/madmongo38 Jan 30 '25
ASIO was well on its way to be standardised (badly, obviously because LEWG can't resist damaging good libraries during standardisation). Then Bryce Adelstein Lelbach, then poisonous then-chair, summarily killed it, and along with it something like 10 years of noble and selfless effort by Chris Kohlhoff.
I believe he did this in a selfish attempt to further his own career at Nvidia.
It was one of the most shameful incidents I witnessed in the LEWG meetings I attended. I was disgusted and filed an ethics complaint.
I saw no action taken by the ethics committee, so I walked away from involvement in C++ standardisation. I no longer saw any point in wasting time with it.
→ More replies (1)5
u/Ayjayz Jan 29 '25
If it's like all the other boost libraries that have been moved to standard, I will be happy for a while and use the standard version, until I run into all the drawbacks that inevitably plague the std version, and end up moving back to the boost version.
2
6
u/smdowney WG21, Text/Unicode SG, optional<T&> Jan 29 '25
ASIO is not going in the standard. Boost ASIO is fortunately still there.
It's not going to play nicely with any other async, ever, though.
4
u/YaZasnyal Jan 29 '25
What do you mean? You can totally make asio work with any other async runtime in a generic way so any possible completion handler can be used. Or you can write your own completion handler and asio will call your async runtime on completion.
5
u/Daniela-E Living on C++ trunk, WG21 |🇩🇪 NB Jan 29 '25
Even better: there is Asio without the Boost baggage, straight from the horse's mouth.
2
u/grafikrobot OPeNDAP/B2/EcoStd/Lyra/Predef/C++Alliance/Boost/WG21 Jan 29 '25
What Boost baggage are you referring to?
→ More replies (1)6
u/Daniela-E Living on C++ trunk, WG21 |🇩🇪 NB Jan 30 '25
René, I mean by that the simple fact that there is
boostify.plin the Asio sources that
takes the source files from vanilla Asio with its dependency on C++ standard library entities
inspects it for their occurances
replaces each of them with the Boost counterparts from a couple of Boost libraries
moves code from the
asionamespace into theboost::asionamespaceThis mechanical change
increases the dependencies from one library (the C++ standard library) to multiple libraries (the C++ standard library, the directly referenced Boost libraries, plus the indirectly referenced ones)
increases the length of almost all symbols
may cause more template instantiations of standard library entities
may incur unnecessary conversions and similar operations on the user side, or it may infect user code with otherwise superfluous Boost entities.
Hence, I go with the simpler, un-boostified solution in our codebase. Originally, I've used Boost.Asio a dozen years ago. Five years later, I discovered the vanilla one on Chris' website the link to his Github. This was the start of purging Boost.Asio from our codebase. For some time now, we only use the Asio module built from Chris' sources.
→ More replies (1)
17
u/ReDucTor Game Developer | quiz.cpp-perf.com Jan 28 '25
The standards committee is all about backwards compatibility, how about standardising around something Berkeley sockets like first which is already defacto standard then move towards async versions of that, then move towards TAPS.
This will be a much easier transition for existing code, rather then needing to make bigger design changes in existing applications.
3
u/pjmlp Jan 29 '25
This does not compile in recent C++ standards,
#include <new> // Type your code here, or load an example. char* allocate_buffer(int num) throw(std::bad_alloc) { return new char[num]; }ISO C++17 does not allow dynamic exception specification
-- https://godbolt.org/z/8PsdT77de
So not really all about backwards compatibility.
8
u/Ayjayz Jan 29 '25
C++ is a strange language. When you start out, you seem to be kind of obsessed with the standard library. The longer you use the language, the more you learn the disadvantages of it and you move to the high-quality 3rd-party libraries of the world.
1
u/pjmlp Jan 30 '25
Ironically before the first standard we had all C++ compiler specific frameworks, supporting all layers of application development all kinds of APIs, whereas the standard stopped at basic IO, data structures and algorithms.
Contrary to C, a POSIX for C++ never happened.
20
u/Beetny Jan 28 '25
Standardize on a package format or manager (as impossible as that is) and the rest of these high-maintenance features will come.
21
u/madmongo38 Jan 28 '25
Watching the WG21 trying to design something is like watching clowns running across a minefield.
2
u/pdimov2 Jan 29 '25
With the Benny Hill theme playing?
1
u/madmongo38 Jan 30 '25
Absolutely. In fact, being chased around by a group of half-naked women to the tune of Yakety Sax would be a lot more productive that spending time arguing irrelevant minutiae with the degenerates in LEWG.
2
u/smdowney WG21, Text/Unicode SG, optional<T&> Jan 29 '25
WG21 doesn't design anything, even when we're looking for something to fit a hole we see.
15
u/madmongo38 Jan 29 '25
I have attended and contributed to LEWG meetings. I have seen first hand how the language is “curated”.
I have seen nasty, politically motivated chairpersons push their agenda while unilaterally sweeping aside standard practice.
I have also seen the Committee sponsor individuals to create libraries from scratch.
WG21 is the reason that competitor languages are springing up.
You should all be ashamed of yourselves.
1
u/zl0bster Jan 29 '25 edited Jan 29 '25
Reason competitor languages are poping up is related to backwards compatability and lack of resources WG21 has. Even if everybody was super nice and professional there is no way that C++ can keep up with modern alternatives with limited resources and backward compatibility.
Now sure if they did not anger Google it would be much better for language, but idk that it would have stopped Rust offensive.
2
u/madmongo38 Jan 30 '25
The ISO committee had a 10 year head start. They sat on their hands and did nothing.
8
u/FriendlyRollOfSushi Jan 29 '25
Someone should sketch up std::first_person_battle_royale_shooter_with_microtransactions for C++29, I think.
Clearly too many people are hand-rolling inferior and buggy in-house implementations, and the lack of standardization in this area creates an unfairly steep learning curve for beginners.
10
u/mserdarsanli Jan 29 '25
Standardizing for first-person only would be wrong. I think a better API would look like:
std::nth_person_battle_royale_shooter_with_microtransactions(int n)3
2
1
2
u/No_Mongoose6172 Jan 29 '25
I understand why there’s interest on having those things in the standard library. Cross platform development is quite important nowadays due to market fragmentation in operating systems (it is becoming more common that desktop software targets windows, Linux and osx).
However, each operating system provides its own api, normally totally different or at least incompatible with the other ones (e.g. I’ve seen windows apis that are equal to the ones used in Linux/unix systems but they have capitalized a letter of each function forcing to use the preprocess or if you want to support both of them). That makes cross-platform libraries harder to maintain.
Maybe, a better solution could be having a standardized system abstraction library (independent from the standard library). That library would focus in providing basic building blocks for cross-platform libraries and software, without imposing abi stability or backwards compatibility
2
u/pjmlp Jan 29 '25
I guess some folks call that POSIX.
1
u/No_Mongoose6172 Jan 29 '25
POSIX support in windows would be great (without needing to use WSL). Unluckily, every standard outside the C++ standard tends to unsupported, making it more difficult to make programs that run in Linux and windows without modifying the code. If posix support was mandatory to be able to say that your operating system is compatible with c++, that may change
2
u/reneb86 Jan 29 '25
Networking in the standard library just sounds all wrong.
I imagine the standard library to be the most basic layer of functionality wrapped around the language features. Strings, containers, and the algorithms to use them well. Threads almost feels like an abstraction rather than a platform independent implementation. And its often omission from some chip toolchains only confirm this for me. Chrono was also an unexpected adventure for me. Now I half expect SI units to make it in there as well. But both Chrono and SI would feel like QOL improvements rather than something that needs to be standardized.
I feel the line of what should and shouldn’t make it into the standard library is unclear and arbitrary at the moment. Perhaps we should more clearly define what the standard library is meant to represent or accomplish.
2
u/elperroborrachotoo Nov 04 '25
Yeah let that be 3rd party libs, have the public battle out a winner, then integrate it. I just want a nice API and hope that I don't decide for the wrong lib/ Api
3
u/14ned LLFIO & Outcome author | Committee WG14 Jan 28 '25
It does have a reference implementation.
Standard Networking is not expected to have maximum possible performance. Therefore only code which doesn't care about performance will use it. I would wonder how much code that might be considering that BSD sockets are perfectly okay for non-performance use cases (and, in fact, are surprisingly performant even with BSD poll(), you need to be polling a good few hundred open sockets before performance begins to suffer).
I do think Standard Networking will be useful for illuminating what fixes need to be performed to WG21's S&R to implement i/o well.
9
u/oschonrock Jan 28 '25
I would wonder how much code that might be considering that BSD sockets are perfectly okay for non-performance use cases (and, in fact, are surprisingly performant even with BSD
poll(), you need to be polling a good few hundred open sockets before performance begins to suffer).I don't understand this sentence
2
u/14ned LLFIO & Outcome author | Committee WG14 Jan 28 '25
As CPU L1 caches have grown in size,
poll()can do its linear scan of the fd array far quicker than in the past. Indeed, other stalls on main memory generally hide the array scan overhead.If you write a benchmark comparing
epoll()topoll(), there really isn't much in it for the first few dozen sockets awaited. I haven't tested it to be sure, but I suspect it's only when the total memory touched by usingpoll()overepoll()exceeds the CPU's L1 cache do we see perf loss.In other words, unless your application uses more than a few dozen open sockets,
poll()is perfectly fine and you don't need anything fancier.4
u/cfyzium Jan 28 '25
Actually checking sockets status along with all the other sanfety and sanity checks it might need to perform probably dwarves the time needed to iterate over a contiguous array of ints, cache lines or not.
6
u/14ned LLFIO & Outcome author | Committee WG14 Jan 28 '25
Some people here may remember I proposed an alternative Standard Networking which came with TLS out of the box, but otherwise was bare minimum viable with nothing fancy. It came with a poll-only i/o dispatcher, and I had benchmarks showing it really didn't matter for low numbers of open sockets (especially with the TLS overhead) on any of the three major platforms.
I argued if you're writing something doing thousands of open sockets, you won't be using Standard Networking anyway. I lost all of those arguments, and my proposal like all my WG21 proposals died.
2
u/oschonrock Jan 28 '25
That's fine, and my practical experience agrees with that and suggests epoll is only necessary when you have at least hundreds, or even thousands, of sockets.
However, I was not questioning the technical merit of what you were saying.
Just that sentence makes no grammatical sense. There are several words missing or out of place, and I still can't make head or tail of it.
So I am not actually not sure whether you are making a case for or against p3482r0.html
3
u/14ned LLFIO & Outcome author | Committee WG14 Jan 29 '25
If there's anything I've learned after six years serving on WG21, there are many fine words said about serving the user base. But in terms of what actually gets standardised, we have been keen on design by committee and not on standardising what users actually do or want.
I therefore see ever more stuff from the committee not being used in serious code going forth. I don't think we are doing good engineering. So I'll be ceasing my participation in two meetings time, moving to the C committee where they only standardise what the user base actually does and wants.
7
u/cfyzium Jan 28 '25
Standard Networking is not expected to have maximum possible performance
Unless it is designed with at least a possibility to make an implementation that is no slower than a hand-coded one, it will be <regex> all over again.
3
u/14ned LLFIO & Outcome author | Committee WG14 Jan 28 '25
S&R's design makes it hard to not encode into every TU the S&R framework. I think changing it later will be very much like with regex i.e. you can't without breaking ABI.
It should be possible to implement Standard Networking in a way whereby the networking senders are behind a stable ABI boundary. But that will add runtime overhead, and it'll be an implementers choice in any case.
Very recent changes to WG21 S&R may have enabled receivers to fire when the i/o completes instead of having to wait for completion queue cleanup, but TBH I stopped paying attention since I decided to quit WG21. If they do have to wait for completion queue cleanup, performance will not be great on those platforms and backends where there is significant latency between i/o completion and completion queue cleanup.
6
u/SkoomaDentist Antimodern C++, Embedded, Audio Jan 29 '25
I would wonder how much code that might be considering that BSD sockets are perfectly okay for non-performance use cases
Probably 90%, if the api was good and easy to use.
This sub is extremely separated from what the reality is for the vast majority of C++ projects. Only a small fraction of (purely server) code is used in environments that have fast enough network that the C++-side performance makes any meaningful difference as long as the design is not truly awful from performance point of view.
0
u/jonesmz Jan 28 '25
Standard Networking is not expected to have maximum possible performance.
Ahhhh, so its useless? Nice.
10
u/tisti Jan 28 '25
So the majority of the standard library is useless for you?
4
u/jonesmz Jan 28 '25
No, but having networking capabilities that are this high level is useless to me.
1
u/ReDucTor Game Developer | quiz.cpp-perf.com Jan 28 '25
I would say lots of library functionality is useless, there is a reason why many large organisations have their own variations not bound by the ISO C++ where fixes cant happen because of ABI breakage fears.
1
u/Ayjayz Jan 29 '25
Kind of, yes?
vectoris pretty good, thealgorithmslibrary is pretty good, the rest of it is not really that useful in practice. It's kind of nice when you're writing toy programs, but when you're writing actual code you just never use it. Like, why would you usestd::unordered_mapwhenboost::unordered_mapis easy to use and is way better?
3
u/ApplicationAlarming7 Jan 28 '25
I’d welcome something that brings basic, easy to use network objects to C++ finally without needing to mess with conan and third party libraries. It doesn’t need to be the best and highest performance—that’s what third party libraries are for. Would love support for HTTP(S), and maybe even HTTP2, for making web service endpoints. Yes, you can manually implement it or use third party libraries but I always fear with third party libraries it’ll end up being like Casablanca which Microsoft abandoned.
Something like the Filesystems library, but for networking!
I don’t have confidence though. So ASIO, Boost and POCO it is.
-3
u/MarcoGreek Jan 28 '25
Why do we need to put toys in the standard library?
10
u/SkoomaDentist Antimodern C++, Embedded, Audio Jan 29 '25
Because that "toy" would be perfectly fine for 90% of use cases. The vast overwhelming majority of C++ projects do not deal with fast enough networks that the cpu performance would be any sort of bottleneck if the implementation isn't completely braindead.
The real problem is security, not performance.
8
u/smdowney WG21, Text/Unicode SG, optional<T&> Jan 29 '25
People are writing network services in python and shell script, after all. Even perl.
2
u/Ayjayz Jan 29 '25
3rd-party libraries work perfectly fine for 99% of use cases. I don't get what being in the standard gets you there.
5
u/SkoomaDentist Antimodern C++, Embedded, Audio Jan 29 '25
I'm not advocating for networking to be in the standard (see /u/stl's post which shows the real reason why it'd be a horrible idea). I am saying that performance is not a reason to avoid having networking in the standard.
1
u/MarcoGreek Jan 29 '25
So why then people avoid std::regex? I personally see the standard library as a library for classes which you need in interfaces. Networking is something you normally don't put in interfaces. So there can be different implementations.
Maybe something like Conan should be standardized?
1
u/smdowney WG21, Text/Unicode SG, optional<T&> Jan 29 '25
Because standardizing the existing practice turned out to be a terrible idea, and additionally is sitting on the space we could use for one that was workable.
1
u/equeim Jan 30 '25
I would argue that TCP and UDP at least need to be as close as possible to platform APIs, since they will be used for low level stuff and to implement other protocols. Something more complex that doesn't just wrap system APIs like HTTP can be "good enough" but I have doubts whether adding it to stdlib is a good idea.
1
u/rand3289 Jan 29 '25
I looked at it for 30 seconds and I don't like that they are dragging security and asynchronous operations into the proposal.
1
u/templarvonmidgard Jan 29 '25
IMO, a good metric for a standardized networking library would be checking if some trickier scenarios can be achieved with it. AFAICT from glancing over it, this wouldn't be capable of implementing RTCWEB, specifically the ICE part, because it uses connectless sockets. (Really, just UDP with sendto/recvfrom)
1
u/manphiz Jan 30 '25
I seem to remember that Bjarne stated in one of his papers that the committee should standardize existing implementations instead of resorting to design by committee, and ASIO was used as an example for the former. But do correct me.
1
u/farseeraliens Nov 05 '25
Couldn't hurt to have an abstraction of BSD socket in the standard library
1
1
u/chibuku_chauya Jan 29 '25
This sounds like a bad idea. I don’t think networking should be in the standard library.
1
u/oleksandrkvl Jan 29 '25
Stop polluting STL with something already implemented by a third-party library.
1
u/Annual-Version7395 Jan 29 '25
Something like https://github.com/ned14/llfio but for sockets should really be in the standard.
std::i/ostream sucks hard and fopen sucks as well yet they are still part of standard...
2
u/14ned LLFIO & Outcome author | Committee WG14 Jan 29 '25
You're very kind, but WG21 said no.
If something which looks awfully like LLFIO happens to turn up in a future C standard library ... well you never know. Perhaps even its TLS socket and networking implementation.
1
u/pjmlp Jan 30 '25
C has had their unofficial runtime, POSIX and Khronos, for this kind of stuff.
As it turns out most people using C also want the ecosystem it was born into.
1
u/14ned LLFIO & Outcome author | Committee WG14 Jan 30 '25
Sure but there's a portability problem there. I'm keen on more POSIX entering the standard C library. Functions like bsearch are useful everywhere.
I'm hoping to make a list of new stuff to bring in from POSIX and other unofficial popular places and see what WG14 thinks. I'll be starting with Freestanding compatible functions from POSIX see how the room reacts.
I think standards committee ought to standardise existing practice, not make it up. Functions like bsearch aren't ideally designed, but they aren't terrible either. There's an untapped gold mine in there in my opinion.
1
u/pjmlp Jan 30 '25
I don't think there is a need in more POSIX into ISO C standard library, POSIX has been after all the unofficial C runtime, and POSIX does require the existence of a C compiler, nowadays C17.
With exception on how things went down on Windows land, almost every non-UNIX OS out there grew a POSIX compatibility layer, due to the C developers expectation that where there is a C compiler, there is also POSIX support, and Khronos standards if the device has graphics support.
I am all for standardising existing practice, doing PDF design and implementing it afterwards hasn't been producing great outcomes.
1
u/14ned LLFIO & Outcome author | Committee WG14 Jan 30 '25
You obviously don't spend much time not on POSIX.
I do (and I'm not including Windows), and I'd like to see anything which isn't platform dependent from POSIX and the major libc's into the standard. Especially on Freestanding/embedded.
We'll see how the committee likes or dislikes the idea. For some of the common string functions not yet in the standard library, we've actively refused because those string functions are in our opinion especially awful. And I'd agree with that. But for stuff like hash tables, binary searches, possibly even random number generation better than
rand(), a lot of that stuff is very well understood by now. Warts and all. We'll see how it pans out, though I expect almost certainly the hardest part will be naming :)→ More replies (1)
-2
u/expert_internetter Jan 28 '25
Anyone who needs networking in a C++ program should just go straight to your OS's provided functions. It'll save a lot of heartache.
11
u/LongestNamesPossible Jan 29 '25
Good idea. They are all different though, so maybe someone could make a little header file that hides the fact that they are all different to give a single interface that works the same everywhere.
3
u/expert_internetter Jan 29 '25
This already exists in the form of ASIO which has been around for +10 years yet nobody is happy with it and the committee refused to standardise around it.
2
1
u/LongestNamesPossible Jan 29 '25
ASIO is a far cry from something like POSIX sockets. Building async into networking and mashing them both together would be a complex mistake to try to do in the standard library.
0
u/Mikumiku_Dance Jan 28 '25
Seems like this TAPS approach could coexist alongside a socket-based one. We could go from zero std::networking frameworks to 2 in one go! 😂
-3
u/weekendblues Jan 29 '25
Genuine question, how does anyone actually get excited about anything in these “standards” when even C++20 support is virtually nonexistent on every major compiler? It seems like the standards committee is just cranking stuff out with no regard for the fact that no one is actually implementing it.
I was able to use more of what’s in C++17 in 2015 than I am able to use what’s in C++20 in 2025. Do people not see the writing on the wall here? It doesn’t matter what’s in these standards if it’s going to actually end up being something we can use in gcc, clang, or msvc.
It’s starting to feel like C++ is truly a dying language and the effort that would be spent to bring these kinds of features to it is instead being spent to develop and migrate to alternative systems languages like Rust and Carbon. I don’t think the standards committee slamming in even more absurdly difficult to implement features is going to be the thing that reverses that trend.
6
u/tcanens Jan 29 '25
Virtually nonexistent? https://en.cppreference.com/w/cpp/compiler_support/20 is pretty green.
-2
u/weekendblues Jan 29 '25
This chart misleading and possibly intentionally incorrect. Many of these features do not actually work with the compiler versions listed in the chart and claims that they do are tantamount to gaslighting. Have you actually tried using these features? Many of them simply do not build, despite of claims of being supported.
5
u/sphere991 Jan 29 '25
Given that you think this is a reasonable claim to make
I was able to use more of what’s in C++17 in 2015 than I am able to use what’s in C++20 in 2025.
I'm certainly not about to give you any benefit of the doubt. The cppreference table strikes me as pretty accurate. What concrete example feature is claimed to be supported by a particular compiler version, but not?
1
u/pdimov2 Jan 31 '25
Some C++20 ostensibly core features don't work without stdlib support. For instance, even though
<=>is implemented on Clang 10, actually trying to use it (e.g.0 <=> 0) gives an error that you need to include<compare>, which you can't, because the default stdlib on Ubuntu 20.04 is libstdc++ 9, which doesn't have it.Similarly, sometimes coroutines work (in the compiler), but
<coroutine>isn't present, so they are unusable.And sometimes
char8_tis recognized, but there's nostd::u8string_view.So looking at the compiler table alone often doesn't tell the whole story.
0
u/pjmlp Jan 30 '25
Parallel STL for example, how can a compiler claim full support for C++20, if everything from C++17 is not fully available?
2
u/sphere991 Jan 30 '25
The claim is that the cppreference table for C++20 is misleading and intentionally incorrect. The parallel algorithms are a C++17 library feature.
-1
u/pjmlp Jan 30 '25
Last time I checked how evolution and grouping goes, C++20 standard includes everything from C++17 standard, with exception of C++17 features that have been explicilty removed from the standard in C++20.
A C++20 standard compilant compiler, with C++20 mode selected, has to be able to compile code making use of Parallel STL algorithms.
2
u/sphere991 Jan 30 '25
I don't know what you find so difficult to understand about the concept of the C++20 tables on cppreference only existing to illustrate support for the C++20 features.
Whether a compiler is "fully C++20 standard compliant" is completely irrelevant to the discussion. That's not at all the point. Are any claims of C++20 features being unsupported incorrect or are you going to make unhelpful comments?
→ More replies (1)3
u/tcanens Jan 29 '25
Have you actually tried using these features?
Not all of them, but the vast majority.
0
0
u/Similar_Childhood187 Nov 08 '25
I think introducing networking into the C++ standard is not a good idea, as it would increase compilation time and be useless for those who write programs unrelated to networking.
Take a simple example: Python, even though it is the most popular language for machine learning, does not include PyTorch or TensorFlow in its standard library.
1
376
u/STL MSVC STL Dev Jan 28 '25
Hold! What you are doing to us is wrong! Why do you do this thing? - Star Control 2
People often want to do networking in C++. This is a reasonable, common thing to want.
People generally like using the C++ Standard Library. They recognize that it's almost always well-designed and well-implemented, striking a good balance between power and usability.
Therefore people think they want networking in the Standard Library. This is a terrible idea, second only to putting graphics in the Standard Library (*).
Networking is a special domain, with significant performance considerations and extreme security considerations. Standard Library maintainers are generalists - we're excellent at templates and pure computation, as vocabulary types (
vector,string,string_view,optional,expected,shared_ptr,unique_ptr) and generic algorithms (partition,sort,unique,shuffle) are what we do all day. Asking us to print"3.14"pushed us to the limits of our ability. Asking us to implement regular expressions was too much circa 2011 (maybe we'd do better now) and that's still in the realm of pure computation. A Standard is a specification that asks for independent implementations and few people think about who's implementing their Standard Library. This is a fact about all of the major implementations, not just MSVC's. Expecting domain experts to contribute an implementation isn't a great solution because they're unlikely to stick around for the long term - and the Standard Library is eternal with maintenance decisions being felt for 10+ years easily.If we had to, we'd manage to cobble together some kind of implementation, by ourselves and probably working with contributors. But then think about what being in the Standard Library means - we're subject to how quickly the toolset ships updates (reasonable frequency but high latency for MSVC), and the extreme ABI restrictions we place ourselves under. It is hard to ship significant changes to existing code, especially when it has separately compiled components. This is extremely bad for something that's security-sensitive. We have generally not had security nightmares in the STL. If I could think of a single ideal way for C++ to intensify its greatest weakness - security - that many people are currently using to justify moving away from C++, adding networking to the Standard would be it.
(And this is assuming that networking in C++ would be standardized with TLS/HTTPS. The idea of Standardizing non-encrypted networking is so self-evidently an awful idea that I can't even understand how it was considered for more than a fraction of a second in the 21st century.)
What people should want is a good networking library, designed and implemented by domain experts for high performance and robust security, available through a good package manager (e.g. vcpkg). It can even be designed in the Standard style (like Boost, although not necessarily actually being a Boost library). Just don't chain it to:
Being implemented by Standard Library maintainers, we're the wrong people for that,
Shipping updates on a Standard Library cadence, we're too slow in the event of a security issue,
Being subject to the Standard Library's ABI restrictions in practice (note that Boost doesn't have a stable ABI, nor do most template-filled C++ libraries). And if such a library doesn't exist right now,
Getting WG21/LEWG to specify it and the usual implementers to implement it, is by far the slowest way to make it exist.
The Standard Library sure is convenient because it's universally available, but that also makes it the world's worst package manager, and it's not the right place for many kinds of things. Vocabulary types are excellent for the Standard Library as they allow different parts of application code and third-party libraries to interoperate. Generic algorithms (including ranges) are also ideal because everyone's gotta sort and search, and these can be extracted into a universal, eternal form. Things that are unusually compiler-dependent can also be reasonable in the Standard Library (type traits, and I will grudgingly admit that atomics belong in the Standard). Networking is none of those and its security risks make it an even worse candidate for Standardization than filesystems (where at least we had Boost.Filesystem that was developed over 10+ years, and even then people are expecting more security guarantees out of it than it actually attempted to provide).
(* Can't resist explaining why graphics was the worst idea - it generally lacks the security-sensitive "C++ putting the nails in its own coffin" aspect that makes networking so doom-inducing, but this is replaced by being much more quickly-evolving than networking where even async I/O has mostly settled down in form, and 2D software rendering being so completely unusable for anything in production - it's worse than a toy, it's a trap, and nothing else in the Standard Library is like that.)