49

Why are many languages case sensitive?

Is it simply a matter of inheritance? C++ is case-sensitive because C is, Java is case-sensitive because C++ is, etc.? Or is there a more pragmatic reason behind it?

0

33 Answers 33

70

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...

10
  • +1 For a case in point, just look at the sleaze caused by case insentitivity of MS-Windows file systems.
    – starblue
    Feb 2, 2009 at 13:37
  • 25
    In fairness, have case-sensitivity doesn't prevent that monstrosity from occurring, it simply guarantees that all four will be calls to different methods on different objects. I don't know that that's a good thing, either. :) Feb 2, 2009 at 13:43
  • 6
    Case insensitive languages don't have these problems as any serious IDE will fix the case for you. Anyway if you are working in Notepad you can fix the case with a simple Search and Replace, you can't do that in a case sensitive language as it risks breaking the code.
    – ggf31416
    Feb 2, 2009 at 13:52
  • 2
    See my answer to this question. It is bad practice to use names that differ only by case.
    – Tom A
    Feb 14, 2009 at 18:30
  • 4
    Only thing worse than different versions of SOMEOBJECT.SOMEMETHOD() varying only in case referring to same object/method pair is them referring to different object/method pairs
    – Amarghosh
    Oct 5, 2009 at 11:57
68

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.

4
  • 8
    UNIX was case sensitive for the same reasons early languages were case sensitive not because of. Programming languages pre-date UNIX, obviously. Feb 14, 2009 at 20:06
  • 22
    I think you're a bit wrong. Originally, everything was in uppercase (FORTRAN, COBOL, LISP, etc.). But it was hard to read, so they added case insensitivity to some systems (IBM mainframe), and case sensitivity to some other (Unix). The system case-sensitivity then determines language case-sensitivity. But originally, the languages were case insensitive, but you had to use uppercase.
    – J S
    Apr 22, 2009 at 9:05
  • 8
    @JS: You can use any case you want, so long as it's UPPERCASE? : )
    – idbrii
    Jan 13, 2011 at 18:50
  • 2
    An upper case character is not the same thing as a lower case one outside of computing also. For instance if I put SAP into a sentence, we know it's an acronym, and not the stuff that comes out of trees. People who do not see case differences are illiterate. They SHOUT IN ONLINE POSTINGS and are probably not going to be able to maintain the attention to detail required of a software developer.
    – Kaz
    Sep 26, 2012 at 4:10
