Who Needs Case-Sensitivity in Java?
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."
So case sensitivity enforces your convention. (Though usually programmers have more sophisticated conventions). Otherwise, THISISAVARIABLE compiles. Since reading /debugging code is harder than writing it, it makes sense for the programming language to strictly require readable code.
A case sensitive compiler lets you do horrible things like having two properties of an object with the same name except for the case. Example: myObject.list and myObject.List. A case insensitive compiler won't let you have that.
Readable code is a human responsibility, and can't be delegated to a mere compiler.
How is it again that it "strictly requires readable code"?
About twice as long for a string comparison is what I would definitely call slower.
(...)
Including all interpretted scripting languages, loadable plugins, and just-in-time compiled code, the last of which being safer and (some day) faster than standard compilation?
Did you know that Java is actually compiled? All the case insensitive stuff would be sorted out when producing bytecode. You just need to sort out issues when you have statements lik "eval" where a string, created at runtime, is executed as code (which is the BAD programming practice i was referring to above).
In Java, since you have to explicitly declare variables before use, the compiler will notice that you typed Var when you meant var and complain. Your criticism is correct about, say, Python, because in Python referring to Var means a new variable Var is created. I believe Python is still case sensitive, because of speed reasons, although Python's developers would prefer case insensitivity if it had no speed cost, I suspect.
In a case insensitive compiler, there would be no error, the code would just work. And, the merit of java is having to declare variables, it has nothing to do with case-sensitivity.
My Stack Overflow user