Re:Ask HN: What is it about compiling that is so time-consum...
by madethissoicou on Monday January 30, 2023 @01:25PM
(#34584130)
one issue in c/c++ is that each compilation unit (i.e. cpp file) includes tons of headers which in turn include tons more headers. so it's like an O(n^2) kind of growth where n is source size. obvs you can do better if you're careful about dependencies
[ Parent
| on HN ]
Re:Ask HN: What is it about compiling that is so time-consum...
by yetihehe on Monday January 30, 2023 @01:31PM
(#34584225)
Compound that with inability to cache those headers between different compilation units because each time you include a header, it can behave differently thanks to preprocessor definitions, but you can't really make dependency of those definitions because even changing order of header inclusion can make difference to those definitions.
Re:Ask HN: What is it about compiling that is so time-consum...
by canucker2016 on Monday January 30, 2023 @02:54PM
(#34585470)
...which is why sane, large projects use precompiled headers (PCH).
C (and later C++) compilers have used precompiled headers since at least the late 80s.
PCH speeds up compilation and roots out (hopefully, the few) cases where precompiled headers fail.
But C/C++ wasn't designed for a world where tens/hundreds of programmers build an app measured in the tens/hundreds of megabytes.
Re:Ask HN: What is it about compiling that is so time-consum...
by CyberDildonics on Monday January 30, 2023 @07:14PM
(#34588805)
There is no reason to lump these together. C will compile practically instantly if there are no optimizations on while C++ will still take a non trivial chunk of time. SQLite is 6 MB of pure C and it compiles in a fraction of a second with the msvc compiler.