Coffeehouse Thread

54 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Why is C# Case Specific?

Back to Forum: Coffeehouse
  • User profile image
    Manip

    I have asked the above question more than once and am yet to get a satisfactory answer. I would like to know, from the guys that designed and developed C# why they choice to continue the tradition of making it a case specific language?

    Doesn't this just make using the language a pain in the * and generally push up the time and complexity of development?

    Doesn't it make for a MORE steep learning curve?

    Doesn't it make developing a syntax checking tool more time consuming?

  • User profile image
    Karthik

    I think you mean case-sensitive, but I'll go ahead and tell you why I think case sensitivity is a good thing -

    1. Easier to declare case specific variables, and hence results in better code - people have conventions for declaration that is done better using a case-sensitive language. xFoo, Xfoo, xfoo all can mean differently based on your conventions - I use xfoo locally within a class, Xfoo in inherited classes and XFoo for externs - its something that does not break and yet makes it obvious to me by just looking at it. And I make sure my conventions are duly noted in the documentation, and it makes it easier for others to work on it.

    2. Code becomes easier to read - sure, I can write class foo as cLaSs FoO - but it looks stupid. Maintainability and readability are issues.

    Manip wrote:

    Doesn't this just make using the language a pain in the * and generally push up the time and complexity of development?


    Do you have any basis for these claims? In fact, good coding conventions are useful in the long run.

    Manip wrote:

    Doesn't it make for a MORE steep learning curve?


    Why? Because it does not encourage laziness and actually makes sure a programmer looks at his code and declarations, and encourages him to follow a standard convention?

    I think thats a good thing. And it discourages bad programmers - which is even better.

    Manip wrote:

    Doesn't it make developing a syntax checking tool more time consuming?


    Maybe, a little. But do you have any information to back this up?


  • User profile image
    ktegels

    Karthik wrote:


    Manip wrote:
    Doesn't it make developing a syntax checking tool more time consuming?


    Maybe, a little. But do you have any information to back this up?



    C# is synatatically based on C++, which is C, which is case sensitive. Making C# not case sensitive would make it harder for the folks who are learning C# from C, C++ or Java harder since it would be different than those languages in that sense.

    As to the back-up: no, being case insensitive is actually harder than not being. Our friends at the U of Manchester have a basic compiler theory paper up that talks about this.

  • User profile image
    Karthik

    ktegels wrote:


    As to the back-up: no, being case insensitive is actually harder than not being. Our friends at the U of Manchester have a basic compiler theory paper up that talks about this.



    Ah, thank you for the link - it was quite useful.

    I said maybe because if one were to convert everything into uppercase and analyze, it would create for a smaller space to check for errors - and hence, maybe a little faster. Thats the same reason they mention why Pascal facilitates locating variables and procedures in a case-independent way - I imagined that it would narrow the possible number of comparisons, and hence maybe make make the compilation happen faster.

    However, I missed the fact that token-checking and other things may use case-sensitivity as a factor - my bad.   

  • User profile image
    Sabot

    Manip ... I'm with you!

    I hate case sensitivity! It's just plain annoying!

    Can we have a feature so developers have a choice? I can see the complications already, it would be like having two different languages, but It will keep both camps happy. I have got tons of developers on VB.NET that are staying there because of just this one issue! They say it slows them down, I can't argue against that.

    What do you think people ?

    Cheers,


  • User profile image
    miies

    Sabot wrote:

    I have got tons of developers on VB.NET that are staying there because of just this one issue!


    If they're using VisualStudio, that's pretty strange - cause VS by default automatically formats all VB.NET code to correct case. Do they deliberately turn that feature off? Smiley

  • User profile image
    AlfredTh

    I suspect that a lot of the reason why C# is case-sensitive is that C and C++ programmers are/were the big target for C#. Those people are used to a case-sensitive language and tend to think that is the way a language should be.
    Case-sensitivity (along with those silly semi-colons) do make life easier for the compiler developers but I'd like to think we're beyond the days when languages were developered just for people who write the compilers. Smiley C was an experiment and I can understand why one would take short cuts for such a thing.
    Visual Basic is case-insensitive and it seems to work just fine. That is one of the reasons I am not ready to give it up for C#.

  • User profile image
    AlfredTh

    miies wrote:
    Sabot wrote:
    I have got tons of developers on VB.NET that are staying there because of just this one issue!


    If they're using VisualStudio, that's pretty strange - cause VS by default automatically formats all VB.NET code to correct case. Do they deliberately turn that feature off? Smiley


    No, why would they? This is one of the advantages of a case-insensitive language. The IDE can format things in a consistant way because the language is case-insensitive. How would it work if  FooBar and foobar could be different variables? You don't see C# correcting the casing of a variable do you? That is a limitation of the language that VB avoids.

  • User profile image
    Sabot

    Sorry guys, just to clear this up. My original post wasn't very clear!

    I have a group of developers that use VB.NET and have come from VB5/6 that do not like being forced to use a case, so this is the reason they will not code in C#.




  • User profile image
    paulcam

    Case-sensitivity can be a good thing, and so can Hungarian notation (these arguments tend to show up in clusters). They both allow us to visually distinguish between different elements in a language. If you see 'max_path' or 'phonenumber' in code somewhere, and you've never seen it before, you'll probably go trawling through code trying to figure out where that variable gets declared and what type it is. MAX_PATH stands out as something that is distinct from other variables. Using 'szPhoneNumber' instead of plain 'phonenumber' allows us to tell a lot about what 'szPhoneNumber' is for, where it came from, and what it isn't. We know, for example, that it's in the local scope... it's neither a member, static, or global variable... It even gives us insight as to what its content might look like. We might think this is a valid operation (though it doesn't seem like something anyone would want to do):

    phonenumber++;

    But we can be reasonably sure that this is probably not something that's being done intentionally:

    szPhoneNumber++;

    Of course, the majority of this stuff is subject to personal opinion. Having been brought up under an oppressively case-sensitive regime (in this case, my college C class Wink, it seems natural to me.

    Some folks argue that the need for Hungarian is mitigated in C# by the language's strong support in Visual Studio. I tend to disagree... I tried to code a little tool up in C# without using Hungarian and ended up with a bunch of variables named "FooString" instead of "strFoo". Old habits die hard, I suppose... Smiley

  • User profile image
    Manip

    I wish wish wish the syntax checker auto-adjusted if they are typed wrong, you can even have it turned off by default to keep all the C people happy.. I dream of a day when you type "Messagebox" and it gets corrected to "MessageBox" without even bothering you. You could even take a note from MS Word's book, and if you correct it, then it doesn't try to re-correct it.

    I can't imagine the C people having too much of a problem with that, it would be switch off by default so would not hurt there perfect code.

    Again nobody has offered a good reason for this. Some have said easier to read bluh bluh, but someone as I would have pointed out told them automatic case selection is EASIER than human any day. I mean who has ever had problems reading Visual Basic code? Nobody!

    I do suspect that because the big rubber stamp has been used on the C# specification, it is too late to change anything.. I would rant and rave about how C/C++ people control all language development but you all know what I'm going to say so I don't see the point. *VB.Net*Sucks*
  • User profile image
    KHowe

    Sabot wrote:
    I have a group of developers that use VB.NET and have come from VB5/6 that do not like being forced to use a case, so this is the reason they will not code in C#.


    Now that seems silly to me... with the invention of intellisense, who cares! Unless you are coding in Notepad or you love to use WeIrD CaSiNg, the IDE makes it easy either way. IMHO of course

    Keith

  • User profile image
    Karthik

    Manip wrote:

    I wish wish wish the syntax checker auto-adjusted if they are typed wrong, you can even have it turned off by default to keep all the C people happy.. I dream of a day when you type "Messagebox" and it gets corrected to "MessageBox" without even bothering you. You could even take a note from MS Word's book, and if you correct it, then it doesn't try to re-correct it.

    I would be scared if my IDE did that Smiley What if Messagebox was a function that I had, or was a variable? Its for the same reason why I think clippy is a pain - please let me do what I'm doing, I will take care of my mistakes myself, thank you. I design UI prototypes in VB and this is one of the many things that really really put me off.

    I would have to agree with Paul Campbell that maybe it's because old habits die hard.

    The point is that there are a lot of programmers out there who do not use the default IDE (I personally use emacs for all my programming - and my templates have been made to be case sensitive - my .emacs has my OO browser configured to tell me the list of variables based on my conventions - and this works well across C, C++, Java and the like). I know tonnes of other programmers who use such conventions and are used to it - and the reason they use it is primarily because its useful.

    Manip wrote:

    Again nobody has offered a good reason for this. Some have said easier to read bluh bluh, but someone as I would have pointed out told them automatic case selection is EASIER than human any day. I mean who has ever had problems reading Visual Basic code? Nobody!


    What do you mean by automatic case selection? I like the freedom to use xfoo, Xfoo and XFoo in the same line - VB takes away that freedom and hence constrains me.

    When I have 10,000 lines of code and would like to see all my local variables, conventions come in handy. Hell, even MFC follows such conventions.

    Paul raised the point about Hungarian Notations, so I will not go there. But I would like to mention the much beaten down fact that the need for Hungarian Notation is perhaps mitigated in a purely OO language - but I do not think C# can be called that - I would put it together with C++ as a hybrid (a better one, but a hybrid neverthless) and therefore, there exists the need for a suitable notation.

    Manip wrote:

    I do suspect that because the big rubber stamp has been used on the C# specification, it is too late to change anything.. I would rant and rave about how C/C++ people control all language development but you all know what I'm going to say so I don't see the point.


    Thank God for small mercies Smiley

  • User profile image
    jpalermo

    C# is based on C, so that would explain why.  People coming from C or Java will like the fact that it's case-sensitive.  I like that feature. 

  • User profile image
    Richie

    Sabot wrote:
    Sorry guys, just to clear this up. My original post wasn't very clear!

    I have a group of developers that use VB.NET and have come from VB5/6 that do not like being forced to use a case, so this is the reason they will not code in C#.


    They don't want to use case? Is it uppercase or lowercase they object to? Maybe we could find a workaround... Maybe they could just go home and stay there... I'd hate to think that life should put such a strain on them.

    An "A" is not equal to an "a"... deal with it...

    (I wonder what advice Donald Trump have for them...)

    Thanks

    Rich

  • User profile image
    Karthik

    Richie wrote:

    An "A" is not equal to an "a"... deal with it...

    (I wonder what advice Donald Trump have for them...)


    I wonder what advice Larry Wall would have for them Tongue Out

  • User profile image
    irascian

    For me case sensitivity (and use of the semi-colon) was a great reason for moving from VB.Net to C Sharp. If you're doing web development it's a pain in the posterior to keep switching between case-sensitive JavaScript and case-insensitive VB. I've lost count of how many times an error in case sensitivity in JavaScript would take forever to chase down, mainly because debugging tools for client-side JavaScript are a joke and the VB habbit of not caring about case lead me to get sloppy with coding.

    Using C# soon gets you into the correct habit (much better debugging helps), gives you great advantage in not having to keep coming up with different names for the field and property versions of a variable (just make the property Pascal notation, field camel notation) and makes switching beween server-side and client-side programming in JavaScript a doddle.

    I'm all for case sensitivity.

  • User profile image
    PeteBeech

    paulcam wrote:

    Case-sensitivity can be a good thing, and so can Hungarian notation (these arguments tend to show up in clusters). 



    It seems like hungarian notation is out of favour now, and the latest coding convention guidelines say it should not be used (see the middle of this blog entry). I really wonder what the rationale behind this is, as I still find it incredibly useful.

    Is it because they think it makes code harder to maintain (e.g. if the type of a var changes, which in my experience doesn't happen too often), or as you say, that the IDE should give that support (not much good if you use notepad, or you're reading a hardcopy of the code for a code-review or something).

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.