Wednesday, December 07, 2005

Java vs C# vs C++

Take a quick look at Comparing Two High-Performance I/O Design Patterns, page 3 which graphs the results of writting the same I/O code in Java, C# and C++. It is really cool to see how well Java and C# stack up against C++.

I've written a couple of servers in Java using NIO, and in C++ using raw sockets. I was very impressed with the performance of Java. Factor in how easy it was to write the Java code and Java is a clear winner to me.

One thing that isn't shown in the article is the difference between Java and C#'s class library. In Java, most everything is a CharacterSequence. All the conversion and string manipulation features in Java work with CharacterSequence. For example you can perform Regex functions directly on the NIO buffers!

Unfortunately in C#, the various strings and buffers do not have a common parent. The String and StringBuilder classes only have Object as the common parent. Also classes like RegEx do not support a wide range of targets. RegEx only works on String and serialization streams. You can't perform a RegEx directly on StringBuilder in .Net!

In conclusion, go Java :)

No comments: