Boost logo

Boost Users :

From: David Abrahams (dave_at_[hidden])
Date: 2003-10-20 17:54:01


Marton Fabo <morton_at_[hidden]> writes:

>>> This is way too much. I'm not using any so that much advanced stuff
>>> that it would be justified - and the compilation time is
>>> inacceptable for such a small app.
>>>
>> Just out of curiosity, why is compilation time a big deal? I
>> understand being concerned about the size of the final executable,
>> but how often are you compiling? (and if it's that often, why?).
>
> Sometimes. It's a maturing program with maturing specifications. I, of
> course, need to make a lot of modifications, and test their effect,
> not just code blindly. So I have to compile often.
>
> And, just to add to the problem, because of the ever changing
> expectations, there are a lot of header modifications, which naturally
> cause recompilation of all the affected units - even slower test
> cycle.
>
> I'm not sure about that the progress bottleneck really should be code
> bloat caused by a library - or that it should force me to perform a
> different programming cycle style. Additionally, that (less frequent
> compiling and testing) wouldn't fix, just work around the problem at
> hand.

As we move more and more smarts into compile-time code (template
metaprogramming), compilation times naturally go up, especially since
C++ templates weren't really designed for the sorts of things we're
asking of them. The possibility of Template Metaprogramming is sort
of a lucky accident. You can cut the compilation time a bit by using
only the "portable" syntax and #including only
<boost/function/functionN.hpp> for the appropriate Ns. That will
expose less code to the compiler, though I wouldn't expect a dramatic
change.

The interesting thing about your problem is that Boost.Function is
exactly the sort of thing one uses to *eliminate* recompilation
dependencies: by hiding the real type of the member/function pointer
or function object it wraps behind a single polymorphic type, you can
prevent changes to the wrapped type from affecting other code.

One thing to keep in mind: Boost.Function can be expensive to copy
(both in time and in code space) if you're wrapping stateful function
objects. Consider passing it by reference.

HTH,

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net