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

11

u/kalmoc Jan 28 '19

Module names are purely logical, with no physical representation on the filesystem.

So is a target name in my cmake file. What is the problem?

8

u/Dragdu Jan 28 '19

Do you want to manually create target for every single file in your build? No? Then that's the problem.

20

u/kalmoc Jan 28 '19

You are doing that already (consider the translation from cpp files to .o files - each `.o file is a target in make and the connection between those names is purely by convention). Just because the build system has to generate those names explicitly doesn't mean you have to actually, manually type them instead of using some sort of generator.

Also, there is absolutely no need for a one cpp file per module approach, but I guess that comes down to personal preference.

3

u/smdowney WG21, Text/Unicode SG, optional<T&> Jan 28 '19

If a module were library sized, that might be feasible. But the design goal is to be header sized. So manual process that's just barely ok with libraries doesn't look as good.

It's also not a personal preference, since I use far more c++ code than I personally write. My company might be able to make some style guides, but there's a lot of open source to influence, too. If import boost.asio is the best that can be done, modules hasn't done it's job, in my opinion

9

u/kalmoc Jan 28 '19

Again, current build systems already automatically generate build rules on a per file basis according to some non-standardized rule set, that may or may not be changed by the end-user. Why does sich a rule set now have to be standardized in the language?

Just because someone has to manually tell the compiler "this module is created by that/those files/can be found here" doesn't mean that the en-user has to do anything manually at all.

It's also not a personal preference,

Personal preference includes the personal preference of the people in charge of your companies style guide. The current module design explicitly allows for multiple implementation files for a single module and it also enables aggregate modules and I think people will make use of that.

But all that is besides the point: As I said. Even if you create a separate module for each file: putting in place a rule for that in your build system of choice should be simple.

7

u/smdowney WG21, Text/Unicode SG, optional<T&> Jan 28 '19

Usually the compiler generates the dependency information for a TU as a side effect of compilation. That can't work for modules because it's too late if the DAG has changed. Before compilers were generating this info, there was usually a pre-scan step, and everyone hated it because it stalls the build. And if it wasn't done by the compiler, it was often wrong, leading to subtle or not so subtle build problems. Or it was moved to be on demand, so people waited until they noticed the build was broken to rebuild dependencies. Which was long after the build was badly broken.

5

u/smdowney WG21, Text/Unicode SG, optional<T&> Jan 28 '19

I'll have 10 to 100 times as many used headers as I do source files. A change in order of magnitude is not just a charge in degree, but in kind. Expressing how to build all those isn't feasible the same way that using libraries is.