40

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 :(

6
  • 6
    Well Japanese, Korean and Chinese don't have case, and it doesn't affect legibility. But your point is value. Feb 2, 2009 at 14:12
  • 1
    Arabic also doesn't have case. Lower case is a rather recent invention, about 1000 years old.
    – starblue
    Feb 2, 2009 at 14:29
  • 2
    Interesting. So is the different between upper and lower case Greek letters a purely modern thing too? I was pretty sure that Latin only used upper case letters, but didn't want to say for certain without checking it out.
    – Jon Skeet
    Feb 2, 2009 at 14:31
  • in .NET world you say "I Like Reading" :P
    – IAdapter
    Feb 2, 2009 at 17:29
  • 2
    @Kaz but one doesn't "capitalize" words like writing first character in hiragana and the rest in katakana.
    – Ruslan
    Apr 23, 2020 at 6:19
30

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.

4
  • 1
    Although the Java language doesn't enforce any case rules in the syntax. Feb 2, 2009 at 14:17
  • I stand corrected, some conventions are so widespread I was convinced they were actually part of the syntax. Feb 2, 2009 at 14:33
  • Eclipse will at least give you a warning if you don't use the style-guide case conventions for classes.
    – Kothar
    Feb 2, 2009 at 15:45
  • 2
    This particular coding convention, identifiers that differ by case alone, makes code harder to read. See my answer to this question.
    – Tom A
    Feb 14, 2009 at 18:33
24

My guess would be that case sensitivity enlarges the name space. A nice trick such as

MyClass myClass;

would be impossible with case-insensitive compiler.

11
  • 2
    It would be possible if types and variables didn't share a namespace, 'though. Feb 2, 2009 at 14:36
  • 3
    It wouldn't be impossible: the compiler could use the position of each token, to know which is the name of a type and which is the name of a variable.
    – ChrisW
    Feb 2, 2009 at 14:39
  • 1
    And your syntax highlighting code editor would colorfully highlight the difference.
    – recursive
    Feb 2, 2009 at 14:52
  • 1
    Java, for example, will indeed let you have variables and classes with the same name: String String = "String"; is perfectly valid.
    – Kothar
    Feb 2, 2009 at 15:49
  • 4
    Q: Why did Wirth choose case sensitivity for Modula-2 even though his earlier Pascal had been case-insensitive. A: He discovered he needed more than 26 variables in one program. Yes... it's a joke, but there's a kernel of truth there.
    – bendin
    Feb 14, 2009 at 19:31
24

Case folding is only simple in English (and for all characters < 128). The German sz or "sharp s" (ß) doesn't have an upper case variant in the ISO 8859-1 charset. It only received one in Unicode after about a decade of discussion (and now, all fonts must be updated...). Kanji and Hiragana (Japanese alphabets) don't even know lower case.

To avoid this mess, even in this age of Unicode, it is not wise to allow case folding and unicode identifiers.

4
  • +1. The biggest headache I can imagine is with internationalization.
    – Matt Ball
    Oct 18, 2010 at 1:02
  • 5
    And on a Turkish locale i and I are not the corresponding lower/uppercase characters. i-İ are a pair, and ı-I are one. Jul 3, 2011 at 13:19
  • You make an interesting point; nonetheless, the fact that an equivalence relation is defined among characters does not necessarily imply that one particular character among a group of equivalent ones must be regarded as the dominant one. Would any particular problems ensue if programs were generally forbidden from having identifiers in the same namespace which differed only in case or accents (so i/İ/ı/I would all be equivalent, as would e/E/é/ê/ë etc.)? Incidentally, my preference would be that languages require that letterforms match, but that identifiers be unique even when...
    – supercat
    May 30, 2012 at 15:45
  • 1
    ...alternate letterforms are considered identical. So if there's a field myThing, code using MyThing wouldn't compile, but the compiler/IDE could easily offer to change it to the correct form (which would have to be unique). Letterform variants can be a useful visual cue to distinguish scopes or usages, but I don't think they should be relied upon for such purposes.
    – supercat
    May 30, 2012 at 15:52
16

ExpertSexChange

I believe this is a competitor to Stack Overflow where you have to pay to read answers. Hmm... with case insensitivity, the meaning of the site's name is ambiguous.

This is a good reason for languages being case-sensitive. Less ambiguity! Ambiguity to programmers is considered yucky.

3
  • 2
    the site's name was and is experts-exchange. (Ignoring a period of dot boom stupidity)
    – peterchen
    Apr 22, 2009 at 8:12
  • @peterchen: expertsexchange.com used to work too. They dropped it later. Sep 24, 2012 at 16:45
  • 2
    As said, only for a rather brief period when the original owner sold it (IIRC to some JP Morgan subsidy - The story of which is a harrowing sample tale of the dot com boom).
    – peterchen
    Sep 24, 2012 at 17:04
15

Back when parsing and compiling was real expensive and would take all night it was advantageous to the compiler if it didn't have to worry about case.

Once identifiers came in to existence that were only unique via their case it became very difficult to go back. Many developers liked it and there doesn't seem to be a big desire to undo it.

4
  • At least one who mentioned the technical aspect.
    – Gumbo
    Feb 14, 2009 at 19:16
  • Don't you think its the other way around? In the day when parsing was expensive converting everything to upper or lower case took to long. Therefore you had to be very specific and variable 'Foo' and 'foo' where not considered the same variable...
    – Luke
    Feb 23, 2009 at 6:15
  • @Luke: I think you've mistunderstood me. By making the language case-sensitive the compiler doesn't have to worry about case since 'Foo' and 'foo' are not the same identifier. The compilier can simply use the binrary representations of the identifiers. Feb 23, 2009 at 9:09
  • This is most certainly wrong post-hoc explanation. Almost all earlier languages (FORTRAN, LISP, ALGOL, mainframe assembler) are case-insensitive or require upper-case (JCL). Also, in both ASCII and EBCDIC, uppercasing is real cheap.
    – JS0
    Jan 3, 2017 at 13:57
11

Case sensitivity adds to language readability by the use of naming conventions. You can't write

Person person = new Person("Bill");

if your language is case insensitive, because the compiler wouldn't be able to distinguish between the Class name and the variable name.

Also, having Person, person, PersoN, PeRsOn, and PERSON, all be equivalent tokens would give me a headache. :)

