[ degojs @ 21.05.2005. 05:48 ] @
Raymond Chen (aka "fixed more Windows bugs than you've had hot dinners") and Rico Mariani (aka "Mr .NET Performance") have been running a great series of articles where they write and then optimize the same application in two different languages: native C++ and managed C#. ... A line-for-line translation of the original C++ code into C# ran 10 times faster than the C++ code. It took five different optimizations (one of which introduced a bug) for the C++ code to match the speed of the unaltered C# code. After Raymond's sixth optimization, his C++ code finally beat the C# code because the runtime got down to where the 60ms startup overhead of the CLR made a difference! To accomplish this, Raymond had to: * Write his own file/io stuff * Write his own string class * Write his own allocator * Write his own international mapping So yes, C++ code can be faster than C# code but when you look at all the work Raymond had to go through to achieve that, you have to ask yourself "is it worth it?" http://blogs.msdn.com/jonathanh/archive/2005/05/20/420634.aspx |