Re: Compile time of C++ vs C#

Stephen Horne <>
Thu, 03 Sep 2009 04:44:29 +0100

          From comp.compilers

Related articles
Compile time of C++ vs C# (Shirsoft) (2009-09-01)
Re: Compile time of C++ vs C# (Marco van de Voort) (2009-09-02)
Re: Compile time of C++ vs C# (Hans-Peter Diettrich) (2009-09-02)
Re: Compile time of C++ vs C# (BGB / cr88192) (2009-09-02)
Re: Compile time of C++ vs C# (Stephen Horne) (2009-09-03)
Re: Compile time of C++ vs C# (BGB / cr88192) (2009-09-03)
Re: Compile time of C++ vs C# (Olivier Lefevre) (2009-09-04)
| List of all articles for this month |

From: Stephen Horne <>
Newsgroups: comp.compilers
Date: Thu, 03 Sep 2009 04:44:29 +0100
References: 09-09-009
Keywords: performance
Posted-Date: 03 Sep 2009 00:32:45 EDT

On Tue, 1 Sep 2009 13:15:35 -0700 (PDT), Shirsoft <>

>I am curious to know why C# code much faster than a similar sized C++
>code. How does MSIL help? Does having a common base class like object
>help in reducing compile times?
>[The optimizer is usually the slowest part of a compiler and I would guess that
>MSIL offers fewer opportunities than native code. -John]

Maybe, but I would have thought templates have a lot to answer for WRT
compile times in C++. C# has generics, but they probably use a
relatively simple model - the generic is compiled separately, but a
closure-like structure is used to fill in instance parameters. C++
templates are more like a kind of broken Haskell that gets interpreted
at compile-time to generate new code.

Obviously Haskell can be compiled, and templates could in principle be
compiled in much the way that many (most?) scripting languages are
compiled to a virtual machine model these days even when used
interactively. I dare say recent compilers do a lot to optimise
template handling. Still, I expect there's a fair amount of overhead
there just from using the standard library. And if you have a template
library that's prone to bloat, of course, you have a slow build
because of all the template instantiations that are being generated
and optimised.

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.