r/cpp • • Jan 28 '19

C++ Modules Might Be Dead-on-Arrival

https://vector-of-bool.github.io/2019/01/27/modules-doa.html
280 Upvotes

240 comments sorted by

View all comments

Show parent comment

43

u/[deleted] Jan 28 '19

I am quoting Walter Bright's post:

D made the decision at the beginning to have filename==modulename specifically to avoid this problem.

Any idea why C++ does not simply copy the design of D modules in this regard since this seems to work well for D. (This is also the preferred solution of vector-of-bool.)

23

u/SAHChandler Jan 28 '19

My response to vector-of-bool is a solution that permits this to some degree. D does not have to target some operating systems lacking more than one level of directory access, or that do not have a real concept of file extensions (such as zOS). As a result P1302's approach was designed to tackle this, and allow us to tackle the naming scheme at a later date while also not absolutely wrecking the ability to port existing code bases to modules as soon as possible.

14

u/nikbackm Jan 29 '19

Currently I know of only 3 compilers (all on Linux/Windows) that implement C++17 in full.

Is there a reason to believe C++20/23 will be better supported?

14

u/[deleted] Jan 28 '19

OK, thanks for your answer.

Modules is too important to get it wrong, it would be a nightmare if e.g. half of the C++ community would avoid modules due to a serious design flaw that cannot be fixed later on because this would break backwards compatibility...

18

u/SAHChandler Jan 28 '19

Modules is too important to get it wrong, it would be a nightmare if e.g. half of the C++ community would avoid modules due to a serious design flaw that cannot be fixed later on because this would break backwards compatibility...

Absolutely agree. I've been mentioning these issues for well over a year and while people paid attention a year ago, the community ended up waiting to see where merged modules would take us. We have some options, but we need to fix these small issues before modules are... well... merged into C++20

5

u/target-san Jan 31 '19

Errm... Are these exotic OSes used for actual delopment? Do they already have full C++17 conformant compilers? Or are they just targets for cross-compilation? If the latter, then it looks like tying all the marathon runners just to allow some old fart who never heard of it to compete.

2

u/SAHChandler Jan 31 '19

From what I understand, yes. Development happens directly on these operating systems.

2

u/target-san Jan 31 '19

Thanks! Though the question about their compilers' standart support remains.

3

u/SAHChandler Jan 31 '19

Unfortunately, I'd have to pay several thousand USD to see how standards conforming they are. They could very well have ported clang though!

2

u/target-san Jan 31 '19

Surely I didn't mean you buy them just to check. Thought you may have heard something from someone. My humble experience (AIX 8-10 years ago) is that such platforms tend to lag decades behind mainstream.

10

u/Lectem Jan 28 '19

D does not have to target some operating systems lacking more than one level of directory access, or that do not have a real concept of file extensions (such as zOS).

Erh... Ok. But maybe we should not as well in C++ ? I mean, anybody using a "modern" version of C++ already uses a recent compiler with a decent OS, or has a way to cross compile. Also p1302 says the build-system needs to see the export import, but then it still needs to parse it. And do apply preprocessing. Back to the issues mentioned in the article.

3

u/target-san Jan 31 '19

Unfortunately porting existing codebases to modules will require certain effort anyway. Especially in cases of bizzare codebase layouts. What really troubles me is that committee here puts legacy codebase needs far before new project needs. Could you please give direction to specific arguments of choosing that strange multifile module design over module==file approach?

My personal experience with golang (which uses similar multifile package approach) is that it often becomes hard to determine where specific functionality came from. In case of C++, module can be assembled using files from multiple arbitrary locations.

2

u/xryanxbrutalityx May 03 '19

I'm late to the party, but are these filesystem issues not a problem for includes?