Tuesday, January 31, 2006

The Great Debate

The Visual Basic versus C# debate has raged since Microsoft released the very first version of .NET. Is one language better than the other? Does one offer superior processing performance? What about development time?



The short answer (and the answer Microsoft is carefully conveying) is that the languages are functionally equivalent. So what does that mean? Basically, you can do the same things in each language with relatively the same performance.



I read an interesting article a while back that pointed out something beyond the functional nuts-and-bolts of the languages; namely, the type of developer each language attracts. In this case, I tend to agree that there is a difference.



Speaking as someone who came up through the Visual Basic ranks, I can now say that I have a bit of a bad taste in my mouth for VB. I think it encourages sloppy programming practices, bad habits, and poor coding in general. Sadly, for these very reasons, VB tends to be a magnet for sub-par programmers.



By contrast, C# is a more elegant language, and in many cases, forces the developer to take an object-oriented approach. Since both languages are billeted as "Object Oriented", I see this as a plus. On the whole, I find that most C# code is less bloated and more streamlined than most of the VB code I come across.



It's been said that 80% of C# programmers are good, whereas 80% of VB programmers are bad, but because there are so many VB programmers, there are roughly the same number of good VB developers as good C# developers. Of course, that's not to say that all VB programmers are bad. Quiet the contrary, I've met several amazing developers who sling VB code.



I was extremely disappointed to find out that Microsoft has further soiled the .NET implementation of VB by, among other things, taking a step backward and allowing form references without instantiation. For example, assuming you have a form named "Form1". In VB 8 (Visual Studio 2005) you no longer have to create an instance of that form in order to interact with it. All forms are effectively static (or in VB terms, Shared).



Furthermore, some of the language enhancements in VB 8 are just plain silly. For example, Microsoft introduced the IsNot operator. The reasoning is to improve the readability. For example, the old way of testing the value of an object looked something like this:
If Not someObject Is Nothing Then ....
With the IsNot operator, that same line of code would look like this:
If someObject IsNot Nothing Then ...
If you ask me, neither approach is as elegant or intuitive as the C# equivalent:
if (someObject != null) ...

The list goes on and on, but at the end of the day, I'm afraid I have to cast my vote in favor of C#.