Subject: Re: [boost] [Booster] Or boost is useless for library developers
From: Stewart, Robert (Robert.Stewart_at_[hidden])
Date: 2010-05-19 15:57:40
Gennadiy Rozental wrote:
> Stewart, Robert <Robert.Stewart <at> sig.com> writes:
> > Artyom wrote:
> > >
> > > Heavy template code produces significantly lager code. So hiding
> > > implementation actually reduces code size and reduces bloat.
> > Ridiculous. Misuse of templates can do so, but I doubt
> > you'll find (m)any examples in Boost. Templates
> > expose more code to the compiler permitting otherwise
> > impossible optimizations. Expression templates, for example,
> > eliminate tremendous runtime code and overhead utterly impossible
> > to do otherwise.
> I do not think this is ridiculous. This is well known fact.
> Templates do lead to the larger code size and larger
> compilation time. You can hardly argue with that.
Template code must, of necessity be duplicated in any shared library or application using it with the same type, to be sure. However, discounting that form of size increase, there is nothing about templates that would cause bloat except failure to factor out non-dependent code. Non-dependent code, of course, must then be inlined to be header only, and *that* can lead to code bloat. The foregoing, however, does not translate to "template code produces significantly larger code."
> The same time I agree that they lead to better performance in
> many cases. Not
> always. I had number of real life scenarios where excessive
> inlining lead to
> losing locality and eventually worse performance.
Of course. Premature optimization is often pessimization. It's hard to get right.
> You always need to balance these two forces. If you get 0.5%
> advantage, but required to add half an half an hour to the
> compilation, your
> choice is pretty much clear, right?
> An ability to define this boundary between what to put in
> headers and what to
> offline correctly is important designer quality.
Rob Stewart robert.stewart_at_[hidden]
Software Engineer, Core Software using std::disclaimer;
Susquehanna International Group, LLP http://www.sig.com
IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk