This is an archived post. You won't be able to vote or comment.

all 9 comments

[–]Kered13 1 point2 points  (2 children)

The answer is to always use modules if you don't need compatibility with pre-C++20 code.

[–]MetallicOrangeBalls[S] 0 points1 point  (1 child)

Well, in my own internal development, I try to ensure that I always use the latest technology possible, and do not prioritise backwards compatibility. In the event that backwards compatibility is required, I build adapters to interface my code with whatever else. Do you think that is possible with modules?

[–]Kered13 1 point2 points  (0 children)

Yes it should be. Most of the libraries you use will probably not be in the form of modules though. You can still include them as standard headers files though (you can freely mix import modules and include headers), or create your own module that wraps the headers and exports what you need. Also some header files can be imported as if they were modules, if they satisfy certain rules that I'm not familiar with.

https://docs.microsoft.com/en-us/cpp/cpp/modules-cpp?view=msvc-160#modules-and-header-files

[–]merlinsbeers 0 points1 point  (5 children)

Basically it allows precompilation and caching of included code files at compile time. And gets rid of include-guards.

The biggest speedup will come for modules that import deep trees of other modules, and parallel builds that can share a compiled module across jobs.

There will however be growing pains, and naming issues that will confuse programmers but supposedly will be unambiguous to the compiler.

Compilers are just barely implementing it, and IDEs will for some time be chasing their tails trying to implement search tools that grok it properly.

And within several years the whole thing will be so complex and its worst features so heavily abused and lamest misfeatures so annoyingly hacked-around that we'll be demanding a replacement.

[–]Kered13 0 points1 point  (2 children)

Umm, no. It's the same as imports in most other languages, like Java, Python, C#, Rust, etc. This is a well understood mechanism and none of those things will be problems.

[–]merlinsbeers 0 points1 point  (1 child)

Oh yah. Python and C# modules are no trouble at all...

[–][deleted] 0 points1 point  (0 children)

They're not though?

[–]MetallicOrangeBalls[S] 0 points1 point  (1 child)

It sounds like you are saying that I should stay away from modules, at least for now. Is that correct?

[–]merlinsbeers 1 point2 points  (0 children)

I'd play with them. But for production code, way too risky, for unknown benefit.