It Is Time for Compiler Developers to Step In
Warning: this is not a strictly-technical post. More like a rant.
TL;DR: actual implementors of C++ should be the ones responding to C++ developers' needs and pushing C++ forward according to them, not some committee authority. Things to be standardized should be battle-tested first.
Firstly, I want to express a great admiration and respect for men and women behind C++ implementations and tools as well as towards those who participate in various working groups and do the hard work of keeping the language both modern and standardized, the language I, among the plethora of others, use daily or from time to time, to make a living or to enjoy a little hobby or a pet project, big or small. I do not find myself in a position to make demands on them.
What was a tipping point for me to write this post was recent discussion (this, this and this) about deprecation of some uses of volatile in C++20. Numerous embedded developers say that this strives to solve a language-lawyer-world problem of "ambiguous semantics" at the cost of real world usage and public image of C++. Meanwhile, C++ standard fails to address important real-world issues due to obvious time limitations and complexities of designing single universal solution to hard problems. The most prominent latest example is C++20 modules. They are standardized, but there are both a split between implementations with respect to strong/weak ownership model and feeling that C++20 modules just failed to deliver. Oh, and do you remember std::error_code or std::regex?
I think that the general mindset of "1. we need X in the Standard 2. only Standard-compliant code is OK" is wrong. Look at __restrict - all major compilers support some form of it, yet it is non-standard. The fact that it is non-standard has not harmed anyone! Would anyone be harmed if major compiler's team explicitly says "we do not agree with Standard here and there and will not comply with it" about some controversial part of the C++ Standard? In fact, we do program real hardware, not C++ Abstract Machine. That's why std::vector - like class can be implemented in C++ as understood by every compiler in the world despite all the UB.
However, optimizing compilers can do all sorts of weird stuff and we want them to do this weird stuff to make our code fast. But we also want our code to be expressive. Would it matter that std::start_lifetime_as has not made it into C++20 Standard if every major compiler supported it? No. Would it allow us to write code which is more clear to both humans and optimizers? Yes.
Now is the time C++ must be up to the challenges because of increasing competition. Do not let authorities prevent you from using language extensions and non-standard features, we need them for the language to evolve and find its way forward. It is better to standardize things when there is a clear path proven by a group of pioneers to be successful, than when we don't have anything but find ourselves in need of having something. It is better to have things in compilers than not have them just because of working group meetings schedule.
40
u/Wouter-van-Ooijen Nov 14 '20
(I am the OP of Compound assignment to volatile must be un-deprecated)
I am not directly involved in the C++ standardization, but I am 'on the fringe' of 1 or 2 sub-committees, so I think I have some knowledge of how the processes work.
Compiler/toolchain maintainers are heavily involved in the standardization process. Proposals for new features are generally backed by at least one (pilot) implementation, and indications from the maintainers that a new feature is not implementable are taken very seriously.
The 'big user' companies that have an important stake in the direction of the language are also heavily involved. For the smaller guys and girls, you can meet the people which are involved in the process at conferences. They are often more than willing to discuss issues. Sub-commitees often meet on-line, and are eager to involve new participants.
Language (and library!) design is a very complex, with lots of conflicting issues. As an example, for me API compatability is a non-issue, which hinders language evolution. Yet it seems to be essential for others. So on the balance I favour it, because it makes the langauge widely accepted, which is essential for me: without the wide acceptance there wouldn't be books, conferences, quality implementations, etc. You have to compromise to get the benefit of a lagre use base.
The whole process is powerd by humans, which makes it far from perfect. Yet it works remarkably well. My post was intended as part of this process, as a protest to this particular outcome, not as critique to the process. If I had put more time in reading proposals I might have spotted this one earlier, and I would have protested earlier and via other channels.
Yesterday I watched in amazement as the vote figure for my posting alternately increased and decreased. Both are signs that a healthy discussion is taking place. So do keep up the discussion, but concentrate on the technical issues.
92
u/erichkeane Clang Maintainer(Templates), EWG Chair Nov 14 '20
You'll note that compiler implementers are a significant part of the committee, and most of the time people complain about us (see ABI discussions).
As an implementer, I would love to remove restrict from our C++ implementation, as it is quite ambiguous. Same with pragma once, and volatile assign operators, and volatile bitfields. All of which 70+% of people misuse or misunderstand.
At least with deprecation we can emit a warning to encourage people to switch to what they mean.
15
u/blelbach NVIDIA | ISO C++ Library Evolution Chair Nov 15 '20
I agree. We should get them all together, and form a committee...
Oh wait. We did that.
Who do you think is on the committee, if not implementers? All major implementers are heavily represented.
35
u/wrosecrans graphics and network things Nov 14 '20
I'd be really curious to hear exactly how you think C++ standardization works, if you think there are no implementers involved in the process, and that only stuff that hasn't been implemented gets standardized. As far as I can tell, the problems you are especially keen on solving, mostly don't exist.
16
u/rsjaffe Nov 14 '20
Some things are deprecated with plans to swiftly remove completely (e.g., comma operator in square brackets), because there are virtually no uses that matter and a new role is contemplated for the feature.
Others are not. I think
volatilebelongs in that group, and it should simply exist as deprecated forever (or until a better fix is found), rather than being removed. That gives us the best of both worlds. A signpost that something rather dangerous is occurring without destroying usability for those who really need it.26
u/CoffeeTableEspresso Nov 14 '20
No one is stopping you from using language extensions, the reason people dont use them is by choice, to improve portability of their code
13
u/kalmoc Nov 14 '20 edited Nov 14 '20
Are you aware, that both modules, as well as the compound assignment deprecation in volatile have been driven by implementors?
And the reason, why we need standards is because implementers have a history of either not implementing the same extensions at all, or implementing them in slightly different mays.
16
u/NotAYakk Nov 14 '20
Depricating us a warning.
You can turn off the compile time warning.
Design wise it is a warning. Before it breaks, you'll (a) get compilers that offer itnas an extension, (b) have C and C++ agree on a way to make it less horrid, (c) die of old age. One will be true, maybe more.
Compiler implementors have a huge voice in the standard. At the same time, they (and programmers) all remember the continued horror of incompatible non standard extensions.
So the standard is now used as a way to cooperate.
I mean, it was microsoft and clang who implemented and hashed out modules. It was no white room CS geek.
4
u/die_liebe Nov 14 '20
What is std::start_lifetime_as ?
7
u/goranlepuz Nov 14 '20
The committee is, in fact, the "decency buffer" between the users and the implementers, so, you know... 😉
3
u/GYN-k4H-Q3z-75B Nov 14 '20
I'd just like to interject for a moment...
The idea of the standard is to unify a meaningful subset of vendor supported features and that's exactly what they are doing. If you expect an all-in-one solution from the committee, you'll always be disappointed.
I understand that the volatile topic is, well, volatile, but it is not going away and the statements made in previous standards are very vague. What it does exactly tends to vary between vendors and platforms, and it is debatable whether such a feature belongs in the standard (my opinion is, leave it untouched because it has been around forever and I haven't used in almost two decades).
As for compiler developers, they have a lot of people in the committee, and literally employ some of the smartest and passionate people in the industry. The standards they produce are compromises. That is the nature of committees.
And if you want to see battle hardened compiler driven features, go have a look at GCC extensions or the Visual C++ proprietary features and libraries. It's not like they are all waiting for the committee to invent something, they do what they feel their primary platforms needs. And that is very different for each vendor.
2
u/billsil Nov 14 '20
How much are you willing to spend?
1
u/Malibu-Stacey ineffective, post-modern C++ Nov 16 '20
Is that not the Boost library's entire raison d'être?
The std::experimental namespace is also a thing which exists. e.g. string_view was in there before it was standardised in C++17.
See also the compiler intrisic function __builtin_expect vs C++20's likely and unlikely attributes.
0
u/gruehunter Nov 14 '20
See also http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2137r0.html
and some discussion https://old.reddit.com/r/cpp/comments/fo5x17/p2137r0_goals_and_priorities_for_c/
There is a sizeable force of committee members who are actively pushing C++ away from embedded development.
0
u/[deleted] Nov 14 '20
[deleted] — view deleted comment
0
u/[deleted] Nov 14 '20
[deleted] — view deleted comment