Note that there are some explanatory texts on larger screens.

plurals
  1. POIs C# really slower than say C++?
    text
    copied!<p>I've been wondering about this issue for a while now. </p> <p>Of course there are things in C# that aren't optimized for speed, so using those objects or language tweaks (like LinQ) may cause the code to be slower. </p> <p>But if you don't use any of those tweaks, but just compare the same pieces of code in C# and C++ (It's easy to translate one to another). Will it really be that much slower ?</p> <p>I've seen comparisons that show that C# might be even faster in some cases, because in theory the JIT compiler should optimize the code in real time and get better results: </p> <p><a href="http://www.grimes.nildram.co.uk/dotnet/man_unman.htm" rel="nofollow noreferrer">Managed Or Unmanaged?</a></p> <p>We should remember that the JIT compiler compiles the code at real time, but that's a 1-time overhead, the same code (once reached and compiled) doesn't need to be compiled again at run time.</p> <p>The GC doesn't add a lot of overhead either, unless you create and destroy thousands of objects (like using String instead of StringBuilder). And doing that in C++ would also be costly.</p> <p>Another point that I want to bring up is the better communication between DLLs introduced in .Net. The .Net platform communicates much better than Managed COM based DLLs. </p> <p>I don't see any inherent reason why the language should be slower, and I don't really think that C# is slower than C++ (both from experience and lack of a good explanation)..</p> <p>So, will a piece of the same code written in C# will be slower than the same code in C++ ?<br> In if so, then WHY ?</p> <p>Some other reference (Which talk about that a bit, but with no explanation about WHY):</p> <p><a href="https://stackoverflow.com/questions/787375/why-would-you-want-to-use-c-if-its-slower-than-c">Why would you want to use C# if its slower than C++?</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload