C#ase Sensitive

I've been doing a lot of training for companies moving to VB.Net and one of the big reasons that keeps coming up in why they aren't moving to C# is the case sensitivity of C#.  And the only answer I have to why C# is case sensitive is that C/C++ and Java are case sensitive, and C# is designed to be a language comfortable to those developers.
But then the question is: Who in their right mind would ever leverage the ability to have a function named SquareRoot and another one named squareRoot in the same namespace?  Imagine a dialog between two developers, Steve and I'm Too Damn Smart for My Own Good

Steve: Hey, I'm having trouble running the InsertCustomer function.  I thought it was supposed to throw an exception when you send in a null value.
I'm Too Damn Smart for My Own Good (ITDSFMOG): Are you calling it with an uppercase or lowercase I?
Steve: Ummm, I guess uppercase.
ITDSFMOG: That one doesn't throw exceptions.  Use the lower case version.
Steve: Hold on, ITDSFMOG, I'm going to set you on fire.
ITDSFMOG: Behold the power of C#!  Let's see those stupid VB programmers call this function.  ARGGghhhhh I'm on fire and it really burns!  I regret nothinggg....

I can think of three reasons in my head why anyone would ever care about case sensitivity.  One would be if this was 1968 and we could only use on character per variable name, so now you can use A-Z along with a-z.  Hooray!  The other reason would be to make the job of the compiler writer a little easier.  And the other one would be for NotePad developers who might do something like this:

int MyVar;
myVar = 59;

Meh, that may be gross but I sure do hate having to remember to capitalize keywords. Can appeasing the notepad developers be that important to keep case sensitivity?

8 Comments

  • I'll second this! Senseless is the ONLY answer, much as Phil has pointed out. And even if someone can come up with some good reason, chances are that there is just as good of a way to do it in a non-case-sensitive language...

  • That's funny. I was just wondering the other day why anyone would want a case insensitive language. I guess it's just depends on how you learned to program...





    -Dustin

  • The only place I use it, and the only place you really should use it according to the docs, is when differentiating between a private field and a public property:





    private int myInt;


    public int MyInt


    {


    get{return myInt;}


    set{myInt = value;}


    }

  • AS already pointed out, there are historical reasons for case-sensitivity. Another is that computer languages were originally used by mathematicians who usually like to give 'x' and 'X' different meanings. We also use case to imply semantics in natural language but not as strictly. I guess the best example is that a 'Polish salesman' is not necessarily the same as a 'polish salesman'.





    I think the most compelling argument for case-sensitivity is that it means you use member names exactly as you declared them. If you're mistakenly using 'arga' instead of 'argA', what's to say you didn't actually mean 'argB'? My point is you *should* be thinking carefully about how you spell and case identifiers, just as you should be thinking carefully about how you format and comment your code. It's all down to maintaining *consistent* style and standards. You have yours and I have mine.





    Ignoring the idioms of VB/C#/C++, don't forget that the underlying CLR allows full use of Unicode for member names as well the use of names which are reserved words in one language but not in another. This means I can create a class called 'ForEach' or 'Next' in MC++ because the CLR doesn't know that they're reserved words in VB. For fun I can also call it '???' or 'ïnt' or any of 12 variations of 'Hello' using the Unicode characters that look almost identical to 'e'. Open up charmap.exe and see how obfuscated you can make your code... and then please never use that functionaility again ;-)

  • "...I can also call it '???' or 'ïnt'..."





    Clearly this comment makes no sense.





    '???' was a string of Japenese characters which are valid in .NET, but obviously need to be transmitted and stored with the right encoding! Part of my point is that some languages don't have casing and that casing/formatting rules extend past the 26 letters of the alphabet *I* use (check out how Korean characters are combined).





    Again, it's all down to style and actual usage. A similar argument crops up with Hungarian prefix notation. Some people swear by it while other argue that it has no place in a strongly typed language. It can be a powerful feature if used consistently and correctly and can add meaning beyond that of the underlying language, but thinking about it, I don't think I'd like to get compiler errors saying "Error: pszName is not a string pointer"...

  • That's funny that people aren't going to C# because it is case sensitive.





    I worked at a company many years a ago whose internal C compiler only paid attention to the first 8 characters of function names (e.g. hellohello() called the same function as hellohelsinki()). Everyone wanted to change the compiler to start matching against all characters in the function name but after years and years of people being lazy and incorrect, the cost was considered to be too high.


  • Hi Folks,



    I strongly beleive in C# case sensitivity. As a programmer its very easy to incorporate the properties and other logics easily using the case sensivity of C# which is not available in VB.NET.



    Cheers,

    Krishnan C.G.





  • For Krishnan:



    Can you provide an example of something you would do in C# that you cannnot do in VB.NET due to it's case-insensitivity? Sometimes people interpret "case-insensitive" to mean that they cannot use mixed-case, which is not true for VB.NET.



    Thanks,

    John G.

Comments have been disabled for this content.