VB Myth - Case Insensitivity is Awesome!
Posted
by Damon
on Simple Talk
See other posts from Simple Talk
or by Damon
Published on Thu, 08 Mar 2012 21:27:43 GMT
Indexed on
2012/03/18
18:16 UTC
Read the original article
Hit count: 377
I was reading Andy Brown's article 10 Reasons Why Visual Basic is Better than C# and the first claim is that VB is superior because of case insensitivity. I think the reasons he outlines are basically as follows:
- Your fingers get tired finding the shift key (e.g. typing PascalCase and camelCase members)
- You are much more likely to make mistakes while typing names
- When you accidentally leave caps lock on, it really matters
These three arguments culminate in the conclusion:
"It doesn't matter if you disagree with everything else in this article: case-sensitivity alone is sufficient reason to ditch C#!"
Righto. I've been using Visual Basic since version 5.0, I wrote a book about ASP.NET in Visual Basic, so I want everyone to know I'm definitely not a VB.NET hater. I had to converted to C# because it was the language of preference at the places I've worked, so I'm used to both languages. I love me some case sensitivity. So first, let's debunk the claims.
First, your fingers do not get tired of finding the shift key unless you are writing code in notepad and compiling everything on the command line. Visual Studio pretty much takes away the need to use the shift key at all. For the most part, any programmer worth a damn doesn't have to type more than about 3-5 characters of any variable or method name before IntelliSense kicks in to help. VB or C#, if you are not using the tab key for autocomplete then you are typing too much anyway, regardless of whether the shift key is involved or not. Also, you've got to be a pretty hard-core candy ass if you're complaining at the end of the day that your little fingers are hurting from hitting the shift key.
Second, I cannot logically refute the fact that if there are more stringent rules about case sensitivity it will lead to more mistakes. As such, know that you will be more prone to mistakes in C#. However, lets talk about the magnitude of the problem. If you are using IntelliSense then you have auto-correction built in so you probably won't have much of a problem in the first place. If you manage to bypass IntelliSense and type something wrong you normally are immediately presented with a red-squiggly to let you know something is amiss. Normally, a person would look at the problem, figure out what the heck went wrong, and then avoid that problem again in the future. Granted, I have met people who seem to lack this capability, but their problem is deeper than a decision between VB.NET and C#. So let's make sure that we're all on the same page about this problem. If you have two teams of developers, one that uses VB.NET and one that uses C#, do not expect to see the VB.NET team drinking beer at the end of the project in festive revelry while the C# team is crying over what the hell to do because their code is riddled with case-sensitivity problems that nobody can resolve.
Lastly, if you leave your caps lock key on, turn it off. Really, what kind of ass-hat would write an entire VB.NET application ENTIRELY IN CAPS?
I happen to be a fan of case sensitivity because it encourages precision and uniformity. The last thing I need is a code base that looks like it was ransacked by LeEt HacKors wHo Can uSe wHateVer cASe tHey wanT. I mean really, if you saw someone write this:
PuBLIc Sub MyMethod
.
End Sub
And upon asking them why BL was upper case, they responded "Oh, I accidentally hit the shift key there. Fortunately for me VB.NET is a case insensitive language so I saved a couple of keystrokes by leaving it in there." Or if you saw:
PUBLIC SUB ANOTHERMETHOD
.
END SUB
And the response to why it was uppercased was "Yeah, I accidentally had caps locks on, fortunately for me VB.NET doesn't care. Really dodged a bullet there, glad I wasn't using C#."
Would you not think that a bit ridiculous? If you want to convince C# developers that C# sucks, go for it. But the case insensitivity argument is crap.
© Simple Talk or respective owner