|C++ vs C compiler on size firstname.lastname@example.org (1997-01-07)|
|Re: C++ vs C compiler on size email@example.com (Arch Robison) (1997-01-09)|
|Re: C++ vs C compiler on size firstname.lastname@example.org.OZ.AU (1997-01-12)|
|Re: C++ vs C compiler on size email@example.com (1997-01-12)|
|Re: C++ vs C compiler on size firstname.lastname@example.org (1997-01-12)|
|Re: C++ vs C compiler on size email@example.com (Stanley Chow) (1997-01-14)|
|Re: C++ vs C compiler on size firstname.lastname@example.org (Joseph Donahue) (1997-01-14)|
|Re: C++ vs C compiler on size email@example.com (1997-01-16)|
|Re: C++ vs C compiler on size firstname.lastname@example.org (Kurt Svensson) (1997-01-16)|
|From:||email@example.com (John Lilley)|
|Date:||12 Jan 1997 11:49:48 -0500|
|Organization:||Nerds for Hire, Inc.|
|Keywords:||C, C++, performance|
>On average, how much bigger the code generated by C++ compiler than C
Hey, nice reply! I love it when someone takes the times to write small
articles that really explain the problem.
Arch Robison wrote:
>  Separate discussion issue: Is it theoretically possible for a C++
> compiler to always generate machine code linear in the size of the
> source? If so, is the theoretical implementation practical?
Gee, I know we're gonna open up a big long thread with this one...
Theoretically, of course you can ;) You generate an executable that
contains a C++ interpreter, which is presumably of fixed size, and the
source code. Not very practical though. I am guessing when I say
that it can be done practically as well, given that template expansion
usually results in very similar sets of code that a plausibly
intelligent compiler/linker could merge the similar cases. But I'm
grasping... The complexity of the type interactions in the template
code, make it so darn hard to merge the resultant specializations.
>  Perhaps someone reading this can provide references on fat-reduced
> use of templates?
Mogens Hansen has a great article in the Jan 97 C++ Report on "Ways to
reduce code bloat from containers", which details some wrappers around
STL containers that work for a restricted family of types (e.g., all
derived from one base or all pointers). Best of all I think that you
can extrapolate this technique to other template domains (like
reference-counted pionters) to acheive similar results. Of course,
the tradeoff is that you lose a little bit of type-safety, but with
some care even that can be mitigated.
Return to the
Search the comp.compilers archives again.