Why Compilation Speed Differs a lot in C++ and C#?

Possible Duplicate:
Why does C++ compilation take so long?

Coming from C# background, I can't help but notice that the speed of compilation for C++ and C# code differs a lot-- C# is very fast to compile, but C++ is comparatively slow-- very slow, in fact.

Why is this so?


Two big reasons:

  • C++ has to go and #include and parse all the header files (which means reading text files and interpreting them -- including templates -- and then expanding them right into your code) whereas C# uses pre-compiled information in the assembly DLLs.

  • The potential C++ optimizations are way more far-reaching than the C# optimizations; they easily blow C# out of the water. The C# compiler never inlines a function call (that's the Just-In-Time compiler's job to do in the CLR), but C++ compilers frequently do that, and much more. The C++ compiler also has to do the JIT's compiler for the entire program at compile time (and then some!), so it's definitely slower.

  • I'd say that the biggest culprit is optimizations -- try turning off all optimizations in your compiler, and noticing the speedup.

    链接地址: http://www.djcxy.com/p/14968.html

    上一篇: 可以使用哪些技术来加速C ++编译时间?

    下一篇: 为什么编译速度在C ++和C#中有很大不同?