Live data from Hacker News

C++ Headers are Expensive

virtuallyrandom.com

111–115 of 115 posts

Re: C++ Headers are Expensive

#111
post #99

Earlier quoted context omitted.

Sure, I was only mentioning that it is possible. However with VC++ it doesn't seem to be that bad, when incremental compilation and linking are enabled.

According to MS[0], LTCG doesn't work with /INCREMENTAL (note /LTCG:INCREMENTAL is different). For my use cases, LTCG is unusable for anything other than our overnight builds. [0] https://docs.microsoft.com/en-us/cpp/build/reference/ltcg-li...

Thanks for the correction.

That's what happens when I spend most the time on JVM/.NET worlds. :)

Re: C++ Headers are Expensive

#112
post #61

Earlier quoted context omitted.

Just to address part of your concern: Traditionally disk speed makes very little difference to compile times for real world C/C++ projects. This is because real world projects have many files, and each one can be compiled in parallel. Once you spawn sufficient compilers in parallel, the CPU becomes the bottleneck, not the disk. (I.e. when a compilation asks for I/O, it then yields the CPU to other compilers which hav…

Absolutely not true. The problem is not the compilation of one single file, but that every one of these single files pulls in large amounts of headers, distributed over various libraries (e. g. Qt/Boost/STL), all of which won't fit into the disk cache. If it doesn't make a difference, all that means is that your project is small, or doesn't have too many dependencies. Good for you. But that's not the reality for all…

My projects take 10 minutes to build on a modern system, which is plenty complicated enough. Don't appreciate the "good for you" flippancy.

Re: C++ Headers are Expensive

#113

Earlier quoted context omitted.

Do you also write all your functions to pass large inputs by value until a profiler says you can pass a const reference? Some implementation details are so well understood that you really don't need a profiler to do what is probably the right thing by default.

> Do you also write all your functions to pass large inputs by value until a profiler says you can pass a const reference? No, but neither do I pass types that fit in a native integer by const reference because copies should be avoided at all costs. There is always a tradeoff. > Some implementation details are so well understood that you really don't need a profiler to do what is probably the right thing by default.…

Avoiding any and all indirection at all costs is not one of these.

"Any and all"? Perhaps not. However, I believe the context here was standard library headers. Those are full of small, often-used functions, so avoiding idioms based on indirection such as pImpl is about as close to a black and white rule as you're ever going to find in the programming world.

Re: C++ Headers are Expensive

#114

Earlier quoted context omitted.

> Do you also write all your functions to pass large inputs by value until a profiler says you can pass a const reference? No, but neither do I pass types that fit in a native integer by const reference because copies should be avoided at all costs. There is always a tradeoff. > Some implementation details are so well understood that you really don't need a profiler to do what is probably the right thing by default.…

Avoiding any and all indirection at all costs is not one of these. "Any and all"? Perhaps not. However, I believe the context here was standard library headers. Those are full of small, often-used functions, so avoiding idioms based on indirection such as pImpl is about as close to a black and white rule as you're ever going to find in the programming world.

Nowhere did I say that pImpls should only be used. That was only one of several strategies I discussed.

The article may have discussed standard headers, but it was neither titled to indicate that it was talking about only standard headers, nor are the problems it discussed localized only to standard headers. My original comment did not limit the discussion to only standard headers.

Re: C++ Headers are Expensive

#115
post #111

Earlier quoted context omitted.

According to MS[0], LTCG doesn't work with /INCREMENTAL (note /LTCG:INCREMENTAL is different). For my use cases, LTCG is unusable for anything other than our overnight builds. [0] https://docs.microsoft.com/en-us/cpp/build/reference/ltcg-li...

Thanks for the correction. That's what happens when I spend most the time on JVM/.NET worlds. :)

Yeah, the situation in .NET is much healthier as far as I've seen!
Post reply on HN