Like Tree2Likes
  • 1 Post By quzah
  • 1 Post By MK27

Case Sensitivity

This is a discussion on Case Sensitivity within the General Discussions forums, part of the Community Boards category; While looking for a case insensitive way to find files on Linux, I came across this post on Coding Horror. ...

  1. #1
    Just a pushpin. bernt's Avatar
    Join Date
    May 2009
    Posts
    426

    Case Sensitivity

    While looking for a case insensitive way to find files on Linux, I came across this post on Coding Horror. (It's an awfully old post in internet terms, but it sparked my interest.)

    The author raises some points as to why case sensitivity is "a giant productivity time sink" and quite frankly I'm not seeing the merit in his argument. To me case-sensitivity seems like a great feature in that it enforces readability. It's easier to see that "Variable" is the same identifier as "Variable" than it is to compare "Variable" and "VARIable". That, and I always find myself doing stuff like this when I need a single instance of a class:
    Code:
    class Apple;
    Apple apple;
    In the comments, I saw the issue going to "how lenient should the language be, then?" If case insensitivity is OK, should the language forgive typos as well? Should "Varyable" == "Variable"? Obviously I hadn't gone as far as to consider this - I'm still saying case sensitivity is a good thing. But the idea of a compiler that forgives little errors like this is quite interesting.

    Oddly enough, however, I'm all for case insensitivity in filesystems. And I love the program that comes up with suggestions when I make a typo on the linux terminal (though this is markedly different than assuming it knows what you meant to say). It might just be that I've had different experiences working with filenames, or that I haven't ever had a need to have two files differing only by case.

    Which brings me to my point: do you guys have any reasons for favoring one or the other (case sensitivity vs insensitivity (vs typo-correction???))? And, do any of you have so-called "horror stories" regarding case sensitivity that are apparently so common?
    Consider this post signed

  2. #2
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    should the language forgive typos as well? Should "Varyable" == "Variable"?
    What if you really meant "Varyable" ?
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Clang can actually find and correct typos in your programs - but it won't actually generate code in such cases.

    Case insensitivity is fine, although I disagree that sensitivity is a productivity sink. Just keep to a naming convention and there can be no question on how to write something. Instead of a compiler being case insensitive, I think IDEs should be case correcting. That is, if you type a variable with the wrong case, the IDE should just change it. No time lost, but the code remains absolutely clear.

    As a general rule, though, a programming language cannot be sloppy. Case insensitivity isn't sloppy, it's just a consistent and simple equivalence rule for identifiers. The important property is that every equivalence class is closed. Typo correction does not have this property. Dog could be a typo for Hog could be a typo for Hag could be a typo for Hat could be a typo for Cat - where is the limit? (Also, Cog, Dot, Cot, Hot, and many other words pave the way for this little transformation.) An equivalence relation for variable names MUST be transitive, or your language becomes terribly ambiguous.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by manasij7479 View Post
    What if you really meant "Varyable" ?
    And what if I meant chose not choose, or lose not loose? Maybe we could make another modifier so we could note when we really meant a different spelling? Maybe: [sic]?
    Code:
    int chose;
    int sic, overstretchedjoke;
    printf( "Enter sic: " );
    scanf( "%d", &sic );
    overstretchedjoke = sic * 5;
    int choose[overstretchedjoke];
    for( sic = 0; sic < overstretchedjoke; sic++ )
    {
        chose[sic] = sic;
        choose[sic] = chose[sic];
    }
    :eyebrow:


    Quzah.
    MK27 likes this.
    Hope is the first step on the road to disappointment.

  5. #5
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,074
    Quote Originally Posted by bernt View Post
    To me case-sensitivity seems like a great feature in that it enforces readability. It's easier to see that "Variable" is the same identifier as "Variable" than it is to compare "Variable" and "VARIable".
    You could always enforce readability by having the editor force a case after the word is complete. Languages like Visual Basic will force whatever case you use at declaration on every instance of that identifier in the code. So if I declare "VARIable" and later on write "Variable" it will automatically be changed by the editor to reflect it's original case.

    Of course, that still doesn't allow you to do this...
    Quote Originally Posted by bernt View Post
    That, and I always find myself doing stuff like this when I need a single instance of a class:
    Code:
    class Apple;
    Apple apple;
    ...but then, I hate that. Even in a case-sensitive language that is barely considered acceptable practice. If being able to do it was the only argument for case-sensitivity then I'd be rallying against it tomorrow.
    Sent from my iPad®

  6. #6
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    I totally agree case sensitivity is important and useful. It also much simplifies parsing. I recently wrote an HTTP server, and HTTP is case insensitive, which is a total pain. Totally horrible choice that was. Contra the coding horror guy, I'd say it is a drain on productivity, and I bet the amount of energy consumed inside the WWW everyday so that servers/browers can treat:

    content-length
    Content-Length
    cOnTent-LENGTH

    as equivalent is enough to power a small city. Honestly. People that think this kind of waste and inefficiency are worthwhile because it makes things more foolproof are...fools. If you are that incompetent and lazy, stay away from a keyboard. I'm sure, WRT the web, various standards are this way in order to "provide leniency" for sloppy work, and a consequence is that it encourages it. Awesome.

    Quote Originally Posted by bernt View Post
    That, and I always find myself doing stuff like this when I need a single instance of a class:
    Code:
    class Apple;
    Apple apple;
    I partially agree with SlyMaelstrom, ie, this almost seems like a bad practice, but I occasionally do it myself because it also seems intuitive. I guess context is important -- if it is short and sweet, why not?

    I often (but not always) capitalize the first letter of a type, and (when I get to choose) always capitalize the first letter of a global, and never the first letter of a local variable.

    All this demonstrates that literate human beings distinguish between upper and lower case. Why render it meaningless?

    Oddly enough, however, I'm all for case insensitivity in filesystems.
    Not me. File system hierarchies often form parts of projects so I regard those names exactly the same way I regard those of variables in code. I'm very against the legal inclusion of spaces in file names. Poor choice. If the OS wants to provide stuff like that to the end user, the filesystem should use meta-data for that purpose.

    And I love the program that comes up with suggestions when I make a typo on the linux terminal
    Pretty sure that is part of the readline library.
    Last edited by MK27; 10-17-2011 at 11:19 AM.
    hauzer likes this.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  7. #7
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,511
    Quote Originally Posted by CornedBee View Post
    Instead of a compiler being case insensitive, I think IDEs should be case correcting. That is, if you type a variable with the wrong case, the IDE should just change it. No time lost, but the code remains absolutely clear.
    This I can't agree. I don't look with good eyes at the notion of IDEs overruling anything I write. Especially if they do it silently. Besides if I'm allowed to easily ignore case sensitivity, there's a good chance I'll end up forgetting all about consistency.

    I cannot imagine any good coming from an IDE that hides language features from me, instead of exposing them. Of course... this for anyone considering case-sensitivity a feature.

    Quote Originally Posted by MK27 View Post
    I often (but not always) capitalize the first letter of a type, and (when I get to choose) always capitalize the first letter of a global, and never the first letter of a local variable.
    Indeed. Very powerful use of this language feature. And why I'm actually a fan of case-sensitivity in general-purpose programming languages.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Case Sensitivity Help!!!
    By Master Ali in forum C Programming
    Replies: 3
    Last Post: 01-21-2011, 03:38 AM
  2. Case Sensitivity... matching words in a string.
    By braden87 in forum C Programming
    Replies: 5
    Last Post: 03-13-2010, 10:04 PM
  3. case sensitivity in GtkTextView
    By MK27 in forum Linux Programming
    Replies: 2
    Last Post: 08-07-2008, 03:16 PM
  4. strcmp without case sensitivity
    By AmazingRando in forum C Programming
    Replies: 8
    Last Post: 03-16-2005, 07:40 AM
  5. window size and mouse sensitivity
    By B-Con in forum C Programming
    Replies: 5
    Last Post: 04-21-2004, 05:12 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21