News for hackers. Stuff that matters.
Re:C++17 – better than you might think by mrich on Thursday December 29, 2016 @07:25AM (#13276921)
Modules are the answer, but it seems nobody cares enough to get them in the standard or, more likely, it's just too hard a problem.

Having looked at the clang modules implementation you basically have to clean up all the system includes, the standard library and your own headers before you can use them. And you will have to rewrite many things in these headers due to changed preprocessor semantics.

I think neither the clang nor MSVC implementations can be used for anything but the most trivial code due to these issues.

There are talks from Google who invested heavily into modules using clang and got gains, but as far as I understand they fixed those issues only for themselves.

More info welcome.

At this point the only cure is brute force (blades with many cores are not that expensive, or a distributed compile cluster) and always taking care with your includes.

Re:C++17 – better than you might think by Joky on Thursday December 29, 2016 @12:35PM (#13278639)
> Modules are the answer, but it seems nobody cares enough to get them in the standard or, more likely, it's just too hard a problem.

Aren't modules especially limited with the mentioned problem of templates? If I have a vector of a custom type, I still have to instantiate it in every file that is using this type, I don't think modules help much here, they reduce the amount of time parsing, not instantiating if I understand correctly.

We'll need to significantly change the way we handle templates in compilers to get significant improvement.

Re:C++17 – better than you might think by netheril96 on Thursday December 29, 2016 @08:01PM (#13281684)
Most of the time the same template with the same parameters are instantiated multiple times. If modules work, there should be only one compilation.
Re:C++17 – better than you might think by jimbokun on Thursday December 29, 2016 @10:49AM (#13277895)
"There are talks from Google who invested heavily into modules using clang and got gains, but as far as I understand they fixed those issues only for themselves"

I thought Google fixed the C++ compile time problem by inventing Go?

Re:C++17 – better than you might think by krona on Thursday December 29, 2016 @11:06AM (#13278033)
Inventing a new programming language is hardly sufficient if your existing codebase is 10M lines of c++ :).
Re:C++17 – better than you might think by haberman on Thursday December 29, 2016 @12:14PM (#13278485)
If we're talking about Google, I think the number is at least one order of magnitude larger. A year ago Google estimated it at 2 billion lines, though that appears to include all languages (not just C++): https://www.wired.com/2015/09/google-2-billion-lines-codeand...
Re:C++17 – better than you might think by lmm on Thursday December 29, 2016 @01:00PM (#13278810)
If the new language has good interop with C++ then it can be.
Re:C++17 – better than you might think by ori_b on Thursday December 29, 2016 @01:21PM (#13278944)
Good interop with C++ means parsing and instantiating templates. This means you have a C++ compiler.
Re:C++17 – better than you might think by usefulcat on Thursday December 29, 2016 @01:13PM (#13278900)
It doesn't help at all as soon as you need to do anything that requires compiling those 10M lines of legacy code (think bug fixes, for example).
Re:C++17 – better than you might think by user5994461 on Thursday December 29, 2016 @01:55PM (#13279176)
No language has good interop with C++.
Re:C++17 – better than you might think by OlaOst on Thursday December 29, 2016 @06:38PM (#13281203)
The D language, while not 100% C++ compatible, takes a pragmatic approach to C++ interop (https://dlang.org/spec/cpp_interface.html)
Re:C++17 – better than you might think by the_why_of_y on Saturday December 31, 2016 @04:49PM (#13293360)
Not even C++ has good interop with C++, given how underspecified it is. Is that library built with MinGW or with Visual Studio?
Re:C++17 – better than you might think by vvanders on Thursday December 29, 2016 @01:08PM (#13278861)
Last I looked at Go is was missing pinning and few other things that are necessary for interacting with native code.
Re:C++17 – better than you might think by agentgt on Thursday December 29, 2016 @12:08PM (#13278448)
No they invented their own build system and tools (Bazel). Although some of the tools are open source the true distributed compile scaling stuff I think is still not.
Re:C++17 – better than you might think by paulddraper on Thursday December 29, 2016 @03:42PM (#13279954)
No, they invented Blaze (general purpose caching build tool, open-sourced as Bazel).

Go is hardly a replacement for C++. Garbage collection, no templates, no const, etc.

Re:C++17 – better than you might think by pjmlp on Thursday December 29, 2016 @08:05AM (#13277040)
Modules are on the good track, looking from the latest CppCon and LLVM talks,they have progressed a lot on their internal use.

I am confident that by C++20 they will be available.

The main problem will be the adoption by major libraries.

Re:C++17 – better than you might think by mrich on Thursday December 29, 2016 @08:12AM (#13277064)
Correct me if I'm wrong, won't we need an updated OS tool chain, i.e. kernel headers and libc/libstdc++ fully adjusted? That will take some work...
Re:C++17 – better than you might think by gpderetta on Thursday December 29, 2016 @10:39AM (#13277831)
Libstdc++ is normally distributed with the compiler, so it will be updated as required by the standard.

Regarding the libc and other headers, modules will still fullly support include files, so that won't be an issue. You should be able to include headers and export them as modules.

Re:C++17 – better than you might think by dom0 on Thursday December 29, 2016 @11:40AM (#13278266)
Kernel/system headers are C, or part of a compiler SDK.

libc and libstdc++ are part of the compiler runtime, ie. will be updated together with it.

Re:C++17 – better than you might think by pjmlp on Thursday December 29, 2016 @09:36AM (#13277445)
Just kind of.

Kernel headers are only an issue on free UNIX like OSes, on other OS what matters is what the SDK provides.

So at least in what concerns Apple, Google, Microsoft and every other commercial vendor OSes, don't expect a big issue having their SDKs updated when they start supporting modules.

The problem is getting the BSD, Linux and open source libraries without a specific agenda to adopt them.

Re:C++17 – better than you might think by cypher543 on Thursday December 29, 2016 @02:43PM (#13279496)
Clang uses "module maps" to turn existing header-based libraries into modules. So, theoretically, your system compiler could include a module map for all of the system headers. I don't know if module maps are going to be part of the standard, though.