• 0

Compilation speed - C# vs C++


Question

Hello, a lot of people say C# compile way faster than C++, and it's also my experience. However, for my essay I would need some kind of reliable bibliographic source to make this claim, and I'm having trouble finding any.

So if you know of any benchmark of C# compilation vs C++ compilation I'd be grateful.

Also, why exactly would C# compile so much faster? Because it only translates into IL? Because there are no header files to parse? No templates? Other reasons?

Thanks.

Link to comment
https://www.neowin.net/forum/topic/691220-compilation-speed-c-vs-c/
Share on other sites

6 answers to this question

Recommended Posts

  • 0
  Dr_Asik said:
Hello, a lot of people say C# compile way faster than C++, and it's also my experience. However, for my essay I would need some kind of reliable bibliographic source to make this claim, and I'm having trouble finding any.

So if you know of any benchmark of C# compilation vs C++ compilation I'd be grateful.

Also, why exactly would C# compile so much faster? Because it only translates into IL? Because there are no header files to parse? No templates? Other reasons?

Thanks.

Well first thing first, C# doesn't compile to machine code but to byte code, so that might explain why it's faster.

But really my question is: who cares? How much time do you really spend compiling ? Is C# that much faster that it makes that much of a difference?

  • 0

Initially I thought: get a large piece of source code and time yourself. But that wouldn't work, because you're changing to many variables:

- The language

- The compiler

- The actual source code (because of the language)

Because of this you can't state that "large program x" compiles faster under C#, compared to C++ because "large program x" will only be written for one of the languages and not the other, and even if it is written for both, it will be implemented differently (due to the language differences). Meaning the compile times cannot be compared, because you are effectively timing the compilation of two different programs. Which is just as bad as comparing the compile times of a simple "Hello World" application to some gigantic thing like MySQL.

If you wanted to do a fair comparison you could time the compilation of some C++ source code using different compilers, or different versions of the same compilers. (Comparing two different compilers may have some problems due to the different build systems.)

The most similar experiment to this would be to compile the same C code on a C and then C++ compiler, this still has the problems of changing 2 variables though (language and compiler).

  • 0
  Rudy said:
But really my question is: who cares? How much time do you really spend compiling ? Is C# that much faster that it makes that much of a difference?
At my intership this summer I spent anywhere between 10% and 70% of my time waiting for the C++ compiler to instantiate all the templates and stuff. Sometimes linking would take a few minutes by itself. That was a huge drain to my productivity. Sure we could have figured out ways to reduce the burden given to the compiler each iteration, but my feeling is that with C# that wouldn't even have been necessary.

Also, I'd like to talk about it for my essay.

  • 0

There are more factors then simply what compiler you are testing on. What performance does the actual machine provide?

The biggest difference is how the compilers generally work. In C# (and any .NET language), it is compiled into IL. Only at first run doesn JIT (Just in time) compilation occur (thats generally why .NET apps run a little slower to begin with (this can be wavered by using NGEN). Compilation into IL is relatively quick (although I have had projects that do take a while to compile). With C/C++ compilers, the compiler is doing more tasks, including compiling and optimising the object code.

  • 0
  Dr_Asik said:
At my intership this summer I spent anywhere between 10% and 70% of my time waiting for the C++ compiler to instantiate all the templates and stuff. Sometimes linking would take a few minutes by itself. That was a huge drain to my productivity. Sure we could have figured out ways to reduce the burden given to the compiler each iteration, but my feeling is that with C# that wouldn't even have been necessary.

Also, I'd like to talk about it for my essay.

that's what make files are for. It will only compile the files that have changed and the files affected by these changes

  • 0
  Dr_Asik said:
At my intership this summer I spent anywhere between 10% and 70% of my time waiting for the C++ compiler to instantiate all the templates and stuff. Sometimes linking would take a few minutes by itself. That was a huge drain to my productivity. Sure we could have figured out ways to reduce the burden given to the compiler each iteration, but my feeling is that with C# that wouldn't even have been necessary.

Also, I'd like to talk about it for my essay.

Part of the advantage of bytecode-based languages is that compiling will be quicker. However, C++ has very significant performance advantages over Java or .Net. That's basically, for example, why every major game is written in C++ or in C. The optimization features of lower level languages are important when developing a big application. There are also many resources out there to help speed up C++ compilation.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.