Program size, linking matter, and static this()

Adam D. Ruppe destructionator at gmail.com
Fri Dec 16 14:04:35 PST 2011


On Friday, 16 December 2011 at 21:45:43 UTC, Andrei Alexandrescu 
wrote:
> Once we solve the static constructor issue, function-level 
> linking should take care of pulling only the minimum needed.

This sounds fantastic.

> One interesting fact is that a lot of issues that I tended to 
> take non-critically ("templates cause bloat", "intermodule 
> dependencies cause bloat", "static linking creates large 
> programs") looked a whole lot differently when I looked closer 
> at causes and effects.

I'd be careful to overgeneralize from this though; templates
do have the potential to bloat things up, etc. Though
static linking has and always shall rok.


(For bloated templates, I had a monster of one in web.d
that shrunk the binary by about three megabytes by refactoring
some of it into regular functions. Shaved two seconds off the
compile time too! Note this binary is my work project, so your
results may vary with my library.

It was basically inlining several kilobytes of the same stuff
into hundreds of different functions... 10 kb * 300 functions
= lots of code.)


More information about the Digitalmars-d mailing list