Question

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 Why are many languages case sensitive?

EDIT: (I cannot believe I asked this question a few years ago)

Was it helpful?

Solution

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.

OTHER TIPS

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.

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.

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

PRINT MYVAR
Print MyVar
print myvar

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top