4
  • 1
    I worked on a maintenance program written in ADA when I first got out of college. Most of the code was WRITTEN LIKE THIS with all kinds of other random casing stuck in. I had a headache everyday from reading it. Feb 2, 2009 at 14:35
  • 3
    Disagree strongly. Having worked with both kinds of languages extensively, having to worry about casing differences in identifiers makes reading unfamiliar code far harder in case-sensitive languages.
    – T.E.D.
    Feb 2, 2009 at 18:48
  • 1
    Depends on syntax. It wouldn't work in Python, but if you have sigils or multiple namespaces or something else to distinguish them, it works just fine. I see ((list list)) in Common Lisp all the time.
    – Ken
    Dec 23, 2009 at 17:27
  • If the compiler knows that the variable type comes before the variable name, this is not an issue.
    – Ama
    Sep 2, 2021 at 13:44
9

Because they're as dumb as a box of frogs, for precisely the reasons given for the opposite viewpoint in this thread (I'm not even gonna ask what that's about. Wood for the trees and all that).

When FOOBAR = FooBar = foobar, you get to choose your convention, and other coders can do the same whether they share your preference or not. No confusion.

They also can't get away with the stroke of genius that is having a constant, function and variable all with the same name in the same file, albeit with different caps. Again, no confusion.

You call your variable WebSite, they call theirs Website, and which system gets confused? Not an easy catch either, when you're scanning.

As for lookups, is it really that much more processing to convert the name to lowercase before looking it up? Doing your own premature optimisation is one thing, expecting it from the developer of your language of choice is a whole other level of missing the point.

...and yet, all these answers saying case-sensitivity reduces confusion. Sigh

