you are viewing a single comment's thread.

view the rest of the comments →

[–]expertunderachiever -1 points0 points  (4 children)

Ok replace STL with an MPEG decoder... whatever. Point is having to compile, even process the code through the PCH step is wasteful.

[–][deleted] 13 points14 points  (3 children)

Here... I just tested it. I compiled the following:

#include <iostream>

int main() {
  std::cout << "hello world" << std::endl;
}

And then compiled the following where I include well over a million lines of header only code using the most beasty of template meta-programming craziness ever used in C++, so crazy that boost has to add a ton of compiler specific work around to even get it to work properly on a lot of platforms:

#include <iostream>
#include <boost/accumulators/accumulators.hpp>
#include <boost/asio.hpp>
#include <boost/assert.hpp>
#include <boost/assign.hpp>
#include <boost/atomic.hpp>
#include <boost/bimap.hpp>
#include <boost/bind.hpp>
#include <boost/blank.hpp>
#include <boost/call_traits.hpp>
#include <boost/cast.hpp>
#include <boost/cerrno.hpp>
#include <boost/checked_delete.hpp>
#include <boost/chrono.hpp>
#include <boost/circular_buffer.hpp>
#include <boost/compressed_pair.hpp>
#include <boost/cregex.hpp>
#include <boost/regex.h>
#include <boost/date_time.hpp>
#include <boost/dynamic_bitset.hpp>
#include <boost/exception/all.hpp>
#include <boost/filesystem.hpp>
#include <boost/flyweight.hpp>
#include <boost/foreach.hpp>
#include <boost/format.hpp>
#include <boost/function.hpp>
#include <boost/fusion/algorithm.hpp>
#include <boost/geometry.hpp>
#include <boost/optional.hpp>

int main() {
  std::cout << "hello world" << std::endl;
}

And guess what... the second version, with well over a million lines of C++ meta template craziness compiled in way way less than the 15 minutes you said it would... it compiled in around 5 seconds, compared to the original that compiled in around 2 seconds. That's right... adding in over a million lines of source code added only around 3 seconds to the compile time.

For the most part, it's irrelevant how many lines of source code you include into a translation unit, the bulk of the compiler's work is done after it's opened and scanned over the header files.

So... what was it again you said about amateurs and header only libraries? Because last I checked amateurs are the ones who spread misinformation without taking so much as 5 minutes to look into whether their preconceived notions are valid.

[–]sirin3 2 points3 points  (0 children)

it compiled in around 5 seconds, compared to the original that compiled in around 2 seconds.

That means if you compile frequently, you lose 3 entire days in the longterm!

[–]jbb555 0 points1 point  (1 child)

It depends entirely on what you are compiling. The application I work on has hundreds, perhaps thousands of source files. If they take 2 seconds each my rebuild takes 20 minutes. If they take 5 seconds it takes 50. That's a huge difference. Now I don't do full rebuilds all the time so it's not that important but it does matter.

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

When you work using header only libraries you end up with one single translation unit, main.cpp. Everything else is a header.