2

Possible Duplicate:
Is there any advantage of being a case-sensitive programming language?

My first programming experiences where with the Basic family (MSX Basix, Q-basic, VB). These are all not case-sensitive. Now, it might be because of these first experiences, but I've never grasped the benefit of a language being case sensitive. On the contrary, I think it is a source of unneeded overhead and bugs, and it still annoys me when I use e.g. Java or C.

Now, I just read on Clojure (a Lisp-dialect) and noticed - to my surprise - that one of the differences with Lisp is case-sensitivity.

So: what is actually the benefit (to the programmer) of having a case-sensitive language?

The only things I can think of are:

  • double the number of symbols
  • visual feedback and easier reading for complex variables using techniques like CamelCase, e.g. HopCount

However, the first argument doesn't hold because of being a major source for bugs (bad practice to use hopcount and HopCount in one method).

The second argument doesn't hold either, as a decent IDE can provide this also in an other way. A good example is the VBA IDE, which has a very good approach: the langauge is case-insensitive but as soon as you type a variable it will change it to the case used in its definition. For example, if you defined Dim thisIsMyVariable as string, it will change any occurrence of thisismyvariable into thisIsMyVariable). That provides the programmer with an immediate clue that the variable was actually typed-in correctly (because it changed appearance).

Edit: added ... benefit to the programmer ...

Community
  • 1
  • 1
Rabarberski
  • 23,854
  • 21
  • 74
  • 96
  • 3
    Technically it's not double the number of symbols. Assuming a maximum symbol length of 32 characters, case-insensitive may be something like 38 characters (`a-z0-9_$`), having `38 ^ 32 = 3.57e+50` permutations. Adding another 26 characters when case-sensitive, we have `64 ^ 32 = 6.28e+57` permutations, which is about `1.76e+7` times more symbols, not just two times more symbols. Not that it's important. – Delan Azabani Mar 04 '11 at 13:07
  • I think readability is the main one. Also makes the compiler do slightly less work. Consider `String string = new String();` – Melv Mar 04 '11 at 13:08
  • 2
    Yeah, for what it's worth, I **completely agree** about case sensitivity being there for the benefit of the computer, rather than the programmer. Unfortunately, this seems like a subjective/argumentative question, for which there is no clearly-defined answer. As such, I don't think it's a good fit on Stack Overflow. I don't really know what the policies are over at [programmers.stackexchange.com](http://programmers.stackexchange.com), but I think it'd be an interesting discussion to have there. – Cody Gray - on strike Mar 04 '11 at 13:08
  • 1
    Numerous duplicates, e.g. [Is there any advantage of being a case-sensitive programming language?](http://stackoverflow.com/questions/521349/is-there-any-advantage-of-being-a-case-sensitive-programming-language), [What's the advantage of case sensitive languages over case insensitive ones?](http://stackoverflow.com/questions/3942489/whats-the-advantage-of-case-sensitive-languages-over-case-insensitive-ones) and [Why are many languages case sensitive?](http://stackoverflow.com/questions/503218/why-are-many-languages-case-sensitive), to name but three. – Paul R Mar 04 '11 at 13:16
  • Languages are case-sensitive because now they *can*. VT50 terminal had capital letters only. Old printronix printers could print capital letters only. But anything more recent than that allows to use both cases. – SK-logic Mar 04 '11 at 13:23
  • @Paul: oops, I did a search on "case sensitive" in the SO search box, but all results returned were no good. Seems like the search function in SO could use some improvements... – Rabarberski Mar 04 '11 at 13:24

2 Answers2

1

One point is, like you said, visual aid. Most programming languages (and even frameworks) have conventions on how to capitalize variables, names, etc. Also, it enforces using uniform names everywhere, so you don't have a mess with the same variable referred to as "var", "Var" or even "VaR".

I can't remember of ever having bugs related to capitalization, so that point seems kind of contrived to me. Using 2 variables of the same name but different capitalization to me sounds like a conscious attempt to shoot yourself in the foot. Different capitalization conventions almost everywhere signify objects of completely different type (classes, variables, methods and so on), so it's pretty hard to make such a mistake due to the completely different semantics.

I'd like to think of it in this way: what do we gain by NOT having case-sensitivity? We introduce ambiguity, we encourage sloppiness and poor style.

This is a slightly subjective matter of course.

Tomas
  • 704
  • 5
  • 10
0

Many naming conventions demand that symbols denoting objects from different semantic classes (types, functions, variables) have their own name casing rules. In Java, for example, types names always begin with a upper case letter, while variables, member function names etc. begin with a lower case letter. This effectively puts type names in a different namespace and gives a visual clue what a statement actually means.

// declare and initialize a new Point
Point point=new Point();
// calls a static member function of type Point
Point.fooBar();
// calls a member function of Point
point.moveTo(x,y);
Nordic Mainframe
  • 28,058
  • 10
  • 66
  • 83
  • I was going to post a very similar answer. As I often times use MainModel mainmodel = new MainModel() {foo=1, bar=0}; – SQLMason Mar 04 '11 at 13:20
  • I dislike *both* practice of using identifiers which differ only in case (allowed in C#), *and* the use of inconsistent case when referring to an identifier (allowed in VB.NET). If I had my druthers, if `Foo` was declared in one scope and `foo` within a nested scope, then within that nested scope `Foo` would refer neither to the outer name nor the inner one, but would simply be forbidden. Such a rule would make it easier for an IDE to correct any problems [I find the C# IDE to be not very helpful in that regard]. – supercat Sep 16 '13 at 20:02