Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are many languages case sensitive?

People also ask

Are all languages case-sensitive?

Some programming languages are case-sensitive for their identifiers (C, C++, Java, C#, Verilog, Ruby, Python and Swift).

What is case sensitivity of a language?

Text or typed input that is sensitive to capitalization of letters. For example, "Computer" and "computer" are two different words because the "C" is uppercase in the first example and lowercase in the second example. On modern systems, passwords are case-sensitive, and usernames are usually case-sensitive as well. Tip.

Which languages use case-sensitive characters?

A programming language that can differentiate between upper case and lower case characters is known as a case sensitive language. Many programming languages such as C, C#, C++, Java, Python, Ruby, Swift, etc. can differentiate between upper case and lower case characters making it case sensitive language.

Is there any case-insensitive language?

Case insensitivity describes a programming languages ability to ignore the difference between upper and lower case versions of a letter. Some examples of these programming languages include Ada, Fortran, SQL, and Pascal.


I don't think you'll get a better answer than "because the author(s) of that language thought it was better that way". Personally, I think they're right. I'd hate to find these lines anywhere in the same source file (and refer to the same object+method)...

SomeObject.SomeMethod();
...
SOMEOBJECT.SOMEMETHOD();
...
someObject.someMethod();
...
sOmEoBjEcT.sOmEmEtHoD();

I don't think anyone would be happy to see this...


Unix.

Unix was case sensitive, and so many programming languages developed for use on Unix were case sensitive.

Computers are not forgiving - an uppercase character is not the same thing as a lowercase character, they're entirely different. And back when processing cycles, RAM and so forth were expensive it wasn't seen as worth the effort to force compilers and computers to be "forgiving", people were just trying to get the things to work.

Notice how case insensitivity didn't really become something useful until things like Visual Basic came along - once companies started to get invested in the concept that getting the masses to program was a good thing for their bottom line (i.e., Microsoft makes more money if there're more programs on Windows) did the languages start to be friendlier and more forgiving.


One interesting thing to consider is that English is also case-sensitive. (I suspect this is true for most natural languages, but it may well not be true for all.)

There's a big difference (where I live, anyway, near the town of Reading) between:

I like reading.

and

I like Reading.

Similarly, while many people do capitalise incorrectly, and you can usually understand what is meant, that doesn't mean such writing is considered correct. I'm a stickler when it comes to this kind of thing, which is not to say I get everything right myself, of course. I don't know whether that's part of the inheritance of programming language case sensitivity, but I suspect it may be.

One distinct advantage of case sensitivity for programming languages is that the text becomes culturally insensitive as well. It's bad enough having to occasionally spell out to a compiler which text encoding is used for a source file - having to specify which culture it's in would be even worse :(


It's actually extremely practical, both for the developer and for the language syntax specification: lower/upper case distinction adds a great deal of expressiveness to identifier naming.

From the point of view of the language syntax, you can force certain identifiers to start with a lower or upper case (for instance Java class name). That makes parsing easier, and hence helps keeping the syntax clean.

From a developer point of view, this allows for a vast number of convenient coding conventions, making your code clearer and easier to understand.