4
  • 1
    Consider a class Color, a function Label::Color (which queries the label's color) and a member variable Label::color (which stores the current color). I find this convention more readable and writable than calling the accessor "GetColor" and the variable "m_color". What do you think?
    – Iraimbilanja
    Feb 2, 2009 at 18:07
  • 2
    Having woked in case-insensitive languages a lot Iraim, I think both suck, and I don't ever do either (even in case-sensitive languages). Both are just crutches so you don't have to actually think about what truly makes those things different.
    – T.E.D.
    Feb 2, 2009 at 18:58
  • Iraimbilanja: I think you're not Japanese. :-)
    – Ken
    Dec 23, 2009 at 17:30
  • Consider conventions that use _ as separation character. To practice case insensitivity the compiler shouldn't distinguish between '_' and '', otherwise programmers calling this_little_function couldn't write it as ThisLittleFunction. That'd mess everything up IMO. Sep 24, 2012 at 16:31
9

Many (non-programming) languages (e.g. European using the Roman alphabet) are case-sensitive, so it's natural for native speakers of those languages to use upper- / lower-case distinctions.

The very idea that programming languages wouldn't be case-sensitive is a historical artifact arising from the limitations of early-generation hardware (including pre-computer teletype machines that used a 5-bit character code).

People who argue for case-blind languages must be unable to distinguish

IAmNowHere

from

IAmNowhere

(It's a joke! ;-)

3
  • Case sensitive natural languages? tell that 2 the txting teen8rs
    – Iraimbilanja
    Feb 2, 2009 at 18:09
  • Most(non-programming) languages are not dual-case languages. In fact, only Europe and USA has dual-case languages. Jun 8, 2009 at 11:13
  • With one minor distinction (below) I take your point that dual-case writing is not universal across natural languages. However, much early work in computer programming was done in Europe and the US, so it's no surprise that the writing conventions there tended to show up in programming languages. (Dual-case vs mono-case is a property of a writing system, not a language. Some languages have more than one written form, and some of those include a form using the Roman alphabet with mixed case. Of course, some of those are non-indigenous.)
    – joel.neely
    Jun 11, 2009 at 12:55
9

What is the capital form of i? I (U+0049) or İ (U+0130)?

Capitalization is locale dependent.

2
  • The capital form of i is U+0049 since one programs in English and anglicizes foreign words in code.
    – Iraimbilanja
    Feb 2, 2009 at 18:11
  • 4
    The majority program in English. Should it be an absolute requirement of language design, though? I think being case-sensitive is less ambiguous. Also, the character U+0069 != U+0049. Outside (alphabet-dependent) natural language processing, why should it? I do not see any benefit.
    – McDowell
    Feb 3, 2009 at 11:40
5

There's also Common Lisp, which is a case-sensitive language that many people mistakenly believe is case-insensitive. When you type (car x) into the Listener, it turns into (CAR X) for processing. It is possible to define symbols with lower-case names, but they have to be quoted with something like |lower-case-symbol|. Therefore, typing in (car x) or (CAR X) or (Car X) all works the same.

(Franz Lisp was at one point introducing what they called "modern" capitalization, in which the Listener would not fold cases, and CL keywords would be in lowercase. I never followed it well enough to know what happened there.)

3
  • upvoted note because it precisely answered the question but was entertaining and informative
    – Andy Dent
    Feb 2, 2009 at 15:41
  • The reader can do whatever you want: setf readtable-case to :upcase, :downcase, :preserve, or :invert. But the builtins are all uppercase, and people don't tend to like saying (CAR my-list).
    – Ken
    Feb 2, 2009 at 18:17
  • Thanks for the clarification, Ken. I neglected to mention that I was referring to default settings (not to mention I lack experience with hacking the reader). Feb 2, 2009 at 19:00
4

The upper-case of a letter isn't a universal concept. Java uses Unicode, so if you wanted case-insensitive Java, the meaning of your program could change depending on what locale it was compiled in.

Most languages don't let you put dots or commas (or apostrophes or spaces) in the middle of integer literals, probably because that's also locale-dependent.

4

From .NET Framework Developer's Guide Capitalization Conventions, Case-Sensitivity:

The capitalization guidelines exist solely to make identifiers easier to read and recognize. Casing cannot be used as a means of avoiding name collisions between library elements.

Do not assume that all programming languages are case-sensitive. They are not. Names cannot differ by case alone.

4

I think having a case-sensitive language ENCOURAGES people to write poor code.

Const SHOESIZE = 9

Class ShoeSize

ShoeSize.shoesize = SHOESIZE

call shoeSize(ShoeSize);

function shoeSize(SHOEsize)
{
   int ShoeSIZE = 10
   return ShoeSize
}

Duh. You couldn't think of a better variable name than "ShoeSize" for the different purposes? There is a billion different words you could use, but you choose to just keep using ShoeSize instead?

1
  • 7
    IME, the sort of people who write this junk in case-sensitive languages, don't write any better code in case-insensitive languages: they just use _shoesize, __shoesize, shoesize2, etc.
    – Ken
    Dec 23, 2009 at 17:34
4

How do you yell if you don't HAVE CAPS?! AHHH!

You have to be expressive. But in all honesty, of all the people in the world, those who work with programming logic would be the first to insist that differences are in fact differences.

4

I have read this entire thread. I must believe that those that report to have found value in case sensitivity have never programmed in a true high level language (which by definition is case insensitive). K&R admit that C is mid-level. After programming in Pascal, Delphi, Lazarus, ADA, etc, one learns that highly readable code is simple to write and to get to run quickly without obsessing on terse case sensitive constructs. After all, readability is the first and last word on the subject. Code is written for the human, not the computer. No problems to debug with case insensitive code. When one moves down to a mid-level language, one finds that there are NO advantages to case sensitivity. There are however, a considerable number of hours spent debugging case sensitivity caused problems. Especially when patching together modules from different coders. It also appears that a large number of respondents do not understand what is meant by case insensitivity. Only the characters a-z are affected. These are a sequential subset of ASCII characters. Three or four bytes of machine code make the compiler indifferent to case in this range of characters. It does not alter under-bar, numerals, or anything else. The points about other languages and character sets simply do not apply to this discussion. The compiler or interrupter would be coded to temporarily convert or not convert the character for analysis at compile time based on the being ASCII or not.

I am shocked at the new languages like Python that have come out repeating the mistake that K&R made. Yes they saved half dozen bytes in an environment where the total RAM for compiler, source, and object code was 1000 bytes. That was then. Now Memory is not a problem. Now, for no sensible reason, even the reserve words in Python are case sensitive! I do not think I will need to use "For" of "Print" as variable or function name. But that possibility has been preserved by the expensive of the time spent contenting with the interrupter over the exact case of each identifier. A bad deal I think.

The closest thing I have read to date in support of case sensitivity is the comments on Hashing. But these rare coding events that can be handled with careful attention to detail do not seem to be to be worth the pointless scrutiny a coder must use to write case sensitive code. Two views of the problem. One encourages bad coding, set traps in the code, and requires extra attention to be diverted away from bigger concepts. The other has no down side, has worked flawlessly in high level languages, and allows flexibility were it does no harm. It looks to me like yet another case of VHS wins over BETA. It's just my two cents worth here.

3

Lots of people here have said that it would be bad for several forms of capitalization to refer to the same thing, e.g.:

person
perSoN
PERSON

What would be really bad is if these all referred to different objects in code. If you've got variables person, perSoN and PERSON all referring to different things, you've got a problem.

3
  • 7
    By typical coding standards, Person would be a class, person a variable name, and PERSON a constant. It's often useful to use the same word with different capitalization to mean something related but slightly different. Feb 2, 2009 at 16:30
  • 3
    Bill, there is nothing anywhere enforcing that, so I am constatly comming across code that behaves differently. If you can't count on it, then you have to assume it could be anything and go look it up. This is why case-sensitivity is a hazard.
    – T.E.D.
    Feb 2, 2009 at 18:54
  • 1
    IIRC, Ruby actually enforces that convention.
    – dan04
    Mar 24, 2011 at 1:27
3

Case sensitivity doesn't really help case consistency.

Foo.Bar  
foo.Bar  
fOO.bAR  

In a case insensitive language that can be fixed automatically by the editor easily. In a case sensitive language fixing it it's harder as it may be legal. The editor first has to ckeck if foo.Bar and fOO.bAR exist and also has to guess that you typed with the wrong case rather than forgetting to declare the variable (as Foo is different to fOO).

3

Every example I've seen supporting case sensitivity is based on a desire to write bad, undescriptive code. e.g. the "date" vs. "myDate" argument - these are both equally undescriptive and bad practice. Good practice is to name it what it actually is: birthDate, hireDate, invoiceDate, whatever. And who in their right mind would want to write code like:

Public Class Person
    Public Shared ReadOnly PERSON As Person
End Class
Public Class Employee
    Public person As Person = person.PERSON
End Class

Amazingly this is perfectly valid case insensitive VB.Net code. The thought that case sensitivity allows you to even more flagrantly disobey good programming practice is an argument against it, not for it.

1

Because many people find employeeSocailSecurityNumber just as readable as employee_social_security_number and it is shorter.

1

MyClass myClass; would be impossible with case-insensitive compiler.

Or you could be smart and actually use 2 different words... that better show what you are actually trying to do, like:

MyClass myCarDesign;

Duh.

1
  • 5
    sometimes you do just want to call a "Date" a "date". being forced to add superfluous prefixes ("theDate", "myDate") is a pain when I know clearly that "Date" is a class and "date" is a variable.
    – nickf
    Apr 22, 2009 at 8:01
1

And you could also (foolishly) just use single-letters ("a" and "b" and "c") for all classes, variables, functions, and methods.

But WHY would you want to?

Use names that make sense, not:

function a(a)
{
    int a = a.a;
    return a
}
0
1

By typical coding standards, Person would be a class, person a variable name, and PERSON a constant. It's often useful to use the same word with different capitalization to mean something related but slightly different.

So, if you had three staff members in your business all called Robert, you'd refer to them as Robert, robert and ROBERT would you? And rely on people to know exactly which one you meant?

Give them email addresses such as [email protected], [email protected], and [email protected] if your email system was case sensitive?

The potential for an unauthorised breach of personal data would be huge. Not to mention if you sent the database root password to the disgruntled employee about to be sacked.

Better to call them Bob, Robbie, and Robert. Better still to call them Robert A, Robert B and Robert C if their surnames were e.g. Arthur, Banks, and Clarke

Really - why on earth have a naming convention that invites mistakes or confusion, that relies on people being very alert? Are you so short of words in your volcabulary?

And as for the person who mentions the supposedly handy trick "MyClass myClass" - why, why why? You deliberately make it difficult to see at a glance whether a method used is a class method or an instance method.

Plus you lost the chance to tell the next person reading your code more about the particular instance of the class.

For instance.

Customer PreviousCustomer

Customer NewCustomer

Customer CorporateCustomer

Your instance name needs to ideally tell your colleague more than just the class it's based on!

2
  • 1
    You are all over the map here. You are comparing coding naming conventions to human interactions and also data entry. These are all different things imo and shouldn't be used to pick apart the quoted statement. I find constant, instance and class level naming conventions pretty easy to read, it is just like reading the syntax of the language no need to be very alert.
    – pllee
    Apr 4, 2014 at 17:03
  • Your ease of reading is not shared by everyone. If your eyesight is at all poor it can be a bit of a strain, for example. I've spoken to many programmers who have made the move from vb to c# and all of them have been caught out by case sensitivity mistakes- if the uppercase and lowercase variables refer to public and private variables within a class the program compiles absolutley fine . The human eye is notoriously easy to fool by optical illusions - because we don't closely examine everything, we construct a guesswork image of the world around us. Why leave traps for folk to stumble over?
    – Andy R
    Dec 12, 2014 at 15:23
1

Learning is always easier by example so here it goes:

C#(case sensitive but usable from VB.NET which is case insensitive):

CONSTANT_NAME
IInterfaceName // Uses I prefix in all case sensitive and insensitive languages
ClassName      // Readable in both case sensitive and insensitive languages
_classMember   // sometimes m_classMember or just classMember
DoSomething(someParam) // Method with action name, params can be _someParam
PropertyName   // Same style in case sensitive and insensitive languages
localVariable  // Never using prefix

Java and JS use a style similar to C# but methods/functions/events are declared like variables doSomething, onEvent.

ObjectPascal(Delphi and Lazarus/FPC are case insensitive, like ADA and VB.NET)

CConstantName     // One can use Def or no prefix, not a standard
IInterfaceName
TClassName        // Non-atomic types/classes have T prefix e.g. TStructRecordName
PSomePointer      // Pointers have types, safer low level stuff
FClassFieldMember // F means Field member similar to m
DoSomething(Parameter) // Older code uses prefix A for parameters instead
PropertyName
LLocalVariable    // Older code uses prefix for parameters not local vars

Using only OneCase and prefixes for each type makes sense in all languages. Even languages that started without prefixes have newer constructs like Interfaces that don't rely on case but use a prefix instead.

So it's really not important if a language is case sensitive or not. Newer concepts were added to case sensitive languages that were too confusing to be expressed by case alone and required using a prefix.

Since case sensitive languages started using prefixes, it's only reasonable to stop using case with the same identifier name someIdentifier SomeIdentifier SOME_IDENTIFIER, ISomeIdentifier and just use prefixes where it makes sense.

Consider this problem: You have a class member called something, a method/function parameter called something and a local variable called something, what case convention could be used to easily differentiate between these ? Isn't it easier to just use the most ConsistentCaseStyle everywhere and add a prefix ?

Fans of case insensitive languages care about code quality, they just want one style. Sometimes they accept the fact that one library is poorly written and use a strict style while the library might have no style or poor code.

Both case sensitive and insensitive languages require strict discipline, it makes more sense to have only one style everywhere. It would be better if we had a language that used only StrictCase, one style everywhere and prefixes.

There is a lot of poor C code, case sensitivity doesn't make it readable and you can't do anything about it. In a case insensitive language you could enforce a good style in your code without rewriting the library. In a StrictCase language that doesn't exists yet, all code would have decent quality :)

0

There is another reason languages are case sensitive. IDs may be stored in a hash table and hash tables are dependent on hashing functions that will give different hashes for differing case. And it may not be convenient to convert all the IDs to all upper or all lower before running them through the hash function. I came across this issue when I was writing my own compiler. It was much simpler (lazier) to declare my language as case sensitive.

0

If word separation is not important then why do we put spaces between words? Therefore I think that underlines between words in a name do increase readability. Also lower case with Capitalization of appropriate characters is easiest to read. Lastly, it is surely much easier if all words can be conveyed by word of mouth - "Corporate Underscore Customer" rather than "Capital C Lower Case o r p o r a t e Underscore Capital C Lower Case u s t o m e r"! - the former can be spoken 'in one's head' the latter cannot - I wonder how people who are happy with case sensitivity handle these case sensitive names in their brains - I really struggle. So I feel that case sensitivity is not at all helpfull - a retrogade step from COBOL in my opinion.

0

Because people seriously overthink things.

Case insensitivity works best when it's also case-preserving and combined with a separation between type and variable namespaces. This means that:

  • If you declare a class as 'TextureImage' and then try to use it as 'textureImage', the IDE can autocorrect you. This gives you the advantage that you'll never have to hit the shift key unless you're declaring an identifier or using an underscore.

  • Just like in Java and several other languages; it's perfectly valid to type "MyClass myClass". The IDE and the compiler should have no problem differentiating between the use of a type and the use of a variable.

In addition, case insensitivity guarantees that 'o' and 'O' will never refer to different objects. Common arguments include:

  • "sOmEoNe wIlL tYpE cOdE lIkE tHiS"; => and that someone will _never_ be allowed to join a programming team, so this is a strawman argument. even if they did manage to do so, case insensitivity is more the solution than the problem, because it means that you don't have to remember whatever crazy uppercase/lowercase combination they use.

  • "you can't internationalize case insensitivity easily!"; => over 95% of programming languages are written in english for a very good reason. there are no competing character encodings and the vast majority of keyboards on earth are english based (in partial or whole). supporting unicode identifiers is perhaps the dumbest idea anyone has came up with in the 21st century; because a good portion of unicode characters are frikkin invisible surragates, reading code is hard enough without having to use google translate, and writing code is hard enough without having to copy-paste identifiers or use a character map.

  • "but case sensitive languages have more identifiers!"; => no, they have grammatically overloaded identifiers, which is substantially worse.

I don't use any case-insensitive languages, but the advantages are blatantly obvious if you think about this sort of thing seriously.

0

A reasonable answer might be that the designers of the language thought it would make the language easier to understand thinking about the future :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.