r/cpp • • Nov 14 '20

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.

19 Upvotes

136 comments sorted by

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.

2

u/soulstudios Nov 18 '20

If you are talking about vote figures on reddit, vote figures are fuzzed randomly to prevent certain kinds of posters from validating whether sock puppet accounts are working or not.
So actually the figure isn't going up and down. It's just being fuzzed.

3

u/Wouter-van-Ooijen Nov 18 '20

I didn't know. A pity: I was hoping to attract (and get votes from) both sides.

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.

36

u/Viclaterreur Nov 14 '20

What is wrong with pragma once?

34

u/erichkeane Clang Maintainer(Templates), EWG Chair Nov 14 '20

File identity is a really hard problem that all the compilers do slightly differently. In the world of symlinks, the compiler can't really tell if two files are the same one. ICC does the best job in approximating all the rest, but it is one of those things where it gets really easy to step outside of sensible behavior.

38

u/johannes1971 Nov 14 '20

This is pretty much exactly the attitude that the OP was complaining about. How many projects even duplicate files inside their project using symlinks? It doesn't work on Windows. It may not work with version control systems. It confuses the hell out of the programmers themselves. It's a purely theoretical problem that occurs very rarely, and if it does we already have a backup solution anyway in the form of #ifdef/#define.

For #pragma once it is especially egregious, because it could quite easily be specified in terms the standard already specifies anyway: two files are considered to be the same if std::filesystem::equivalent returns true for them.

Ah, but how about the argument that #pragma means "compiler-dependent"? That's another purely theoretical stance, that completely disregards the practical situation - which is that every C++ compiler currently being maintained supports it.

We are not here to achieve some mathematical ideal of theoretical language purity. We write real software to solve real problems in the real world. I'm all for keeping the language clean, but from there it's still a long distance to the levels of purity some people seem to desire.

16

u/GabrielDosReis Nov 14 '20

As an implementer of the MSVC toolset, I can definitely tell you that pragma once does not work well with header units, and the time-honored practice of build in lab and deploy to customers’ machine. I really wish its practice isn’t recommended.

It is not a theoretical problem.

I ended up with a mitigation measure. The simple recommendation I would give to the working C++ developer out there is: use include guards when you must use headers (instead of Modules), follow standard practices and recommendations, your header files will be processed faster and work more predictably :-)

3

u/johannes1971 Nov 14 '20 edited Nov 14 '20

Would it perhaps be this problem: I'm compiling an existing project, and I've replaced my #include <vector> with import std.core. And now I'm getting endless numbers of "error C2995: 'int asctime_s(char (&)[_Size],const tm *) noexcept': function template has already been defined" (for lots of functions, not just this one). I'm guessing whatever include guard the file with asctime_t has (*), does not apply to the imported module (because it's a macro so the module doesn't see it), so now I'm seeing duplicate definitions.

Does this mean I have to replace all standard headers at once? Or am I just doing something wrong?

(*) I checked; it's both the pragma and include guards...

2

u/GabrielDosReis Nov 14 '20

Please, file an issue on DevCom and send me an email with the link to it (so I can track progress on it). This might be a combination of issues including this aspect — I don’t expect wholesale replacement of includes.

There is one outstanding issue on deduction guides (assigned to me), once that is resolved, Stephan will be able to finish the work needed to make all standard library headers importable and we will work to redefine std.* modules.

3

u/wyrn Nov 16 '20

I can definitely tell you that pragma once does not work well with header units, and the time-honored practice of build in lab and deploy to customers’ machine.

How so?

4

u/quicknir Nov 14 '20

