Re: C++ Frequently Questioned Answers
on Fri Nov 02 2007, Walter Bright <walter-AT-digitalmars-nospamm.com> wrote:
Hyman Rosen wrote:
Yossi Kreinin wrote:
The problems with the build speeds of templates are inherent to the
design of this language feature
I work with a project that contains many hundreds of C++ files,
pretty much all of which use class and function templates from
the standard library and our own. I can do a clean recompile of
the whole system in ten or fifteen minutes or so on my Solaris
x86 machine using the Sun CC 11 compiler. For normal work, the
source compilation time is inconsequential - it's linking that
takes most of the time, and even that isn't too long.
I've heard many reports of heavily templated C++ code having build times
measured in hours - such as overnight builds. Even so, a build time of
ten minutes is very consequential. Having a build time of a few seconds
can completely transform how one develops code.
I know very well how and why templates slow down compilation, and this
is inherent to how C++ templates work. It is not fixable.
We did a fair amount of testing of template instantiation speed for
http://www.amazon.com/Template-Metaprogramming-Concepts-Techniques-Depth/dp/0321227255
and we found a huge variation between the slowest and fastest template
instantiators. So there's great room for improvement in at least some
compilers.
But even the fastest ones have performance problems because they do a
linear walk through a list of template specializations each time a
specialization is mentioned. An O(1) hash table lookup should make a
big difference. Why do you think it's not fixable?
--
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]