3 ms·
Exciting as it may be, to be fully available for portable codebases maybe around 2030, given the current velocity of compilers adoption of ongoing standards, ev
by pjmlp 2y ago
Exciting as it may be, to be fully available for portable codebases maybe around 2030, given the current velocity of compilers adoption of ongoing standards, even among the big three.
As of today, C++17 is the latest one can aspire to use for portable code, and better not making use of parallel STL features.
- Kelteseth 2y agoI would argue C++20 is totally fine. MSVC does not yet has a C++23 flag and it will be internally replaced with 'latest', aka some C++26 features, when you use it. This took us by surprise, because they deprecated some enum conversions and thus our clang-cl CI failed for openCV, with the latest llvm. I still fail to understand why enabling a specific C++ version, automatically means that it is considered stable. At least give use C++23-experimental or something /rant.
- pjmlp 2y agoWriting C++20 code without modules, ranges, or concepts, is like, what is the point. Naturally when code portability doesn't matter, it is another thing. All my C++ side projects are written against C++latest on Visual C++, and make full use of modules and concepts.
- einpoklum 2y ago> Writing C++20 code without modules, ranges, or concepts, is like, what is the point. * std::span is in! https://stackoverflow.com/q/45723819/1593077 https://stackoverflow.com/q/45723819/1593077 * Designated initializers (like in C99) * Spaceship operator and default comparison ops * More language constructs can be constexpr'ed * Better structured binding * using on enums * Don't need to say "typename" as much :-) * Bunch of minor improvements to the standard library Note I did not say coroutines. I still don't understand how that boondoggle made it into the language the way that it has.
- pjmlp 2y agostd::span is a trap, gsl::span should be used instead, unless one is willing to enable checked collections on the respective compiler. As for the rest, the point stands regarding portable code across various C++ compilers. I agree on the co-routines, while I know C# co-routines relatively well, and the C++/CX stuff that was used as inspiration for Microsoft's initial proposal, they are a bit of a mess, when key WG21 members also don't fully grasp how they have to be implemented, and we need two hour sessions on C++ conferences to go through "hello world" kind of implementations.
- deleted 2y ago[deleted]
- vitus 2y agostd::span is no more a trap than the rest of C++'s standard library in that regard. Are you also eschewing std::vector and std::string? std::string_view, std::array? I suppose C++26 brings std::span::at, although exceptions are a different can of worms.
- pjmlp 2y agoSome errors are too late to fix, span was originally bounds checked when proposed. Pre-C++98 compiler frameworks used bounds checking by default. And yes, if I am calling the shots, bounds checking are enabled in release builds. Never has been a problem other than performance cargo cult folks. Thankfully governments are making this less of discussion.
- vitus 2y ago> And yes, if I am calling the shots, bounds checking are enabled in release builds. No disagreement there. But I'd prefer to turn it on across the board via compiler flag rather than pull in a special library for it and remember to use that library consistently. And if that's the case, I don't see std::span as any more problematic on this front than the rest of the standard library. (Yes, I know, GSL isn't really a special library on Windows. But anywhere else, it is.)
- forrestthewoods 2y agoModules are DOA and won’t happen even by C++32
- pjmlp 2y agoIf portability isn't a concern, VC++ with MSBuild, or clang with CMake (without header units), are pretty much quite usable. However I do agree with the feeling for large scale adoption. The way modules and concepts went down, or the way GC API got added only to be removed, or ongoing contracts discussion, has pretty much settled my opinion that WG21 really needs to adopt the same approach as other programming language communities. Papers without working implementations for community feedback shouldn't be accepted at all.
- bluGill 2y agoThat is generally the case. Modules had two different proposals with thair own implementation and they choose the one microsoft iplementet after debate which is why msvc had modules from the start.
- pjmlp 2y agoThe missing part of that story is that they ended up compromising on a third approach, without build tools support, with the hope everything would be quickly settled after shipping the standard. Apple and Google kept using clang header modules, switched focus to their C++ replacements, and clang transition to C++20 modules languished until a few heroes stepped in to do the work. Meanwhile GCC is still work in progress. And build tools are still a mess, even cmake doesn't have yet a story for header units. As for Microsoft, except for Office, there isn't a single Microsoft product, especially C++ SDKs, that make use of modules in any form. This is quite different from how other programming language ecosystems migrate features from preview into stable.
- chipdart 2y ago> However I do agree with the feeling for large scale adoption. I think that everyone has misguided and naive expectations on how such a radical change would roll out to production software. Changing dpendency management and updating build systems is a hard sell for professional projects delivering production software. It's the most radical change in how you're software is built with zero upside in terms of features. Best case scenario your software works as it always did. Worst case scenario you wasted tons of developement effort to retool and revamp your whole CICD pipeline just to break your project. Hard sell. I mean, why do people think so many projects are still stuck with C++11?
- dxuh 2y agoConcepts are well supported and have been for a while and they are so great. Those alone make C++20 worth it. But Coroutines also make it worth it, if you build software that can use them well. Designated initializers change how I write code (for the better - by a lot). And of course std::span.
- pjmlp 2y agoPortable code across various C++ compilers....
- chipdart 2y ago> Writing C++20 code without modules, ranges, or concepts, is like, what is the point. The point is, obviously, use other features introduced in C++20 and not have to deal with artificial restrictions when you opt to onboard onto whatever feature you'd like. To me C++20 has more to do with designated initializers than modules, for the very obvious reasons. It's fine if you take a pass at an upgrade and prefer to take the hit of migrating through a bigger delta, but framing this thing as "what is the point" is indeed missing the whole point.
- kevin_thibedeau 2y agoconsteval is worth it alone.
- ratmeadow 2y agoI propose a theory/rule that every new C++ version takes superlinearly longer than the previous to implement. Currently the Standard is at C++23 and we are ~4 years behind (C++20 is not portable, as you say). At this rate, by the time we get to C++40 or 50, compilers could be behind to a comical degree, like 15 years. Personally I am interested to see how many unimplemented features it takes before the Committee takes action. (I would find it superbly amusing if they simply did nothing and we got to a point where no new C++ features ever became available.)
- layer8 2y agoYou may have missed that C++97 took six years to fully implement, due to export, and only a single compiler actually ever implemented it.
- pjmlp 2y agoThis is why I have the very unpopular opinion that C++26 is going to be the very last standard that anyone cares about. It will be good enough for the industry use cases where C++ matters, while other languages keep slowly eroding C++'s market share. Example of such scenario, LLVM, GCC, JVM, V8, CLR are all currently settled on C++17, maybe eventually C++20, they don't need any additional features, for their C++ use cases, other than having GCC and clang keep up with ISO. How many people care about COBOL or Fortran 2023 standards?
- fweimer 2y agoGCC is still expected to bootstrap from a C++11 compiler. (For self-hosting compilers, language version choice is not only about useful language features.) The built compiler defaults to C++17. I think the remaining obstacle before moving to C++20 by default is more experience with (and fewer bugs in) the support for modules.
- superkuh 2y agoI'm with you, but in my experience you have to go further back still to C++11 before it's actually compileable on most distros. And even there the atomics stuff is not really fully supported everywhere.
- MathMonkeyMan 2y agoI've been writing in a certain C++17-like subset of C++20. I like designated initializers, and there are probably some other syntax and library conveniences from C++20 that I'm taking advantage of without knowing (std::string_view::starts_with?), but the rest is just C++17. One notable exception is that I did a project with C++20's coroutines recently.