Page 1 of 1

Article - Is Managed Code Slower Than Unmanaged Code?

Posted: Thu Aug 30, 2007 2:54 am
by Luke
I found this to be an interesting read:
http://www.grimes.demon.co.uk/dotnet/man_unman.htm

Re: Article - Is Managed Code Slower Than Unmanaged Code?

Posted: Thu Aug 30, 2007 9:42 am
by michal.kreslik
Luke wrote:I found this to be an interesting read:
http://www.grimes.demon.co.uk/dotnet/man_unman.htm


Now that's a cool article, Luke. Thanks for posting it!

A few months ago, I was talking about the advantages of the managed vs. unmanaged code with one of my former classmates who is now a successful professional programmer in Germany. Apart from many other languages, he is coding in C++ (both unamanged and .NET managed) as well as in C#.

I asked him whether there's a significant overhead in using C#.NET compared to the "rock-solid & ultimate pro" unmanaged C++ :) He said a crucial thing to me: it doesn't really matter what language do you code in or whether the code is managed or unmanaged in the first place, but it only matters how the actual resulting machine code looks (which is very true!). And he said that .NET does the hell of a good job when generating the actual machine code.

It seems like .NET MSIL + JIT compilation tandem simply generates a code that is perfectly "curve-fitted" to the actual CPU where the code is being run. These JIT runtime optimizations can't be done remotely at the programmer's desk.

A negative aspect of .NET code might be the time needed to JIT compile the code in some cases. If one would code an application that only performs a quick task once and exists, it would probably take more time to run such a managed app than an unmanaged that doesn't have to deal with JIT.

Concerning the "wonder compilers" of .NET, then obviously, if one would write a humpty dumpty code which is inefficient by definition, even the best set of compilers would not make much out of it. But that's true for any programming language, regardless of it being managed or unmanaged.

In this respect, when I was reading the NeoTicker manual for the first time, it was quite puzzling to me that the NeoTicker guys wrote the following in the IDL Interface / IDL Overview section:

NeoTicker manual wrote:If possible, you should compile the indicator into standard DLL or early binding ActiveX DLL. Late binding ActiveX DLL runs slower. .NET DLL run slowest.


I'm inclined to think that if the above is true, it's mainly because the NeoTicker COM Interop-based object model is ancient and needs replacing. Even the fastest Lamborghini doesn't perform well if it is dragging a 5-ton boat behind :)

Michal

Posted: Fri Aug 31, 2007 12:52 pm
by pr
Michal,

I share your concern for the technological base of NeoTicker. My own observations of todays trading software "scene" indicate that at this point platforms with a .Net technology base are screaming ahead of all others in terms of rate of delivery of feature innovations and bug fixes.

Yes, at this moment, in some cases, legacy platforms remain the most powerful overall - but their lead is eroding so quickly it's stunning. IMO, any Windows-oriented legacy platform that is not already well underway towards a full conversion to .Net is destined to be toast, and much sooner than nearly anybody realizes.