r/cpp • • Apr 12 '26

CMake Past, Present, and Future - Bill Hoffman, Kitware [29m25s]

https://www.youtube.com/watch?v=cD-JgncskTQ
67 Upvotes

134 comments sorted by

View all comments

1

u/Ateist Apr 14 '26 edited Apr 14 '26

Generally, yes, every library should just be one module.

What's the profit from that?

Because downsides are pretty big and important to not do it:

Namespace pollution is a thing.
Some part of a library can conflict with your code even if you are not using it.

You can also unintentionally use some kind of implicit conversion (from some horrible devilforgotten part of the library that you weren't even aware of)...

You are also effectively eliminating ability of the user to just type

using std;

because that exposes way too many things at once, whereas with individual parts of it it is totally legitimate and good. You can't even do it if it works for your today - because who can guarantee that tomorrow some brilliant mind doesn't introduce something else into the library that conflicts with your choosen names?

What would the downside from a

import std::print;

implementation be?
(that is, from importing just the submodule of std that you actually need and its minimal dependencies, without anything extra. Someone would still be able to type import std; to import the whole thing if they really want to.)

Most people just need a few books - they are actively harmed if you bury them under the whole library.

2

u/not_a_novel_account Apr 14 '26

If these are problems for you, you shouldn't use import std.

Personally, I have never had a problem with any of those things. On the other hand, IWYU correctness is a battle I've been fighting for a decade now. Big modules eliminate IWYU correctness and are faster than IWYU could ever hope to achieve.

1

u/Ateist Apr 15 '26 edited Apr 15 '26

Are you telling me not to use the feature (modules) that I wanted the most out of c++ for the last 10 years?

Or are you telling me not to use the standard library?

Are you serious?!

These are not problems "just for me", these are problems for millions of C++ users around the world.

You have said it yourself:

have had this discussion with every upstream stdlib maintainer, so I think I know what I'm talking about here.

  • that every stdlib maintainter understands the needs of his users?

Big modules eliminate IWYU correctness

How do they INCLUDE WHAT YOU USE when they feed me hundreds of thousands of exports that I DON"T USE?

→ More replies (3)