Alright, that’s not quite fair, but anyone that assumes that C# is going to be slow just because Java is making a big mistake. One of my classmates made this mistake, and it should have cost him $5, but I chickened out and wouldn’t take the bet. Anyway:
We had a programming assignment to find the average number of colors to color a graph. I won’t go into the details, but suffice to say that we had very similar solutions in terms of algorithmic design (in theory my algorithm should have been faster, but it looks like its advantage is minimal in practice), and he thought his program would smoke mine due to our choices in language and platform. I chose C# and .NET 3.5 running on Windows, he chose straight-up C running on MacOS. We both ran our programs on MacBook’s with identical processors. Even *I* expected the C program to win out. When I use .NET, I know that I am giving up some performance in exchange for an improved development experience… or so I thought.
We fired up our programs in dramatic fashion, then waited for them to complete. 10 minutes later, we had our winner: C# had completed the task ahead of C. The C program wrapped up around the 14 minute mark. I love C# and .NET, and though I expected C# to be close to C, I never expected it to be faster.
Despite the results, I still think the C version should have been faster; there must be some minor algorithmic, implementation, or environment difference that is causing the results. Still, this does demonstrate that C# is no slouch on the performance front.
Oh, and for anyone that likes Java: I talked to people who implemented the same assignment using Java, and their programs took *hours* to run for the same problem size. Suck on that, Java! 😛