In, Microsoft's Rico Mariani made a comparison between the performance of C # And C ++ in actual application. The things originated from Microsoft's Famous Veteran Raymond Chen (the super cool-man who is admired below) who wrote an English-Chinese dictionary program in C ++ to describe the process of optimizing the C ++ program. He started from a simple and intuitive version of the code and continuously tested and optimized until he achieved satisfactory performance. Rico Mariani uses the same method, but uses C # To do the same program. The result is that Mariani's initial simple and intuitive version is almost ten times faster than Chen's original C ++ version. For the final optimized version, Chen overwrites the file IO, the string class is rewritten and the custom memory distributor is used, so that the speed of C ++ is twice that of C.
To put it simply, one of the design goals of C # Is to make simple and intuitive code more efficient, and it does achieve this goal; c ++ allows us to use any means to improve efficiency, as long as we are willing to make enough effort.
Original article:
A few years ago, Rico Mariani (at Microsoft) did really interesting performance comparison between C # And C ++.
It started when Raymond Chen (one of the most important engineers at Microsoft, and in the CS universe generally) wrote a Chinese/English dictionary application in C ++ to initialize strate his process for optimizing C ++ code. he started with a simple, intuitive version of the code, and then he incrementally profiled and optimized the bottlenecks until he was happy with the performance.
Rico Mariani took a similar tack, writing a simple, intuitive version in C #, and then optimizing its bottlenecks.
Surprisingly, Mariani's original C # implementation is almost ten times as fast as Chen's original C ++ implementation, without having to resort to any counterintuitive hacks.
Eventually, Chen rewrote the file I/O library, implemented his own string class, and used a custom Memory Allocator. only after jumping through all those hoops, the C ++ version was about twice as fast as the C # version.
The moral of the story is that C ++ gives you the tools to write blazingly fast software, if you're willing to do a lot of non-standard programming, and use a lot of hacks.
C #, on the other hand, lets you write really fast software right out of the gate, without resorting to any oddball shenanigans. but if you want to reach maximum possible performance, you will hit a wall sooner with C # Than you wowould with C ++. additionally, a piece of software in C # will almost always have greater memory requirements than an equivalent C ++ program.
There's a summary of the story on coding horror, here:
Http://blogs.msdn.com/ricom/archive/2005/05/10/performance-quiz-6-chinese-english-dictionary-reader.aspx
And you can read the whole play-by-play, here (follow all the links at the top of the page ):
Http://blogs.msdn.com/ricom/archive/2005/05/19/420158.aspx
Benjismith
Saturday, December 08,200 7