views:

528

answers:

7

I personally do not like programming languages being case sensitive.

(I know that the disadvantages of case sensitivity are now-a-days complemented by good IDEs)

Still I would like to know whether there are any advantages for a programming language if it is case sensitive. Is there any reason why designers of many popular languages chose to make them case sensitive?

EDIT: duplicate of http://stackoverflow.com/questions/503218/why-are-many-languages-case-sensitive

+1  A: 

It allows the implementer of a class/library to control how casing is used in the code. Case may also be used to convey meaning.

krosenvold
A: 

The code looks more the same. In the days of BASIC these were equivalent:

PRINT MYVAR
Print MyVar
print myvar
Johannes Weiß
Just because the language is case-insensitive, it doesn't mean you just leave your caps lock on.
Pyrolistical
I think for some people it would mean just that.
JMD
AFAIK, BASIC was written a lot with caps lock on ;-)10 PRINT "HELLO WORLD"20 INPUT "YOUR NAME", A$30 PRINT "HELLO ",A$40 GOTO 10
Johannes Weiß
Many BASIC interpreters automatically converted keywords to tokens to save on RAM and parsing. When viewed, these were always shown uppercase
Gerry
+1  A: 

Case-sensitivity is inherently faster to parse (albeit only slightly) since it can compare character sequences directly without having to figure out which characters are equivalent to each other.

Welbog
A: 

With type checking, case sensitivity prevents you from having a misspelling and unrecognized variable. I have fixed bugs in code that is a case insensitive, non typed language (FORTRAN77), where the zero (0) and capital letter O looked the same in the editor. The language created a new object and so the output was flawed. With a case sensitive, typed language, this would not have happened.

Bill Perkins
You're actually onto a problem with dynamically typed languages as a whole. Mixing "case" is just one sort of misspelling, a trivial case. If you have myVariable and myVaraible (second is "misspelled") then you get no help either. But, of course, I agree. :)
BobbyShaftoe
+2  A: 

This is a preference. I prefer case sensitivity, I find it easier to read code this way. For instance, the variable name "myVariable" has a different word shape than "MyVariable," "MYVARIABLE," and "myvariable." This makes it more straightforward at a glance to tell the two identifiers apart. Of course, you should not or very rarely create identifiers that differ only in case. This is more about consistency than the obvious "benefit" of increasing the number of possible identifiers. Some people think this is a disadvantage. I can't think of any time in which case sensitivity gave me any problems. But again, this is a preference.

BobbyShaftoe
A: 

In the compiler or interpreter, a case-insensitive language is going to have to make everything upper or lowercase to test for matches, or otherwise use a case insensitive matching tool, but that's only a small amount of extra work for the compiler.

Plus case-sensitive code allows certain patterns of declarations such as

MyClassName myClassName = new MyClassName()

and other situations where case sensitivity is nice.

Tony Peterson
MyClassName myClassName = new MyClassName() is anything BUT NICE. It is a trap for junior devs etc. Yes I know the curly-bracket types use conventions like this, but it would drive me insane! I'll stick to Delphi thanks!
Gerry