Become a fan of Slashdot on Facebook

 



Forgot your password?
typodupeerror
×
Java Programming IT Technology

Who Needs Case-Sensitivity in Java? 434

David Barber asks: "I've just started learning Java, and to my exceptional disappointment it is as case-sensitive as C. I'd like to ask Slashdot readers to make the case for case-sensitivity in a programming language, because I can't see it. Although I've used C on and off since 1976, I also have a history of Fortran, COBOL, PL/I, assembler, and other legacy languages that were never case sensitive (perhaps due to the single case nature of card punches). Today I use modern languages including Visual Basic which preserves case for pleasing appearance, but is not case-sensitive itself (it will correct the case for you in the IDE, which is quite nice). In all my years of programming I have never seen the rationale for making a programming language case sensitive. It simply makes typing it in harder, and mistakes easier, yet we persevere with maintaining it in modern languages like Java. Without making this into a religious war, can someone make the argument of why case-sensitivity in a language is 'a good thing'? And don't confuse this with handling case-sensitive data, which is fine."
This discussion has been archived. No new comments can be posted.

Who Needs Case-Sensitivity in Java?

Comments Filter:
  • by samdu ( 114873 ) <samdu AT ronintech DOT com> on Thursday January 22, 2004 @05:08AM (#8052925) Homepage
    I'm not a programmer, but I would imagine that case-sensitivity would help a great deal with the uniformity of the code.
    • Re:Uniformity... (Score:4, Insightful)

      by mystran ( 545374 ) on Thursday January 22, 2004 @05:14PM (#8059659)
      I am a programmer, and I can tell that case-sensitivity has other benefits too.

      • You don't need to care about the LOCALE settings or other such things. Either something is the same as something else, or it is not. You don't need to care if the compiler actually accepts the source with the right character set.
      • In some cases, it is very useful to be able to use the same identifier in several different cases. One example is having a class "Foobar", an instance of which you can name "foobar", and it's clear what class it belongs, but you still have a separate identifier.
      • This is not directly related to Java, but sometimes you want to have a short identifier for something that's used a lot. Say, you have a global object which talks to an Xserver. If you need to use that in many places, it's nice to name it "X" which is easy to understand, but "x" is a common variable name for short-lived variables, and you don't want it to be the same identifier as "X". Without case-sensitivity, you can't really use one letter globals, because one letter variables are the ones people will be using the most. With case-sensitivy, you can use just the uppercase for globals, and there's no problem. (whether globals are a good idea at all is another subject, and depends on the language and type of program one is writing in/for)

      Case-insensitivity is probably the single most annoying thing with otherwise decent languages such as Scheme. In case-sensitive languages, errors in casing are usually catched by a compiler. With case-insensitive languages it's easy to make errors that are not catched, because the different looking identifiers are actually the same.

      My .02 euros. YMMV.

      • Re:Uniformity... (Score:3, Interesting)

        by Spudley ( 171066 )
        Your first point is by far the most important point that you made. Character sets are not uniform (at least in the world of 8 bits per character), even among nations that share most of them, and the upper/lower case equivalents are not always the same between them.

        I also agree with your final point - case sensitivity can be useful in helping to pick up typing errors at compile time.

        But as for the two other points you made...

        The second point is not *quite* as strong. You're right that it does enable you t
        • Re:Uniformity... (Score:3, Insightful)

          by mystran ( 545374 )
          Ok, the "X" example might be a bad one (and indeed I generally dislike identifiers that are two short to be descriptive, although in the particular case I had this, an uppercase X could not have possibly meant anything else but the Xserver interfacing object, and it was used extensively, which was actually the fault of the stupid interface, which I had nothing to say about anyway) but at least local one-letter variables are IMHO just fine in many places (that is not the same as "in most places" though). The
  • History (Score:4, Funny)

    by Photar ( 5491 ) <photar AT photar DOT net> on Thursday January 22, 2004 @05:09AM (#8052927) Homepage
    Case sensitivity is just a tradition, with its roots in the Old Testiment.
    • Re:History (Score:2, Interesting)

      by saden1 ( 581102 )
      Case sensitivity helps with naming convention. Static variables are always capitalized. Plus it doesn't hurt having them so why not?

      The idea of eliminating case sensitivity seems appealing until you need it.
    • Re:History (Score:5, Interesting)

      by jc42 ( 318812 ) on Thursday January 22, 2004 @02:19PM (#8057211) Homepage Journal
      Case sensitivity is just a tradition, with its roots in the Old Testiment.

      Um, funny maybe, but wrong. The Old Testament was written in classical Hebrew (with maybe a bit of Aramaic in some of the later parts), and that alphabet has never had a case distinction.

      Upper/lower case is something that developed only around 1500 years ago, plus or minus a few centuries. It was adopted in the Roman, Greek and Cyrillic alphabets, but that's about it.

      It is useful, as we all learned in grade school. Thus, many managers have aids who are very helpful. But if they have AIDS, it's a serious medical problem.

      One of the reasons that the project I'm working on isn't using Macs is that OSX uses a caseless file system. When we tried porting several important software packages to OSX, they were utter disasters. The symptoms were bizarre and inexplicable, and took forever to hunt down. It turned out to be caused by executables from different packages that had names that differed only in capitalization. Each package had its own convention, so there weren't any collisions on linux and other unix-like systems. But on OSX, there were cases where a component of package X ended up calling a program from package Y, and they both went crazy. We spent so much time finding the problems and fixing them that we decided to just not use OSX except as a UI.

      It's too bad, really. My 17" Powerbook is a really neat tool. I'd like to use it as a real computer. It wouldn't have been much more work for Apple to hide their case insensitivity in runtime libraries, the way it should be done. I really wish they'd done that, rather than breaking the assumptions that all other unix-like systems are built on.

  • by choi ( 189590 ) on Thursday January 22, 2004 @05:13AM (#8052933)
    It's nice that VB corrects your code in its proprietary IDE, but C/++/Java is used in many different editors/IDEs. The language thus enforces clean code case-wise by being case sensitive.
    • Must disagree. I can't think of a language that enforces clean code. Can anyone?
      • by Dr. Smeegee ( 41653 ) * on Thursday January 22, 2004 @11:22AM (#8054913) Homepage Journal

        Python strongly encourages it. :-)

        Perhaps syntax errors should cause your monitor to explode. I think using deprecated modules already does.

        Let me check....

        Python 2.2.3 (#42, May 30 2003, 18:12:08) [MSC 32 bit (Intel)] on Your Mom
        Type "copyright", "credits" or "license" for more information.
        IDLE 0.8 -- press F1 for help
        >>> import fcntl B`LAST!!!!

        AAAIIIGH! Mine EYES!

        Aye.

    • Is thIs clEAn cOdE cAsEwIsE As lOng As It's cOnsIstEnt In All yOUr proGrAm's fIlEs? whAt lAngUAgE wIll hElp wIth thIs? AdA? pAscAl?

      Conventions matter as far as clean code, even at the level of case choices. Language choice doesn't help here, does it?

  • my reasons....... (Score:5, Insightful)

    by Anonymous Coward on Thursday January 22, 2004 @05:14AM (#8052936)
    Here are some reasons I just made up (though a couple actually affected my programming).

    Because it makes sense that all symbols are uniquely identified from a set of characters, rather than each symbol being identified by a huge set of names (var, vaR, vAr, vAR, etc). There may be a need for a "canonical name", which is it? All lowercase? All uppercase?

    Because it makes dynamic programming and reflection even slower and/or more error-prone (I have experienced this in PHP which is case-insensitive and it bugged the hell out of me [and my program]).

    Because it takes fewer CPU cycles when compiling or scanning source code.

    Because some languages use case to indicate a different class of variable (Ruby for instance, issues a warning if you try and change a variable starting with uppercase).

    Because many programmer's text editors are case-sensitive (I know, I know, chicken, egg, etc).

    Because lowercase/uppercase could be a harder problem if you use a language which allows Unicode symbols (Perl6?). (Is this possible? I have no idea).

    Because sometimes it actually is useful to have a symbol "ID" and another one "id" in the same symbol table.

    Because stuff like case and english language is not part of programming, programming is about precision and computers. Introducing ambiguity (whether for the compiler or the programmer) can't be good.

    Because C is case-sensitive, and C is a popular language.

    You might want to try PHP5 though, it's a lot like Java but case-insensitive.
    • by KDan ( 90353 ) on Thursday January 22, 2004 @06:27AM (#8053174) Homepage
      Additional reasons:

      Because it makes naming conventions much easier without all sorts of silly prefixes. You'll come to appreciate the fact that, in Java, if a term looks like MyTerm you know it's a class name, if it looks like myTerm you know it's a variable or a method name (recognisable because it's followed by brackets, even when there are no arguments - something which I'm sure you'll be griping about too, right?), if it looks like MY_TERM you know it's a constant...

      Because good programmers aren't bothered by such trifling matters?

      Daniel
      • by GCP ( 122438 )
        ASCII has a relatively simple, consistent mapping from lower- to uppercase and vice versa. Letters all have a single upper-lower 1:1 pair, while all others are caseless and upper and lower are the same. It's a simple map.

        But ASCII is obsolete. Java doesn't use it, even for variable names. When you go beyond ASCII, you have many different case maps to choose from. Different cultures have different case equivalency rules, some of which are rather complicated. And then, as others have mentioned, there are the
    • by Pogue Mahone ( 265053 ) on Thursday January 22, 2004 @07:04AM (#8053305) Homepage
      Many natural languages have case-sensitivity too - German, for example: fliegen (verb) and Fliegen (noun) are different words.

      But why a big list of reasons FOR case-insensitivity?

      IMHO the question should be turned around to "Why should anyone want case-insensitivity in a language?" (since, as you say, it has to be put there and requires more work in the part of the compiler and/or the compiler writer).

      Then it is up to those who want case-insensitivity to argue their case against the simplest implementation.

    • Re:my reasons....... (Score:2, Interesting)

      by Shazow ( 263582 )

      Because sometimes it actually is useful to have a symbol "ID" and another one "id" in the same symbol table.

      This kind of made me think of my calculus homework which I should be doing right now. Especially for integration, and such. We've variabled "m" and "M". Sure, in a program, it wouldn't be hard to change them to something else like "bigM" and "littleM", but it would sure make the code a lot simpler to read to just have "m" and "M". This is in a case where you're writing a calculus-related program. E

      • ... since lisp and it's relatives are often used in computer algebra systems, and lisp is case insensitive.

        On the other hand, lisps allows all kinds of characters in identifiers, e.g eq? load-this-now are.we.there!yet? so we can still have fun.
  • Java (Score:5, Interesting)

    by GuyWithLag ( 621929 ) on Thursday January 22, 2004 @05:15AM (#8052939)
    Take a look at eclipse. Not only is it a subperb IDE that you can pick up within the hour, it has the correct-my-case-for-me feature you asked for.

    Note that in Java case has by convention semantic significance, so that you can discern org.foo.Bar.bleh from org.foo.bar.Bleh.
    • Re:in Holland (Score:5, Interesting)

      by tigersha ( 151319 ) on Thursday January 22, 2004 @05:53AM (#8053083) Homepage
      This is actually a problem with java because Java states that thos packages must be in the correct directories:

      org.foo.Bar.bleh must be in org/foo/Bar
      org.foo.bar.Bleh must be in org/foo/bar

      This is NOT possible (unless they are in different section of the classpath) in Windows NT because the filesystem is not case-sensitive there. Java's mapping of case-sensitive package names to an underlying filesystem assumes that the filesystem has the same naming conventions that Java uses.

      As far as I know Java can also take Unicode source as input and then the filesystem must also handle that, which would work on NTFS, but not of FAT and probably not on any Unix FS AFAIK.

  • Namespaces (Score:5, Informative)

    by HalfFlat ( 121672 ) on Thursday January 22, 2004 @05:17AM (#8052947)
    One advantage of case-sensitivity of variable names and the like is that it allows ad hoc separations of name spaces.

    For example, it is a common practice in C to use ALLCAPS for macro definitions and alllowercase for variable and function names. If adhered to strictly, it means that there won't be any collisions between variable and macro names.

    It can be convenient in maths heavy code too, where the use of long variable names quickly makes the code hard to read due to excessive line lengths. Being able to use short upper case names for 'big' objects (eg matrices or operators) and short lower case names for 'small' objects such as scalars matches mathematical convention and keeps equations short and readable. Case sensitivity means that there won't be any accidental collisions between the two sets of objects.

    It's certainly not necessary, but it can make life a lot easier. If you don't expect your language to ignore case, then you're unlikely to make case-based errors as a programmer. Especially if you're coming from a mathematical background where 'A' and 'a' rarely refer to the same thing.
    • Concerning the long variable and the difficulty of writing mathematical code with those. I heavily suggest making use of the refactoring features of your IDE of choice (eclipse hopefully) to rename variables. This way you can write your code with small and obscure variable name and when your code is working you just have to rename your variables to something meaningful :)
  • OMG (Score:5, Funny)

    by DarkDust ( 239124 ) <marc@darkdust.net> on Thursday January 22, 2004 @05:26AM (#8052979) Homepage

    Today I use modern languages including Visual Basic

    Real programmers don't use (Visual) BASIC... at least not after puberty ! ;-)

    • They do if they wan't a paycheck. VB.NET really isn't that bad, and I've always seen VB as the shellscript for windows --Its a neat way to hack applications together with COM.
  • by noselasd ( 594905 ) on Thursday January 22, 2004 @05:26AM (#8052981)
    When I make a class Person {..} I want the other developers to use
    Person person = new Person(..); not
    person person = new perSon();

    It also becomes a mess when you have some people write
    If(something){
    }
    later you see IF or if.
    Case sensivity preserves sanity and helps enforce coding standard.
    It's a good thing, learn to deal with it.
    • In Unrealscript (the Unreal engine's Java-ish scripting language), the same convention will work:

      local Actor actor;

      However, it's case-insensitive and recognises from context whether you mean a class or a variable (classes and variables effectively have separate namespaces), so you can actually do

      local Actor Actor;

      and that'll still work.

      It can be annoying when trying to write Unreal Tournament mods in x86 Linux (compiling under Wine, testing in the native version of UT), since a lot of the source files
  • readability (Score:5, Insightful)

    by retards ( 320893 ) on Thursday January 22, 2004 @05:26AM (#8052982) Journal
    In my opinion, case senssitivity allows for more readable code if using long variable or method names .

    For instance:

    MySteadfastObject.doSomeReallyBizarreParsing()

    instead of

    mYSTEadfasoBJEct.DOSomerEAllybizaReparsiNG()

    Emphasizing readability instead of easy-writing is (mostly) a Good Thing (TM).
    • readability has nothing to do with case sensitivity. Code is kept readable by programmers that use sane variable names and, the occasional uppercase letter.
      In a case sensitive environment this:

      MySteadFastObject.doSomeReallyBizarreParsing()

      Would produce an error because you actually meant to type this:

      MySteadfastObject.doSomeReallyBizarreParsing()

      But your head got in the way and parsed "fast" as a separate word that should have it's own uppercase letter. The only proper reason for case sensitivity i
    • That's nice, but doesn't really have anything to do with the issue. You can do the second thing in a case sensitive language (but you have to be consistent with it), and you can do the first thing in a non-case sensitivie language.

      I think the only plus for case sensitivity in Java is the Object object = new Object() meme - difference between the class and an instance. I doubt whether that is worth it.

      On a related note, I also think case sensitivity in the Unix file system sucks.

  • by BoxedFlame ( 231097 ) on Thursday January 22, 2004 @05:31AM (#8053002) Homepage
    I strongly recommend you look at IntelliJ's IDEA editor for java. It will do the case fix if you make a mistake.

    Personally I prefer case sensitivity iN ALL LanGUagEs, inCludDinG jAVa bUT AlSo IN eNGlish.
  • by LizardKing ( 5245 ) on Thursday January 22, 2004 @05:46AM (#8053057)

    Having had the pleasure of maintaining some Fortran code that was decidedly haphazard when it came to case consistency, all I can say is thank God C and Java are case-sensitive. The only reason languages like Fortran are case-insensitive is because punch cards and many early terminals only had uppercase characters. This enforced a consistency in case, but once terminals with full character sets became common I'm sure legibility of code became an issue.

    Relying on an IDE to correct your sloppy coding by enforcing case consistency is a dubious idea. An IDE can have many positive features - syntax highlighting of errors, automatic indenting - but it shouldn't automatically "fix" errors. Sooner or later the IDE will make the wrong decision about how to fix a programmers syntax error, leading to potentially subtle and hard to find bugs.

    Chris

    • The problem with that argument is, in a case-insensative language, mixing up the case isn't an "error". Sometimes it actually helps to eliminate errors because when it corrects the case you know you didn't typo it.

      I program in both VB and PHP. One of each style. I also use Option Explicit in all my VB modules, which removes the default loose-casting variable types. (I am not aware that PHP has any such feature) This means I explicitly declare each variable with the case I want for readability. I then type
      • Bloat. Case-insensitivity creates a large bottleneck in compiling. Seriously. Every symbol comparison requires special handling. Ostensibly, it's no worse than lowercasing and doing a byte-for-byte comparison. However, that's a large linear overhead (in time AND memory) at each comparison.

        Comparing PHP to VB is interesting since VB has a pretty IDE and you're doing PHP in Notepad! Write your VB in Notepad for a month and then call me.

        Ironically, you just made an argument for me anyways. Your proble
  • Mistakes easier? (Score:5, Interesting)

    by profet ( 263203 ) on Thursday January 22, 2004 @05:46AM (#8053060)
    It simply makes typing it in harder, and mistakes easier


    easier??? If anything it makes mistakes harder. Java is a very strict language syntax wise and will probably error out on compile if you have a syntax error.

    Now lets think...what would happen if it didn't error out because of case sensitive erors? Wouldn't that make it "easier" to make mistakes?
    • by LizardKing ( 5245 ) on Thursday January 22, 2004 @06:00AM (#8053106)

      Now lets think...what would happen if it didn't error out because of case sensitive erors? Wouldn't that make it "easier" to make mistakes?

      This set me thinking. The guy who posted the article would probably prefer Perl to Java. It is case sensitive, but will let him get away with his sloppy coding practices by simply creating a new variable every time it encounters one which only differentiates from another in case. Then once he's learnt the error of his ways, he'll either return to Java with a greater appreciation of it's reasonably strict syntax, or become a fan of "use strict;" ...

      I remember reading the Jargon File entry on "discipline and bondage" programming languages, which was quite disparaging about them. I found myself in wholehearted disagreement with that attitude, as most programmers I work with need to have discipline imposed on them - coding standards, style checkers and peer review help, but the quality of C code seems to generally better than Perl or C++ simply because the language is much smaller and narrowly defined.

      Chris

  • by Tune ( 17738 ) on Thursday January 22, 2004 @05:50AM (#8053071)
    - SetSlower is a procedure that reduces the speed
    - SetsLower is a function that gets a lower bound in a set of sets

    These are completely unrelated identifiers which are rendered equivalent by BASIC and other case-insensitive languages. It may look like a stupid example, but I've been annoyed on several occasions by misinterpreations of VB code that were caused by case-insensitivity. As a C/C++/Prolog/Haskell/Modula/... -coder I'm probably biased toward liking case-sensitivity, but I can't see why liking case-insensitivity should be objectively better; be more than just a bias.

    --
    What is wanted is not the will to believe, but the will to find out, which is the exact opposite -- Bertrand Russell, "Skeptical Essays", 1928

    Therefore, lets leave this issue as it is until someone comes up with good arguments to choose either one or the other.

    • - SetSlower is a procedure that reduces the speed
      - SetsLower is a function that gets a lower bound in a set of sets

      I could argue that this is actually a disadvantage of case sensitivity, since it makes this sort of error-prone situation possible. Especially if they're in the same module so that this could be a problem, then a compiler error is just the clue you need that you should give them clearer names (like getLowerBoundInSets).

      That is: Relying on case sensitivity for differentiating between funct

  • Conformance (Score:5, Informative)

    by cookd ( 72933 ) <.moc.onuj. .ta. .koocsalguod.> on Thursday January 22, 2004 @05:51AM (#8053077) Journal
    I think the biggest reason is style enforcement. The reasoning goes something like this:

    1. Case distinction is room for additional information without increasing the length of the text.
    2. For the additional information to actually be useful, people have to know what the case distinctions mean.
    3. For people to know what the case distinctions mean, there have to be established conventions.
    4. Conventions fall apart very quickly if there is no enforcement or verification.
    5. It is useful to make the compiler perform some of the verification and/or enforcement -- you're much more likely to notice problems immediately if the problem is caught by the compiler rather than an optional LINT tool.

    It is a lot like case sensitivity for English. It really isn't needed, but it sure helps you understand things a lot more easily. You can scan for the start of the next sentence much more quickly if the sentence starts with an uppercase letter and the rest are lowercase. In the same way, you can get a quick sense of what a variable is for by observing its casing, assuming that you are familiar with the casing convention in use.

    English teachers force us to use proper spelling, grammar, casing, and punctuation so we can communicate more clearly. Computer language syntax works the same way. The parser/compiler could do a fine job with a much simpler language, and it doesn't really need to be that strict about syntax checking. ("Error: missing semicolon." If it knows there is a missing semicolon, why can't it just pretend the semicolon is there and go on?) The idea is that stricter syntax checking is useful to the original programmer (many syntax errors are also indicative of logic errors or ambiguity) and also to the maintainer who has to make sense out of the code.

    So the bottom line is that following coding conventions makes your code more readable and your intent more clear. Case sensitivity is one way the compiler helps you maintain your coding conventions.
    • Re:Conformance (Score:2, Interesting)

      by SnakeNuts ( 44263 )
      I wholeheartedly agree with this point. Speed reading wouldn't be possible without case distinction. It's even easier in german, where every noun has to be captalized, so it's even easier to find the (possible) subject of a sentence. Or when you're trying to find names of persons in text, the fact that they start with capitals is damn useful. I find this the same with Java and C++. It just makes it easier to read.
  • by ivi ( 126837 ) on Thursday January 22, 2004 @06:03AM (#8053111)
    I understand that the rules of the Java game
    are no longer in Sun's hands to control...

    There's some sort of community-input standards
    committee or working group to which you (or
    any/all of us here, even) can put the Suggestion
    that Java become case-insensitive.

    In fact, why don't we organise a -mass- sugges-
    tion campaign here to do just that.

    A bit like those spontaneous "Let's all meet
    at Macca's on 5th & Spring St (or wherever)"
    that turn out crowds of people, who've never
    even met before... on somebody's whim... ;-)
  • Easier to read (Score:3, Insightful)

    by jgoemat ( 565882 ) on Thursday January 22, 2004 @06:12AM (#8053129)
    Most languages have guidelines to show you how to capitalize identifiers. It is much easier for me to read code that way than if anyone could capitalize differently than the libraries were defined.

    Being case-sensitive AND following capitalization guidelines makes code much easier to read. I don't see any reason to allow the same characters with different capitalization to refer to different variables, but I definitely think any references to a variable or function should be capitalized the same way it is defined and that all keywords should be capitalized consistently.

  • a cultural thing? (Score:2, Interesting)

    by 12dec0de ( 26853 )
    I believe that the wish for case insensitivity is a cultural thing, mainly craved for by those for whom english is the native language.

    In more than a few other (human) languages (yes there are others beside english) case conveyes difference in meaning, generally reducing redundancy and often ambiguity when compared to english. Now, those are aspects that should appeal to hackers.

    Also it probably is a windows centric idea to expect things to be case insensitive (or as the original poster pointed out have o
    • It would actually be reduced way more than 50%...it would be reduced from hrm, 63^n ([A-Za-z0-9_]) to 37^n ([a-z0-9_]) where n is the length of the identifier and assuming letters and digits used in English and underscore are legal chars.
    • Where most Nouns are Capitalized by Everone. It is a good Thing. I always liked being able to find Nouns easily in a sentence.

      Verbs at the end is confusing though. You no Idea Phrase what about is, until Pile of Verbs at the end get to. It Holistic Sentence parsing make is.

    • "Also it probably is a windows centric idea to expect things to be case insensitive"

      Why is it that as soon as someone suggests something opposed to current "hacker" taste he is instantly derided as a windows l0ser?

      ANY language I could find older than C is case insensitive. Didn't you hear the original poster talk about his __PL/I__ experience? And you deride him as a newbie? Get a grip!
  • if you look at the languages from whence java sprang, you'll see that while a lot of the semantics came from lisp (not case sensitive, easy to get lost in a sea of parentheses), the syntax is almost entirely based on that of C/C++/Object C (fewer parentheses, case sensitive). people coming from those languages (and there are a lot of them) are used to having case sensitivity and are likely to start bitching long and loud if you ever take it away from them.
    • that Lisp is case sensitive. It's just that by default the reader upcases the characters in symbols when it reads them. One can either alter the readtable or quote symbols or characters in symbols as desired to avoid that.

  • by zeda ( 415 )
    Quick guess:
    We need case sensitivity because the English language has two cases.

    I mean 'R' and 'r' don't look the same do they?
  • Ummm....beacuse they are two separate things to a computer? Asking a computer to treat 'T' the same as 't' is not a natural assumption like it is in a human - you have to put in extra code to make it do that. Therefore, you have slower compilers. While it might feel like the more natural path when trying to read your code aloud, it is definitely not the natural way of things.

    I also note that you realize English is case sensitive. You didn't have your all caps key on. Why are you not complaining about t

  • It is useful, for example, in Python. The accepted coding style is that variable names are lowercase and class names are CamelCase. The advantage of this is that you can have:
    class Object:
    #...

    object = Object()
    Which is cleaner and easier to type than:
    class ObjectClass:
    #...

    ObjectInstance = ObjectClass()
  • Up till now every answer I've seen is either a) Because it's a tradtion, b) Because it's english, c) Because in Mathematics, we distinguish, or, simply, d) Because it's just better.

    With the possible exception of c) these are rubbish. a) Even if it were traditional (which it isn't, as some pointed out -> punch cards), since when do geeks care about old stuff??? A little nostalgia, but die-hard conservatism (in the sense of "to conserve")? b) Yeah, right, "MyObject.GetNumberOfReferences" sure is proper en
      1. An argument you missed is that upper/lower case is poorly defined for Unicode.
      2. Is VARPTR a Variable Pointer or a Variant Pointer? Is a "variable pointer" something that points to memory that can be changed (a variable), or a changable pointer? Does a "variant pointer" point to a variant variable, or can it be changed to point to different types of variables?
        Meaningful names are long to reduce ambiguity. It shouldn't be necessary to read the code to understand the intent of a variable or function.
      3. Most
    • I'm afraid you're guilty of using a (d)-style argument in your own rebuttal. Basically, you are saying that you like case insensitivity better, and that's it.

      I don't like Java's mile-long member names either, but I don't think that has anything to do with case (in)sensitivity.
    • For everything you've talked about here, not having to worry about it is all well and good. However, what you fail to take into account is that in the real world, where people get paid to write code for a living, and especially in cases where you might not have the same team of coders on a project over it's lifetime who will know what everything is and does. I currently work on a system that has been in use for around 10 years, and I can assure you that most of the original team no longer works for this c
    • What's wrong with VARPTR? Is VariablePointer really better?

      Yes. Obvously, it is clearer.

      A post up top stated what I think is the best reason, which is to distiguish between class and object (their example):

      Person person = new Person();

      This is pretty common code for me. Without case sensitivity I would have to get quite awkward. Java strives for legibility and organization. Other languages strive for other things. Don't fault it for trying to meet its goals.

  • by FriendlySolipsist ( 129062 ) on Thursday January 22, 2004 @08:16AM (#8053497)
    C is carefully designed so that it does not assume that the underlying platform on which it runs is natively using ASCII. A number of relatively obscure features, especially trigraphs, were put into the language specifically to make this work.

    While case-folding is fairly easy in ASCII because upper and lower case letters are exactly one bit distant, it would substantially complicate compilation on other platforms. It is relatively unnatural for the computer to allow case-insensitivity, even in ASCII, and in machines that natively use something other than ASCII it can be quite tedious.

    Having dealt with C implementations that are targeted for machines which are radically different from what most people are used to using, I have a lot of respect for the portability of C. For example, I once worked with a C implementation on an IBM mainframe processor that had no stack, so the C stack had to be synthesized using machine registers and memory conventions, but this worked!

    C was designed to be small AND portable. Java was designed to be, well, portable. No matter how careful you try to be, dropping case-sensitivity from the language would lead to nightmares when trying to achieve portability.

  • How else could I name all my variables variants of "stuff?"

    int stuff;
    int Stuff;
    int StUfF;

    (Man, it must be early for me to think that's funny.)

  • i AgrEE. hElL, whY DoES eNGlIsH hAvE tO Be cASe sEnsItiVe? dOeS iT ReAlLy mAttEr?
  • Silly Troll... (Score:2, Informative)

    by jonadab ( 583620 )
    > Without making this into a religious war, can someone make the argument
    > of why case-sensitivity in a language is 'a good thing'?

    If you look up "holy war" online and skip over anything having to do with
    real-world non-computer-geek religions, you'll find the following classic
    examples of holy war materiel: Emacs vs vi, big-endian vs little-endian,
    *nix vs non-*nix, CISC vs RISC, and case-sensitive vs case-insensitive.

    In short, it's highly a matter of taste. Some people even like to have
    case-sensiti
  • by zero_offset ( 200586 ) on Thursday January 22, 2004 @09:28AM (#8053858) Homepage
    Having fought this war several times before (I agree that case sensitivity is an unnecessary pain in the ass), and I believe I can sum up most of the likely responses in one big post.

    1. History -- Argument: Lots of languages are case sensitive, and people seem to be capable of dealing with it, so this is a non-issue. Response: The problem is, of course, that this response completely avoids making a point relevant to the argument.

    2a. Readability -- Argument: Forcing people to type "if" instead of "IF", "If" or god forbid, "iF" will enhance readability. Response: I personally feel that all-lowercase individual words are a lot easier to read than leading capitals or all-uppercase, but this is only a solution for the predefined keywords of a language, and really fails to address the question of case *sensitivity* to case in programmer-defined names.

    2b. Readability -- Argument: If I define myCleverMethod, I don't want to debug code littered with MYcleVERMetHOD. Response: Somebody inevitably posts some variation on this, and I can't imagine why they bother. What kind of idiot would bother with such screwy capitalization?

    3. Flexibility -- Argument: Case sensitivity allows you to use the same multi-word phrase for two unrelated things when they both happen to require the same spelling. Response: I actually had somebody use the examples CarPass and CarpAss to illustrate the flexibility of case sensitivity (on the pre-release C# mailing list at Don Box's develop.com). To date I have not seen an example of this which is even remotely defensible. Elsewhere in this /. discussion someone posted SetsLow and SetSlow, which sounds slightly more realistic, but it's still reaching. Somebody show me one where the "obvious" names are significantly better than simply choosing an alternative.

    4a. Parsing -- Argument: The main reason case sensitivity exists is because uppercase and lowercase letters really are different things to a computer. Response: This mattered a lot in the old days of computing (which also yielded the terseness we see in languages like C). The machine on my desktop has a 3GHz CPU and 1GB of RAM. It can compile tens of thousands of lines of code in a matter of seconds. Although it can probably be argued that non-ASCII platforms would have a harder time performing this conversion, I'd also point out that databases and other applications in those same environments perform case conversions quite easily on those same platforms. I do not consider this a valid argument.

    4b. Parsing -- Response: The standard parsing argument could be extended in equally ridiculous directions. With the considerable power of modern desktop computers, we can do all sorts of things with text. Why not treat red, blue, and boldface text as separate characters, too?

    5. Mathematics -- Argument: Mathematicians regularly represent different variables and other elements which are differentiated only by notational case. Response: Due to the incredibly tiny fraction of programmers who are also mathematicians writing mathematical code, I believe this argument is irrelevant. It's probably one of the more interesting arguments, but frankly it's always annoyed me in mathematics, too. :)

    6. Constants and Classes -- Argument: Traditionally, many languages define constants using names which are all-uppercase, and more recently classes are often defined using names which are captialized. Response: This one always annoys me. Usually the same person is saying that the capitalization differences assist in the readability of the code moments after they've made the argument that capitalization should be inflexible for the sake of readability! There is nothing about case-insensitivity which would prevent this practice. I do it myself when I use case-insensitive languages. What it would prevent is using the same WORD to mean two different things. If that isn't just begging to introduce readability errors, I can't imagine what is. Nothing about case-insensitivity prevents peopl

  • hAVe YOu eveR tRiED TO reAd a MIxeD cAsE DoCUMenT?

    iT IS ReAL pAIN iN THe aSS.

    cODE is dIFfiCUlT eNOugH tO rEAd wIThouT coMPLIcatINg tHiNGs fURthEr.
  • When implementing a language in itself (or one like it), you usually want to have classes, or datatypes, or arms in a union, named after features of that language. For instance, in Java you might have a class called 'If' that represents an if expression. Of course, you can't call it 'if' because that's a keyword. 'If', in my opinion, is a lot better than 'if_e' or whatever.

    Some languages use initial capitals to distinguish lexical classes (like O'caml), and this is another reason to have case sensitivity.
  • by Ba3r ( 720309 ) on Thursday January 22, 2004 @10:17AM (#8054273)
    With Case Sensitivity, I can have 52 one letter variables, not 26!
  • by ykoehler ( 122420 ) on Thursday January 22, 2004 @10:22AM (#8054333)

    Why is Visual BASIC trying to preserve the case-sensitivity? If you think as you said that it is only to please the eye, think again.

    The BASIC language was to introduce people to programming and is a language that try to remove rules to allow faster results (faster != better all the time...).

    If they preserve case it probably is because people requested it and if people requested it probably has something to do more the need to have consistency.

    In english, why do we put name with a Capital in front? Or why to sentence required to be uppercase? Because case, like a letter create different pattern which may be easily recognized by the brain and treated in a different way.

  • My reasons for disliking case-insensitive software:
    • Ugliness -- Instead of a nice set of unique symbols, the system has to deal with the language and location dependent concept of case, which is an ugly mess.
    • Inefficiency -- Every string comparison is slower.
    • Imprecision -- If I write "abTable", I mean "abTable", not "abtable", "Abtable" or "ABTABLE". If I wanted it in another form, I would have written it that way in the first place.
    • Inconsistency -- Each file name and variable name should have a unique a
  • there are plenty of reasons for and against case sensitivity in languages... so why not allow both?

    just make up a compiler directive or something that indicates whether to de-case-ify your code.
  • by lokedhs ( 672255 ) on Thursday January 22, 2004 @10:55AM (#8054659)
    In english, the concept of upper and lower case is quite simple. Every uppercase letter has a lower case version, and this rule is true the other way around.

    Speakers of other languages are not quite as fortunate. I'll try to explain, but the horrible lack of Unicode slashdot coupled with the extremely stupid character filter will make this slightly more difficult than it should be.

    German, for example, has a letter which is basically a "double s". This letter only has a lower case form, in upper case, this letter becomes "SS". However, "SS" in lower case becomes "ss", not "double s".

    French has a character which is a lower case "e" with two dots above. The upper case form of this letter is the normal "E" in france, but in french canada this letter becomes an upper case "E" with two dots.

    There are other languages which has characters that only exist in upper case or lower case forms.

    Do you realise just how complex the casing rules becomes when you have to take these things into consideration? Keep in mind that Java supports all unicode characters in symbols.

    The exact same argument can be used when explaining why the oeprating system kernel shouuld not have case-insignificant file names. This is a localisation issue and neither your java compiler nor the operating system kernel should have to worry about what locale you have in order to determine how a certain string of characters should be interpreted. (yes, encoding issues always creeps in, but that's on a different level).

    Just think about it. Your program compiles properly if you select "french france" when you log in, but fails when you use "french canada".

    Don't you think it's easier just to specify that symbols are case significant?

  • by Godeke ( 32895 ) *
    Case sensitivity is a relic of the long gone day when calling upper() was considered an extravagance by the designers of C. Being a low level language, many of the functions of the original AT&T version of C were as stupid as possible while still achieving the goals. Null termination of strings, (actually the entire string function set), and bare pointer arithmetic are other examples. It was considered "super assembly for OS writing".

    Being such a bare bones, close to the metal language, case sensitivit
  • Programs are data (Score:3, Interesting)

    by scruffy ( 29773 ) on Thursday January 22, 2004 @12:09PM (#8055456)
    And don't confuse this with handling case-sensitive data, which is fine.

    No, you are confused. Programs are data, too. At least they are data to compilers.

    Consider a regular expression. Is it a program or is it data? Many filtering programs will load in a bunch of filters written as regular expressions. Which parts should be case-sensitive or case-insensitive? It turns out that it is relatively standard for lower and upper-case pattern elements to have opposite meanings, e.g., \w matching any alphanumeric character, and \W matching any non-alphanumeric character.

    Interestingly though, LISP historically has been both case-insensitive and a language that allows programs to be easily treated as data. I programmed in LISP for a long time, and the case-insensitivity wasn't any big deal. You'll get used to case-sensitivity and learn to take advantage of it.

  • by XaosTX ( 723612 ) on Thursday January 22, 2004 @12:52PM (#8056063)
    GEE, LET ME THINK...WHY DO WE NEED CASE-SENSITIVITY IN A LANGUAGE? COULD IT BE BECAUSE CASE CAN ENCODE ADDITIONAL MEANING? Take the above paragraph as an example. Was I yelling? Sure seems like it. In the same way, additional meaning can be encoded within a programming language by using that little Shift button on your keyboard.
  • by morcheeba ( 260908 ) * on Thursday January 22, 2004 @01:03PM (#8056219) Journal
    I've just started learning Spanish, and to my exceptional disappointment it is as spelling-sensitive as English. I'd like to ask Slashdot readers to make the case for spelling-sensitivity in a written language, because I can't see it. Although I've used English on and off since 1976, I also have a history of Egyptian heiroglyphics, runatic symbols, street signs, pictographs, and other legacy languages that were never spelling sensitive (perhaps due to the lack of letters in these symbolic languagues). Today I use modern languages including American Sign Language which preserves spelling for pleasing appearance, but is not spelling-sensitive itself (it will correct the case for you in the Word, which is quite nice). In all my years of speaking I have never seen the rationale for making a language spelling sensitive. It simply makes typing it in harder, and mistakes easier, yet we persevere with maintaining it in modern languages like Spanish. Without making this into a religious war, can someone make the argument of why spelling-sensitivity in a language is 'a good thing'? And don't confuse this with handling spelling-sensitive surnames, which is fine."

  • by cookiepus ( 154655 ) on Friday January 23, 2004 @01:36AM (#8063324) Homepage
    As someone with history of Java, who does C now, I instinctively want case sensitivity. If I did not have to use case, I still would. Ie, all my variables would be myStruct even if I could reffer to it as mySTRUCT and MYstrucT and whatever. So lack of compiler enforced case checking wouldn't make code less readable.

    One benefit I would get out of C being case INsensitive is this:

    I often link fortran and C objects together. For those of you who don't know, fortran is case insensitive, but when it is compiled, all function symbols are compiled as lower case with an _ attached to the end. So if in my fortran file I have a subroutine called MYstupidFORTRANroutine, and I wanted to call it from C, I would need to extern mystupidfortransubroutine_ (lowercase with the attached ampersand)

    Which is fine.

    Now here's the problem. When I do a function call from Fortran (something like CaLL MyStuPiDcSUBrouTINE) the compiled code actually calls a function mystupidcsubroutine_ . That means that in C, I must name my function mystupidcsubroutine_ (all lower case with the ampersand) in order to have it callable from fortran.

    Now, life would be simpler if all the compiled symbols became standard and case insensitive accross all languages. That would allow us to link objects together and have functions callable from one language to another. Since this one case insensitive name would have to be standardized (eg: always make it lowercase with _) then the language would have to be case insensitive as well, because otherwise myFunction and MYFUNCTION would be different symbols but must share a common name - impossible.

    This isn't really a super-strong argument for case insensitivity, but it's a possible one. Personally, I would still keep my code consistent whether I had to or not (when I write fortran code I do it even though I don't have to. it bothers me to see fortran code SHOUTING AT ME) And I would not agree that having variables called FOO Foo and foo in your code refering to different things isn't too good. Though I guess a function taking a string argument "file" and opening the global file pointer FILE to that "file" is kinda reasonable.

THEGODDESSOFTHENETHASTWISTINGFINGERSANDHERVOICEISLIKEAJAVELININTHENIGHTDUDE

Working...