Hacker News new | ask | show | jobs
by vrodic 1631 days ago
Sounds like headers in general are not necessarily a good idea.

They provide flexibility but at a cost.

I enjoyed Borland Pascal compilation speeds and clean dependencies before switching to Linux. I miss it, together with Delphi.

2 comments

C++ has been trying modules, and Gabriel Dos Reis from Microsoft has gotten a pretty decent standard and implementation done. It's likely it will be added to the C++23 standard. The biggest issue seems to be "What cross compiler format do we use for the compiled modules" (the equivalent of DCUs). The other problem is that macros have to still work, and code that uses them will not benefit as much from modules.

The gains in compilation speed (including linking) and dependency information tracking is phenomenal though. It would certainly bring C++ in line with languages like Java, Rust etc.

The CPPCon 2021 talk about this is enlightening.

If C++ gets modules, there is no reason why C can't use the same model - since the compilers will have that stuff anyway.

Modules are part of C++20
And it's telling that we're in 2022 and still the only compiler with full C++ module support according to cppreference [0] is MSVC.

[0] https://en.cppreference.com/w/cpp/compiler_support

https://clang.llvm.org/cxx_status.html

https://gcc.gnu.org/projects/cxx-status.html

The c compilation model is tuned for ancient hardware. On modern hardware, incremental compilation isn't all that useful, so the entire import/header model makes less sense.