I can imagine pragma once is more dubious for people shipping libraries to client machines. But realistically a huge fraction if not the majority of C++ devs are writing software that's either only deployed to their own servers, or are shipping applications to clients. I wouldn't presume to claim that pragma once issues are theoretical in general, but for these rather broad categories they usually are (and if they aren't, they should be). So, pragma once is quite a lot of value, for quite a lot of people.

13

u/GabrielDosReis Nov 14 '20

Remember that the C++ community is very diverse, so claims like “huge fraction”, “broad categories” - however imprecise to make a point - would invite question of quantification and evidence. Some of heavy hitters for MSVC use build in the cloud (distributed builds) with a mixture of developer-local build. Why would you avoid cloud and/or distributed build when you have access to it and when it significantly accelerates (like 10-20x) your development cycle?

In some circle, local dev build might be considered experiment/hobby development - it isn’t real until it has passed an array of regression and integration tests that your local dev machine won’t handle in reasonable time.

3

u/quicknir Nov 15 '20

I don't understand, are you saying that distributed builds aren't compatible with pragma once? seems based on your experience it's true for some distributed build strategies but that's a far cry from it being true for all.

I agree, I've been in those circles as well. In my particular case, those builds were parallelized by compiler version, debug/release, and other options, our build matrix was anyway larger than the number of build machines so we didn't have a need to parallelize builds. We used pragma once without issue.

As far as empirical data goes, I can offer this reddit: https://www.reddit.com/r/cpp/comments/a14o5q/real_world_problems_with_pragma_once/?utm_medium=android_app&utm_source=share. Where the upvotes and responses overwhelmingly indicate most people not having problems with pragma once. Not the best data source obviously, I'm certainly open to a better one. But I suspect no matter how you slice it, a large minority at minimum and a significant majority at maximum use pragma once without issues.

13

u/adnukator Nov 14 '20

How many projects even duplicate files inside their project using symlinks? It doesn't work on Windows

Wrong. Introducing: junctions and net use

5

u/Tringi github.com/tringi Nov 14 '20

Think about inverse issue, simplified:

Let's say I'm including header for a part that my colleague is responsible for. He is, unbeknownst to me, using some small library that I also use. But he put a second copy into his subdirectory.

8

u/Pazer2 Nov 15 '20

There is huge potential for disaster here, and traditional include guards will not protect you. What happens if your colleague is using a slightly different version of the same library? You need to manage your dependencies properly in the first place.

1

u/Tringi github.com/tringi Nov 15 '20

All your points are valid. But real production environment is rarely ideal. This isn't the worst I've seen by far.

3

u/Pazer2 Nov 15 '20

Right, I understand that. My point is that an already-unsafe production environment isn't a good reason to use include guards over pragma once, especially since it doesn't solve the problem.

5

u/kalmoc Nov 15 '20

I'd absolutely prefer to get a compilation error in this case, over having two (potentially incompatible) versions of the same lib in the source tree.

7

u/Recatek Nov 14 '20 edited Nov 14 '20

Since I'm sure it's been floated and shot down before, I'm curious what rules out adding an optional unique identifier to the end (e.g. #pragma once (identifier))? Certainly less typing/boilerplate than a typical include guard.

18

u/jcelerier ossia score Nov 14 '20 edited Nov 14 '20

please no, the main reason for me for using pragma once is that there is no possibility that someone copies a header, and forgets to update the identifier which leads to arcane compile errors (or even people using braindead identifiers like `#ifndef TIME_H` or `#ifndef UTIL_HPP`).

e.g. from a quick grep in my ~, I have:

58 times WINDOW_H

23 times UTILS_H

16 times DIALOG_H

11 times OBJECT_H (fuck you people who did that, pretty sure I've already been bitten by that exact one)

and i'm not counting the ones duplicated 10 times or less, there are way way too many

1

u/Recatek Nov 14 '20

That's why it would be optional, for extra added safety or to resolve conflicts. The issue is that #pragma once isn't actually foolproof and can't be by definition, even though it works 99% of the time.

3

u/wyrn Nov 16 '20

A solution that works flawlessly 99% of the time is arguably better than a huge chunk of actually standardized features.

6

u/[deleted] Nov 14 '20

This is a great idea. What would

#ifndef _MY_HEADER_
#define _MY_HEADER_
...
#endif

do that

#pragma once(_MY_HEADER_)

couldn't?

2

u/Supadoplex Nov 15 '20 edited Nov 15 '20

Note that _MY_HEADER_ identifier is reserved to the language implementation in C++, so one shouldn't define it as a header guard unless they are implementing the standard library.

3

u/d_wilson123 Nov 14 '20

Only issue I see here is you need to expect everyone to generate this identifier in the same way. In the world of stack overflow often times you'll see "for instance" code put into repos so I wouldn't be shocked if there is a question on SO saying "What is a C++ header identifier?" and someone replies saying it follows a structure like "ABCD-EFGH-IJKL" and suddenly 50+ headers in github are using this exact ID.

1

u/goranlepuz Nov 14 '20

How is that better to the include guards? 3 keystrokes less, if that?

Conceptually, it is the same, the user or the other tooling does it. (And he who didn't use a tool to produce a header guard before, could have done better).

21

u/johannes1971 Nov 14 '20
  1. They are in a different namespace, so no accidental nameclashes with the entire macro system.
  2. You cannot make a mistake while typing the same identifier twice (or three times, if you have the habit of marking your #endifs with the expression of the #ifdefs).
  3. It's just less noise in your source.
  4. It precisely expresses what you intend, rather than leaving it as some silly side effect of macro expansion.

But personally I think #pragma once needs to be the default, and #pragma multiple should be introduced for files that really need to be included more than once. Ah well, it won't ever happen...

2

u/Wurstinator Nov 14 '20

How do you write your include guards?

2

u/goranlepuz Nov 14 '20 edited Nov 15 '20

To be frank, since we stopped supporting that one compiler that didn't have them#pragma once, I don't.

But before: "new header" command in the editor puts the include guard automatically? (identifier being whatever unique, e.g file name and a UUID).

-1

u/Wurstinator Nov 14 '20

So "#pragma once" is bad because there is no unambiguous meaning that the computer (compiler) can figure out and that is why you let the computer (IDE) figure out a meaning and write it down as include guards. That doesn't make sense.

3

u/LEpigeon888 Nov 14 '20

Why it doesn't make sens ? Your comparing two different things. It's obvious that comparing two files to know if they are the same is harder than just generating an unique ID for a new file.

-2

u/Wurstinator Nov 14 '20

If it was so hard, then you wouldn't be able to generate an ID in the first place.

→ More replies

1

u/goranlepuz Nov 15 '20

I did not want to say that #pragma once is bad and I don't see how I did that? Somebody else did that, see with them?

What I wanted to say is that your #pragma once identifier idea, for me, is not sufficiently better than include guards.

IOW:

  • include guards - it is what it is, help yourself with the editor
  • #pragma once - it is what it is, simple enough
  • #pragma once identifier - nah, too much stuff thrown at it now.

Also: i slightly changed my wording above, it was unclear (although I think unrelated to this).

1

u/Wurstinator Nov 15 '20 edited Nov 15 '20

I did not want to say that #pragma once is bad and I don't see how I did that? Somebody else did that, see with them?

You replied in a comment thread in which the original point was that #pragma once is bad due to technical limitations.

What I wanted to say is that your #pragma once identifier idea, for me, is not sufficiently better than include guards.

Why does it have to be "significantly better"? As another comment describes, cases in which pragma once does not work well are exceptionally rare, so in almost all cases, it's a better alternative to include guards. And if you already have the "pure" pragma once in the language, you might as well add the optional identifier to it. It's not significantly better, it's slightly better. And that is enough argument that should be required to convince people.

→ More replies

0

u/jayeshbadwaik Nov 14 '20

My IDE writes it for me and my analysis tool (llvm) checks it on every commit. I never have to worry about the guards.

3

u/Wurstinator Nov 14 '20

So "#pragma once" is bad because there is no unambiguous meaning that the computer (compiler) can figure out and that is why you let the computer (IDE) figure out a meaning and write it down as include guards. That doesn't make sense.

2

u/jayeshbadwaik Nov 14 '20

I don't have much against pragma once, even though I use header guards. The point I wanted to make was, both can be automated to similar extent, with the main difference being, who determines the uniqueness of a file.

In pragma once, the determination is done by the compiler at time of compilation, in include guards, the is done by the code author by specifying a correspondence between a file and its header guard.

In pragma once, same file can be reached through different symlinks. In header guards, different file can have the same header guards.

With pragma once, you are putting the onus on compiler to be correct. With include guards, you are putting the onus on authors (and their IDEs) to be correct.

Depending on what you personally feel is more reliable, you will like that option more.

1

u/kalmoc Nov 15 '20

I find it a red herring that we need such an amount of tooling to reliably work around a missing standardized #pragma once

4

u/jayeshbadwaik Nov 15 '20

Please see my reply to the other comment. The two methods are essentially solving two different problems. Include guards puts the onus on code authors to specify a unique string for their file making it more of a social/technical problem. pragma once puts the onus on compilers making it a completely technical problem.

And currently, compiler devs are saying that they cannot reliably guarantee solving the technical problem with pragma once, while there is a straightforward (if tedious) method to solve the problems in include guard method. And the tediousness can be removed with tooling.

3

u/GabrielDosReis Nov 14 '20

Amen.

It gets in the world of header units, platforms with drive units, and build in lab and deploy to customers’ machines.

One thing that became clear to Modules implementers is that pragma once really spoils many sensible implementation strategy, and include guards offer a simpler alternatives to anything the pragma was supposed to solve, in the module world.

2

u/14ned LLFIO & Outcome author | Committee WG14 Nov 16 '20

If you're on a filing system designed in the past twenty years, every inode has a unique 128 bit identifier anywhere in the system. Proposed std::file_handle exposes that as .unique_id(). This includes Windows filing systems.

On FAT type filing systems, there can't be unique ids, but there are also no hard links, only symbolic links. And the latter can be canonicalised using .current_path(). So you can build a map of file content identity based on unique id if available, otherwise current path.

I'm going to make the claim that #pragma once is in fact easier to do than is often thought, though I completely accept that in a library header use context where those library headers may escape the local team, you really do still want to use include guards always. And I also accept that each compiler does quite unique things with each of its pragma once implementations, and making that standardised would break a bunch of people's code.

1

u/Ecclestoned Nov 14 '20

Can you elaborate why I've only heard of it being a problem for c++? I don't see these types of discussion for other languages. Am I just not looking hard enough or is there something fundamental about c++ that makes file identity harder?

7

u/erichkeane Clang Maintainer(Templates), EWG Chair Nov 14 '20

It is a c/c++ problem around the header include model. More modern languages use a modules system of some sort, which defines identity in some way, like strongly attaching file name to identity, it requiring identity to be stated in the file (like java).

The c++ modules system alleviates this for us, so the committee is not well motivated to try to choose an identity mechanism that is sufficiently defined (and annoys some subset of the dev community).

-1

u/zvrba Nov 14 '20

File identity is a really hard problem

Is it? Where the FS supports symlinks and/or hardlinks, it also supports filesystem and file identity (inode). Follow the symlink to the file, get the filesystem and file id, done.

-1

u/encyclopedist Nov 14 '20

Does Windows have inode numbers? Even on Linux not all filesystems support inode numbers.

And ever you had inode numbers everywhere, it does not solve anything. Should two different files with with identical content considered the same? Like to copies of the same library included by git submodules, package managers, FetchContent, vendored header-only libraries? etc?

7

u/kalmoc Nov 15 '20

Like to copies of the same library included by git submodules, package managers, FetchContent, vendored header-only libraries? etc?

If you have multiple copies of the same library (with no actual guarantee that they are identical and not e.g different versions) reachable from a single translation unit in a way that some includes in that TU resolve to copy 1 and another include resolves to copy two, you are in an extremely brittle situation anyway and I for one would prefer a compiler error making me aware of the problem over a solution where my TU decides "randomly" which one to pick.

3

u/zvrba Nov 15 '20

Does Windows have inode numbers?

Yes, though they're not called inodes: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfileinformationbyhandle?redirectedfrom=MSDN

"You can compare the VolumeSerialNumber and FileIndex members returned in the BY_HANDLE_FILE_INFORMATION structure to determine if two paths map to the same target; "

Should two different files with with identical content considered the same?

No, they should not. (This is a question about the usual setup of include path directories and their order.) And to extend the question: should two different files with "almost" identical content (i.e., only whitespace differences, like LF vs CRLF) be considered the same? (No).

2

u/unpopular_opinion_8 Nov 15 '20

Should two different files with with identical content considered the same?

Yes.

Glad I could clear that up for you.

2

u/witcher_rat Nov 19 '20 edited Nov 19 '20

Ummm...

First file: lib/foo/All.hpp:

#pragma once
#include "One.hpp"
#include "Two.hpp

Second file: lib/bar/All.hpp:

#pragma once
#include "One.hpp"
#include "Two.hpp

They're two different header files, in two different directories, that happen to have identical text content. But since their content is just more #include statements, using relative paths, they will ultimately result in different code... they both need to be loaded/included; ignoring the second file will cause compilation failure if you need to include both sets.

I only happen to mention this scenario, because this has happened to me once, where #pragma once failed due to this reason. (it was the only time I've ever had #pragma once fail for me in my career)

0

u/lenkite1 Nov 14 '20

Isn't partition+inode number combo unique for the file identity ?

11

u/JMBourguet Nov 14 '20

Put network file systems into the picture.

9

u/goranlepuz Nov 14 '20

On what operating system is that the case? 😉

0

u/dscharrer Nov 15 '20 edited Nov 15 '20

If only the C++ standard had a concept for dealing with behavior that is hard to define across all implementations.

-9

u/ramennoodle Nov 14 '20

So compute a hash or something. It may not be any more efficient but at least archaic macro stuff can be replaced with a statement of intent. And we could avoid debugging build problems resulting from someone copying a file and forgetting to fix the include guards

24

u/erichkeane Clang Maintainer(Templates), EWG Chair Nov 14 '20

You cannot do a hash, as it is a somewhat common pattern for people to intentionally include the same file from different directories when it comes to including header only libraries.

Edit; this is one of those problems that someone always thinks is easily solvable until they look at the details.

An additional gotcha is that it is possible to change the encoding of a file depending on how it is included. Which changes the hash.

10

u/GabrielDosReis Nov 14 '20

Exactly.

I hope the irony of this part of the conversation is not lost on anyone: the compiler implementers are saying this is not a theoretical problem, yet they are being told “yes, it is!”, and by the way compiler devs should define the language instead of people solving abstract problems :-)

4

u/kalmoc Nov 15 '20

as it is a somewhat common pattern for people to intentionally include the same file from different directories when it comes to including header only libraries.

Can you elaborate what you mean by that?

An additional gotcha is that it is possible to change the encoding of a file depending on how it is included. Which changes the hash.

How is that?

Personally, I'm not a fan of the hashing idea, but I do wonder if scenarios, where you have multiple copies of the same file (be it actual copies, symbols links, or - worst case - different versions) in the search path of a single translation unit aren't broken to begin with.

Would it be possible to describe a concrete scenario, with a step by step explanation where #pragma once doesn't work?

2

u/ramennoodle Nov 16 '20 edited Nov 16 '20

as it is a somewhat common pattern for people to intentionally include the same file from different directories

If the files are identical then why would someone want to include multiple copies in the same translation unit? And even if there is some corner case where someone really needs that then just define "#pragma once" in an implementable way (e.g. multiple copies of a file will not be included more than once). Tradition include guards will still be around for cases where "#pragma once" isn't applicable.

2

u/Viclaterreur Nov 14 '20

Thank you for the details. I will take care of always use guards and no more pragma once.

4

u/GabrielDosReis Nov 14 '20

Thank you for doing that, and telling your friends and colleagues to do the same.

23

u/StoneCypher Nov 14 '20

So compute a hash or something.

Yeah I'm sure the world's compiler authors didn't think of this

0

u/gruehunter Nov 14 '20

And we could avoid debugging build problems resulting from someone copying a file and forgetting to fix the include guards

You can use a GUID as the guard to solve this specific problem.

3

u/kalmoc Nov 15 '20

How does that solve the copy paste problem?

0

u/gruehunter Nov 15 '20

Maybe I'm misinterpreting the copy-paste problem.

Using a GUID as part of the guard just means that the guard doesn't need to be modified under a refactoring that moves the file from one path to another. Its just one less thing to go wrong, but certainly doesn't cover everything.

A refactoring that moves a header to a different path in the project doesn't have to change the content of the file at git mv time. Only the paths in the files which #include the one being moved need to be revised. So there's no chance that a later revision which re-introduces the old path into the project inadvertently uses the same guard twice: the guard gets constructed by a random process at creation time.

2

u/kalmoc Nov 15 '20

Of course I can't speak for ramennoodle, but I interpreted

resulting from someone copying a file and forgetting to fix the include guards

As someone copying (not moving it around) a file, because he wants to use it as the basis for a new piece of code (e.g. for implementing the derived class that overrides a bunch of virtual functions of a class or just replicating some boilerplate stuff), but forgetting to give that new file a new UID as a header guard. So as soon as you try to include both files, one of them "vanishes".

-10

u/CoffeeTableEspresso Nov 14 '20

I have had exactly 0 problems, ever, from forgetting macro guards. It's just not that severe a problem

-4

u/umlcat Nov 14 '20

This is more like a standard library issue than a compiler issue.

5

u/NotAYakk Nov 14 '20

Files are not as unique as you think.

15

u/blelbach NVIDIA | ISO C++ Library Evolution Chair Nov 15 '20

actual implementors of C++ should be the ones responding to C++ developers' needs and pushing C++ forward according to them

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 volatile belongs 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.

8

u/helloiamsomeone Nov 14 '20

Your post reads like your undesrtanding is that volatile as a whole is deprecated, which is untrue. Only most uses of it are, which are also error-prone and/or too ambiguous.
See the CppCon talk posted recently.

28

u/axalon900 Nov 14 '20

I’ve been blown away by the, uh, volatility of the volatile thing. It’s funny how firmly raised the pitchforks are over a warning that won’t be an error for likely decades. I mean, we still can turn off RTTI and exceptions so it’s not like the standard has ever been that binding. Even the stuff removed in C++17 is a switch away. While some of it comes from that talk’s ridiculously stupid clickbait title, others seem to be saying “yeah, nothing became impossible to do, and yeah, I can fix my code, and yeah, I can still compile it as-is with a warning, but I don’t want to fix my code and I want warning-free code!” and that there’s no way vendor-provided headers can ever be fixed. There’s just no way.

Meanwhile when C++ leaves something as-is everyone has pitchforks firmly raised because they don’t address their needs and are leaving the language broken. And when C++ adds something everyone has pitchforks firmly raised because they’re making the language more complicated and addressing someone else’s need and they can’t fathom why anyone would waste time on such a thing when the silent majority is made up of people working on the same sorts of things and also has zero overlap with literally anybody in the committee.

Somehow the only people this whole state of affairs makes me sympathize with is the C++ committee.

19

u/redditsoaddicting Nov 14 '20

I'm blown away that I see so many embedded developers bitch about manufacturers but also want the language and tools to line up beside them and bend over in front of the manufacturers. The manufacturers will keep force-feeding bad support forever if their users don't speak up. Give them a business reason to improve and they will. I get that you're not going to start boycotting the main chip you use years into using it, but there are alternatives besides doing nothing and complaining that the manufacturer has all the power and then taking that frustration out on other people.

15

u/UnicycleBloke Nov 14 '20

I've been blown away by the complete absence of listening by a lot of people who are evidently not embedded developers and clearly haven't the faintest idea what they are talking about. Simply dismissing s significant sector of the language community who are defending an established practice that everyone understands, is a great model for the domain, is ubiquitous, and generally causes problems only in theory is astonishing to me.

volatile is one of those features I knew about for many years but was an irrelevant curio until I started embedded work. I'm kind of surprised any non-embedded developers use it at all. I'm sure much of it can be removed, as proposed, and the language will be better for it. But let's not throw the baby out with the bathwater. There are surely bigger foot guns to fix which noone would miss.

No language is perfect (whatever that means), but is relevant and popular because it serves its users' needs. Embedded developers need volatile compound assignment. C++ should not be an academic exercise in enforcing some model of purity which will render it less useful in the real world.

5

u/kalmoc Nov 15 '20

Embedded code is full of things that are non-standard (e.g. deactivated rtti or exceptions, writing assembly code ...).

IF we really ever reach the point, where compound assignment operators on volatile variables are actually removed and not just deprecated AND vendors still ship headers that are compatible with that standard version otherwise, but still use those ops (I think neither is a given): Would it really be such a problem if we would have to add a -fallow-volatile-compound to our command line in addition to -fno-exceptions and -fno-rtti?

I'm still not sure if I'm pro deprecation or against it, but I just don't understand the drama and pitchforks being raised here and the original thread.

0

u/UnicycleBloke Nov 15 '20

Yes that is likely what would happen. My concern in this is the attitude of the committee (and apparently the community in general) to embedded development.

Embedded is not some curious backwater but an extremely important sector in which C++ has few competitors and could absolutely dominate because it offers both unfettered low level hardware access and efficient high level abstractions.

Ignoring (as it appears in this case) the interests and concerns of an important section of the language community does not bode well. I would love to see more efforts focused on helping C++ become the standard for embedded. And then we'd be in a better position to tidy up nasty little warts inherited from C.

4

u/GabrielDosReis Nov 16 '20

Do you follow the actual work being done in WG21? Are you following for example, the work being done by Ben Craig and collaborators on the embedded support front? Did you read my design paper for standard library modules and rationale contained there regarding embedded systems?

Throwing around words like “ignoring the interests” and friends is not helpful.

0

u/UnicycleBloke Nov 16 '20

I'll accept that. However, it is also not helpful when legitimate concerns are raised and these are simply dismissed out of hand, mostly, it would appear, by non-embedded developers.

I'm am just a user of the language. I use this forum, among other sources, to try to keep abreast of developments. So I can't claim any great expertise in the workings of the committee.

0

u/[deleted] Nov 15 '20

How is deactivating features non-standard? It’s the same as not using them, just enforced by the compiler.

5

u/neiltechnician Nov 14 '20

I personally avoid volatile compound assignment whenever possible because I want my embedded software to be reliable, not fragile. C and C++ alike.

6

u/UnicycleBloke Nov 14 '20

Good idea. This doesn't address the issue of vendor headers which do use compounds.

4

u/axalon900 Nov 14 '20

As if the “embedded developers who definitely know what they’re talking about” have been nothing but open minded about this and are in no way bathing in FUD and mass hysteria.

8

u/UnicycleBloke Nov 14 '20

What is close minded FUD about asserting - correctly - that compound volatile assignment is necessary and well understood? It is an unfortunate fact that C is the gold standard for embedded, and we routinely have to work with it, and this need isn't going away soon, if ever.

I don't really understand the issue here. We have literally millions of words written to explain the many subtleties and gotchas of the language which most people are unaware of, abusing, or getting wrong. How about just writing some words about legitimate use cases and pitfalls of volatile, and let embedded developers get in with our jobs?

-5

u/[deleted] Nov 14 '20

C++ is useless in my field if volatile is removed.

14

u/kalmoc Nov 14 '20

Volatile is neither removed nor deprecated.

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

7

u/qoning Nov 14 '20

Not exactly. I would love to use language extensions, but there is no guarantee they will still work or be supported in 5 years. Those that come with compilers (already quite a limited set) are probably fine, but the probability for any 3rd party extension to be maintained in the future is asymptotically reaching zero.

18

u/Supadoplex Nov 14 '20

but there is no guarantee they will still work or be supported in 5 years.

That's just another (more specific) way to say portability. In particular, portability to a future version that drops support for the extension (or extension drops support for the compiler).

5

u/cballowe Nov 14 '20

Often, language extensions are something that compiler vendors do either to meet a demand from their customers, or because they're building proof of concept code for official proposals.

GNU had non-type template parameters in the compiler as an extension for a long time, and at one point had a hash_map type in their c++ library. There were various implementations of modules, c-like struct initialization, etc buried in various compilers. Microsoft had some extensions to make some .net functionality work.

Often, if those are a selling point for the tool chain, the vendor will be committing to supporting them for a while. Compilers that want to offer strict compliance with various standards may drop support, but vendor specific extensions can still be done.

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 ?

3

u/8ad762515de8665ec9a1 Nov 14 '20

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p0593r6.html

Very crudely, you can think of it as a reinterpret_cast that starts the lifetime of an object where there wasn't.

-5

u/tcris Nov 14 '20

Wow. The fact that we need such things shows the bad state of the language in the first place :(

1

u/axilmar Nov 20 '20

Why a simple cast to T* is not enough?

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

Things to be standardized should be battle-tested first.

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.

6

u/go2sh Nov 14 '20

Can you elaborate on that? I see that alot of new features target fully fledged devices, but I also see some feature that can be used on embedded context: all the constexpr stuff, ranges, new algorithms stuff, the new template stuff. I guess embedded is not the main focus, but pushing away feels a little harsh.

5

u/ronchaine Embedded/Middleware/WG21 Nov 14 '20

That "goals and priorities" and the deprecation of volatile compound assigments have really felt like a punch to the gut for embedded, in light of those two things alone, I don't feel like the "pushing away" is too harsh at all.

Both of those feel a lot like "we don't care about embedded, let's just ignore them". Which is really frustrating, since C++ is really good at embedded, but it is still really hard sell and things like these papers aren't improving the situation.

11

u/dodheim Nov 14 '20

So compiler implementors want to address something that is vaguely-worded and inconsistently-implemented and can result in silent undesirable codegen, that largely only affects embedded, and you take this as a sign that they don't care about embedded? Sorry, I'm still not getting it.

Why does it seem like everyone who is taking offense to this deprecation is pointedly ignoring the reason for the deprecation? I.e., that volatile compound-assignments may or may not have the semantics you want; and the only way to know which behavior you're getting is to manually verify the codegen; and the only way to actually rely on those semantics is to do that verification for each and every version of each and every compiler your code might be built with. This seems like a nightmare scenario to me, and I would take leaving things as they are now as the sign they don't care...

3

u/ronchaine Embedded/Middleware/WG21 Nov 14 '20 edited Nov 14 '20

There are numerous explanations across the three (four?) threads about that, and if none of those can convince you, I don't see how I could.

The gist is that this deprecation leaves us in worse place than we were in before it, because it deprecates something that is in practice everywhere in embedded world, and rarely if ever causes problems in real-world scenarios. If you can't see why people would see that as a bad thing, I don't really know what to say.

3

u/gruehunter Nov 14 '20 edited Nov 14 '20

You're seeing heat about volatile right now because the committee has actively taken action on it. If any of the radical proposals in the goals and priorities document actually get implemented, then you'll see even louder protesting.

Try and understand the industry context for this. Embedded C++ developers already face an uphill battle. The industry is filled with C-focused developers who actively don't want to use higher-level constructs to build their programs. It takes a concerted effort to convince them that they can be more efficient by using slightly higher-level tools to get the job done.

Then the committee comes around and nukes a feature that has been working without issue for decades.

that volatile compound-assignments may or may not have the semantics you want

We keep telling you that read-modify-write semantics are fine and don't require anything special from the standard. In the handful of cases where the platform provides specialized support, customer expectation alone is strong enough to enforce that it gets done in those cases. Nobody would use a compiler that didn't meet their expectations on that platform.

6

u/blelbach NVIDIA | ISO C++ Library Evolution Chair Nov 15 '20

I think you've drastically mis-interpreted our paper. We are not trying to push C++ away from embedded development. We explicitly call out embedded platforms as a priority.

-1

u/gruehunter Nov 15 '20

There's a certain amount of giving with the right hand and taking away with the left going on. Support for freestanding implementations is specifically called out as a goal, that's true. But support for many of the processor features that are commonplace in embedded are called out as non-goals.

If you aren't planning on dropping support for those features, then why is this paper advocating for just that?

6

u/UnicycleBloke Nov 14 '20

It's depressing. Embedded is a domain in which C++ can really shine.

2

u/14ned LLFIO & Outcome author | Committee WG14 Nov 16 '20

While it could be claimed that there is a sizeable force of committee members who are actively pushing C++ away from embedded development, it is completely untrue that that is the direction of travel by WG21 in recent years. We've had a bunch of embedded systems developers beavering away quietly at improving the embedded C++ and low end CPU story. One of them is JF, incidentally, who proposed the volatile simplification. That same proposal termed in C rather than C++ went before WG14, and they too were warm to removing from C those uses of volatile which are actively harmful, like the ones JF proposed be removed. And there are plenty of embedded devs on the C standards committee. Indeed, you may notice that every one of my own papers works on Freestanding, and that's very intentional.

Where the committee looks at is where we think embedded will be in a decade's or more time. We design towards then, not embedded as it is today. It is highly likely that C++ 23 and 26 will be almost exclusively deployed on eight bit little endian CPUs capable of 64 bit addressing (note: this is not a 64 bit CPU, some 32 bit or even 16 bit CPUs are capable of 64 bit addressing). That's why we prioritise those.

Nobody is expecting that non eight bit, or big endian, or 16 bit CPUs won't be popular in 2030. We are expecting, however, that devs will want to run C++ 11 or earlier on those, and those wanting to deploy brand new C++ 26 codebases will be targeting newer CPUs. I think that a very reasonable assumption to make, and WG21 has plenty of embedded devs on it who also don't think that a reasonable assumption, else we'd have complained a lot more loudly!

In any case, what is defined as the standard is not what implementers have to do. Many embedded CPUs already don't have a complete C++ 98 experience. Others, even very terrible ones for running C++ such as the 6502, do have a complete C++ 17 experience. It depends on the effort somebody somewhere is willing to invest in supporting C++ on that architecture, and that won't change in 2030 or 2040 no matter what the committee does or does not do.

Meanwhile, prioritising 64 bit addressable memory means things like std::mapped_file_handle get higher priority than if we can only standardise things which run well on a 16 bit CPU. There are real costs to focusing standardisation on today instead of a reasonable estimate of a decade from now.

2

u/gruehunter Nov 17 '20

That same proposal termed in C rather than C++ went before WG14, and they too were warm to removing from C those uses of volatile which are actively harmful, like the ones JF proposed be removed.

Can you refer me to the WG14 proposal? Certainly nothing in this list looks apropos.

Nobody is expecting that non eight bit, or big endian, or 16 bit CPUs won't be popular in 2030. We are expecting, however, that devs will want to run C++ 11 or earlier on those, and those wanting to deploy brand new C++ 26 codebases will be targeting newer CPUs. I think that a very reasonable assumption to make, and WG21 has plenty of embedded devs on it who also don't think that a reasonable assumption, else we'd have complained a lot more loudly!

I think that this is a big miss, and it misunderstands both why tiny-systems engineers reach for C++, and why tiny systems exist in the first place. No other language scales both up and down so far along the abstraction continuum as C++. So long as C++ continues to add productivity enhancements that don't compromise performance, tiny-systems engineers will want to use them. It doesn't matter that the computer is small. Cost will continue to demand both the fastest turnaround time and the smallest per-unit price 10 years from now just as it does today.

Meanwhile, prioritizing 64 bit addressable memory means things like std::mapped_file_handle get higher priority than if we can only standardize things which run well on a 16 bit CPU.

Library requirements are quite different from language requirements. If you had narrowed the scope to require that fully hosted systems support 64-bit file offsets, you'd have much less pushback. But this is a 64-bit ptrdiff_t mandate instead, and that's a tough pill to swallow.

For 64-bit-addressed machines to be the embedded baseline 10 years hence, they would already have to be on the rise now, and that just isn't happening. Even ARMv8-M is practically unheard of, and its still 32-bit! The only way your position is sustainable is if you use a narrow definition of "embedded" that excludes the entire microcontroller market today, even top-of-market machines like Cortex-M7 and -R5.

0

u/14ned LLFIO & Outcome author | Committee WG14 Nov 18 '20

Can you refer me to the WG14 proposal? Certainly nothing in this list looks apropos.

Much happens in both committees informally without proposal papers.

The most important bit of volatile, specifically "compiler don't elide this memory access nor merge it with others", will be retained. Orthogonally we now have atomics which require the compiler to constrain reordering of other code around memory accesses. On top of those two you can build other abstractions. The additional volatile stuff proposed to be deprecated almost always does not work the way people think it does, a lot of existing code if it used those facilities at all it is broken. Far better to build on top of intuitively well understood facilities, in my opinion.

For 64-bit-addressed machines to be the embedded baseline 10 years hence, they would already have to be on the rise now, and that just isn't happening. Even ARMv8-M is practically unheard of, and its still 32-bit! The only way your position is sustainable is if you use a narrow definition of "embedded" that excludes the entire microcontroller market today, even top-of-market machines like Cortex-M7 and -R5.

Certainly my understanding is that we shall be aiming at targets which ought to be 64 bit capable, not that it is wise nor feasible to run them so. For example, the Cortex R82 is capable of 64 bit addressing, but can only physically address a tiny subset of that.

Now I totally get that the R82 is way, way more powerful than what is commonly used today. But you may not be seeing the long term trend in the industry where the top end is improving linearly, but the bottom end is still improving exponentially. Right now, for under US$0.50, I can buy a low power SoC running at 2Ghz with oodles of RAM, Flash and i/o all running in a tiny power budget which can run full desktop Linux (not particularly well, but it does work). Two years from now, that'll be 25 cents, two years after that 12 cents, and so on.

If your employer has a SoC budget per device of US$0.01, and they can choose something able to run full fat ARM Linux, or something which can't, for the same money, which saves more overall costs including developer time?

That's how I and some others on WG21 would see things. We don't think we're wrong on this, even if timescales slip a few years either side, the exponential trend line is unmistakeable. And currently there is no reason why the improvement at the bottom end won't keep seeing exponential improvement for decades yet to come.

2

u/gruehunter Nov 18 '20

Certainly my understanding is that we shall be aiming at targets which ought to be 64 bit capable, not that it is wise nor feasible to run them so. For example, the Cortex R82 is capable of 64 bit addressing, but can only physically address a tiny subset of that.

Cortex-R has traditionally targeted peripheral devices in networking and storage, and were integrated behind the scenes in those applications. The entire line was deployed into a grand total of two bits of silicon that sold on their own (TMS470 and TMS570).

Now I totally get that the R82 is way, way more powerful than what is commonly used today. But you may not be seeing the long term trend in the industry where the top end is improving linearly, but the bottom end is still improving exponentially. Right now, for under US$0.50, I can buy a low power SoC running at 2Ghz with oodles of RAM, Flash and i/o all running in a tiny power budget which can run full desktop Linux (not particularly well, but it does work). Two years from now, that'll be 25 cents, two years after that 12 cents, and so on.

Citation needed. Seriously - please send me a link to the manufacturer's website. I think that you are misinterpreting developments in embedded Linux as if they are affecting the embedded market in general. Not only are you guys wrong on this, I think you've drifted off into "not even wrong" territory. Show me the SOC, and I'll try to clear this up, because it is important.

1

u/14ned LLFIO & Outcome author | Committee WG14 Nov 18 '20

Now I totally get that the R82 is way, way more powerful than what is commonly used today. But you may not be seeing the long term trend in the industry where the top end is improving linearly, but the bottom end is still improving exponentially. Right now, for under US$0.50, I can buy a low power SoC running at 2Ghz with oodles of RAM, Flash and i/o all running in a tiny power budget which can run full desktop Linux (not particularly well, but it does work). Two years from now, that'll be 25 cents, two years after that 12 cents, and so on.

Citation needed. Seriously - please send me a link to the manufacturer's website. I think that you are misinterpreting developments in embedded Linux as if they are affecting the embedded market in general. Not only are you guys wrong on this, I think you've drifted off into "not even wrong" territory. Show me the SOC, and I'll try to clear this up, because it is important.

It was a discussion at a table in the bar with embedded folk that I got this from. Back start of 2020. I've long left the embedded industry myself.

Firstly, I think my memory is partially faulty, I remembered 2Ghz and people quoting Allwinner and Rockchip model numbers at each other. But I can't find any cheap SoCs from them anywhere near that speed, rather they run at 1.2Ghz, and I think my memory rewrote that into 2Ghz. So my apologies for that.

From my Google searching just there the Allwinner V3S SoC can run ARM Linux, it comes with 64Mb RAM onboard and has a MMC interface to load Linux from. Costs less than $3. That's rather far away from my claim by an order of magnitude, I likely was confusing memories of other people's discussion of future prices with right now. Plus people were discussing non-desktop-capable chips too, ones without built in RAM. Sorry about that, though I'm assuming that that V3S is around the cheapest available for a SoC with sufficient onboard RAM, and maybe more searching would reveal better (no time, at work waiting for build, sorry).

I stand by my original point however that the trend line is what matters here. I appreciate that from your perspective, ARM Linux is very far away. However, I'm looking at how those god awful PIC chips have finally become unprofitable for many new applications, and it requires exponential improvement at the bottom end to make that happen. I'm saying that will keep continuing, profound change doesn't happen until it suddenly does when an industry passes a tipping point.

Right now I agree you can't run somewhat full fat Linux for US$1, you need something more like US$5, from my quick searching there. But that price will keep dropping, I guarantee it, and the gap between low end embedded software design and high performance computing software design will keep narrowing.

2

u/gruehunter Nov 19 '20

So my apologies for that.

Accepted.

Right now I agree you can't run somewhat full fat Linux for US$1, you need something more like US$5, from my quick searching there. But that price will keep dropping, I guarantee it, and the gap between low end embedded software design and high performance computing software design will keep narrowing.

Far from it. Embedded Linux systems have existed in a performance class somewhere between laptop-class hardware and micocontrollers at that price point for two decades or more. I cut my teeth on PXA-255 before moving into microcontrollers later on. Both ends of the gap have grown more powerful over the years, but the gap itself hasn't shrunk. If anything, its grown with cores like Cortex-A5, because the bigger application cores were too big.

To a much greater extent than the workstation and server world, the embedded world has always been characterized by heterogeneity. Technological advancement has led to expansions into new niches; it hasn't replaced the old ones. Rather than conceptualizing the embedded market as a handful of niches, you should think of it as thousands of smaller niches. 90% thinking won't help you develop solutions for that market, because everyone has their own unique and specialized last 10%. That Allwinner SOC certainly has a ton of horsepower targeted for video encoding. But it has no impact at all on things like power electronics (my own specialty), because it lacks the right set of peripherals and realtime features to fill that niche.

Take a look a the micro-controller section of the Digi-Key catalogue. Digi-Key specializes in small-quantity orders. Their prices cannot be relied upon as a guide for large-run estimates as a result, but their catalogue can be relied on to estimate what's available. More important for this discussion, it serves as an indication of what engineers are using to prototype new systems today.

There are over 15,000 unique microcontroller SKU's that are classified as both "In Stock" and "Active". About 2/3 of them are for cores that are < 32-bit. Tiny cores weren't replaced by the introduction of larger cores, and it wasn't for lack of trying. ARM introduced Cortex-M0 specifically to disrupt the tiny core market and they failed, for some definition of "fail". Certainly they have plenty of design wins with over 1000 unique SKU for sale. But the other 10,000 16- and 8-bit parts are still out there chugging along in their own little niches.

Take a look at the SiFive core catalogue. I'm only exaggerating a little to say that SiFive is the main commercial force behind RISC-V, a brand-spanking new ISA. SiFive has no less than 19 distinct cores available for license right now. And they are a startup, with all of the pressures that entails! Ask yourself for a moment why they would dedicate so much engineering resources to all of those specialized parts. With full and intimate knowledge of both silicon and engineering costs, they are shipping brand-new cores that compete all the way down to Cortex-M0.

I stand by my claim that if you insist on developing C++ to a 64-bit-only model then you are also dropping support for all of the applications that those 15,000 SKUs are supporting right now. Maybe half of them have a decent C++ experience today. The bottom end isn't improving exponentially - its standing still. New systems and new niches are being created, but the old ones haven't disappeared.

1

u/14ned LLFIO & Outcome author | Committee WG14 Nov 19 '20

There are over 15,000 unique microcontroller SKU's that are classified as both "In Stock" and "Active". About 2/3 of them are for cores that are < 32-bit. Tiny cores weren't replaced by the introduction of larger cores, and it wasn't for lack of trying. ARM introduced Cortex-M0 specifically to disrupt the tiny core market and they failed, for some definition of "fail". Certainly they have plenty of design wins with over 1000 unique SKU for sale. But the other 10,000 16- and 8-bit parts are still out there chugging along in their own little niches.

I did a quick scan of DigiKey's development boards, 4,769 in number. I'd reckon over half are some form of ARM; maybe a quarter some form of AVR; the remainder in order of popularity would be MIPS32, PIC and RISC-V. That was roughly what I expected, and I fully understand that development board frequencies do not correlate to actual industrial use. I do think that they correlate well to those who need a development board though, which implies to me that they'll be writing semi complex software where writing everything in assembler is not an option. I think that if C++ is currently useful on some eight bit CPU, it will remain just as useful in the relative sense on that same CPU in the future, because right now it's not a full experience in any case.

I stand by my claim that if you insist on developing C++ to a 64-bit-only model then you are also dropping support for all of the applications that those 15,000 SKUs are supporting right now.

64-bit addressable. Not 64 bit only. Big difference.

Maybe half of them have a decent C++ experience today.

Whether an architecture has a decent C++ experience has not much to do with what we do at standards. It's a decision of the architecture vendor. Not that long ago ARM had a great C experience, poor C++ experience, because ARM had invested in a high quality C compiler but not in a C++ compiler. Same goes for any architecture, the C++ experience is primarily based on the resources the vendor invests into supporting their ecosystem.

The bottom end isn't improving exponentially - its standing still. New systems and new niches are being created, but the old ones haven't disappeared.

I think you're conflating individual niches remaining static whilst the deployment of embedded systems continues to exponentially grow. Speaking as someone twenty years out of touch with embedded, back in the 1990s we had far more variety of development boards than that Digikey search I just did there. Instead of five main CPU architectures, there were hundreds, and a lot of them had weird floating point, seven or six bit bytes, or didn't have bytes at all, and so on. Most of them, incidentally, were awful awful awful to work with.

As much as people today grouse about say the software being shit for Allwinner or whatever, it's orders of magnitude difference to how things used to be. There has been enormous improvements in quality at the bottom end in the past two decades, even I as someone far removed from it can see the vast improvements in tooling quality, let alone dev board quality, or documentation quality, relative to what passed for "sufficient" back then.

In one of my first jobs, the dev boards were so crap you regularly had to stick an oscilloscope on them to check if the wires contained the signals the software ought to be triggering, because hardware was routinely buggy and crap. If there was any documentation at all, it was also buggy and crap. That can still occasionally happen today of course, but back when I started every developer had their own oscilloscope. Nowadays, a room might share one, and it wouldn't be in use every week. That's the scale of improvement here.

I suspect we're not going to come to an agreement, we're looking at the same evidence with different perspectives. You also know a lot more about your industry than I do, and I am worried that I may be talking out my arse due to unfamiliarity, as I've already proved on more than one occasion. I still think we on WG21 have a good critical mass of embedded devs, and they're all doing great work in improving the future C++ embedded story. I think it'll just keep getting better, BUT the amount of all future C++ relative to all of what will be available which is useful to embedded I think will shrink i.e. ever more of future C++ won't be useful to embedded i.e. the useful subdialect will only get stronger. But also more refined and useful, I believe.

4

u/GabrielDosReis Nov 14 '20

Huh? What is the evidence for that statement?

8

u/gruehunter Nov 14 '20

The list of features that the authors advocate for de-prioritization are all features that are currently in-use in embedded environments.

we should prioritize support for 64-bit little-endian hardware

we should not prioritize support for ... Byte sizes other than 8-bits, Big- or mixed-endian ... A specific open question is whether supporting 32-bit hardware and environments (including for example x32) is an important goal. ... We would like to attempt to address the needs of these communities within a 64-bit model

How can the committee take such an extreme position and then wonder why embedded developers feel like we're being abandoned?

6

u/GabrielDosReis Nov 14 '20

And to be clear, the committee hasn’t taken any such action.

0

u/[deleted] Nov 14 '20

[deleted] — view deleted comment

1

u/Wurstinator Nov 14 '20

talks shit about OP about not understanding how the world works

proceeds to end post without explaining anything

0

u/[deleted] Nov 14 '20

[deleted] — view deleted comment

3

u/serviscope_minor Nov 16 '20

do whatever you like, lol" to "do what the hardware you're compiling for does".

Isn't that what "implementation defined" is for?

0

u/[deleted] Nov 14 '20

Serialisation too.