The Case For Case Insensitivity

Can anyone even come up with an anecdote where case-sensitivity was helpful while programming? Come on, even a friend-of-a-friend.

Case sensitivity helps as a pnuemonic device.

Case sensitivity makes the programmers intent clearer - a reader won’t have to guess if htmltag or HtmlTags refers to the same ‘tag’.

Case sensitivity, in some cases, could help in text searches. I hate searching for a keyword and not being able to find it in notepad just because the ‘case’ radio button was set the incorrect way. ( this is kind of a lame and picky point to make - but so is complaining about case insensitivity. )

generally, case sensitive languages aren’t that difficult. I certainly haven’t ran into the problems that have been described, and I’ve coded a lot in both scripted and compiled languages. When I have ran into an error - it’s been something that I can fix within a few seconds - maybe a minute at most.

On the other hand, case insensitivity leaves the door open for sloppy coding style that makes others second guess your intent, and drives me crazy when I look at it myself.

In VB.NET I only type HTMLTag once, when declaring the variable, and thereafter I type htmltag and let the IDE change it to HTMLTag automatically.

GENIUS!!! i hereby declare that we just let the ide’s write the code.

I blogged about how just a worthless debate this about a month ago when I had to endure yet another “It’s great/It sucks” debate

You’re just gonna love my next post, “when does human life begin: a woman’s right to choose”!

I realize that Microsoft isn’t going to make C# case-insensitive on my behalf (although they should). I’m trying to save the next generation of frameworks from the horrors of case sensitivity.

No one has been able to show that there is any productivity increase or decrease with either of the two methods.

Actually, I can pull up a dozen case sensitivity horror stories without even breaking a sweat. Can you find even one example where case sensitivity actually helps a programmer? Here’s an example:


http://forum.java.sun.com/thread.jspa?threadID=638387messageID=3736785

So the problem was that instead of

gBuffer.setColor(Color.BLACK);

I should have used

gBuffer.setColor(Color.black);

The ***** (Java) wasted half of my day because of a case error. I understand that Java is a case-sensitive language, but why would it then let me use (and even propose the usage of) CAPS name when the browser Java wouldn’t actually allow it?

I have a real-world, honest-to-goodness example of where case sensitivity was not only required, but helpful. I built an accounting and reporting framework at one of my previous jobs. It was a printing company that printed bank statements, billpay checks and what not. Well one of our print jobs was to print billpay checks for one of our customers. This customer actually consisted of hundreds of child customers for whom it was printing checks. Two of their customers actually had the exact same name that differed only by case. I can’t remember the exact same name, but let’s just say BankOne, and Bankone (there actually is a BankOne, but I’m just using it as an example).

Whenever I pulled back a query and ordered the report for this customer by bank name, I would get fouled up orders for these two banks. It would show up similarly to this:

Value1 Value2 Value3 BankOne
Value1 Value2 Value3 Bankone
Value4 Value5 Value6 BankOne
Value5 Value5 Value6 Bankone

Where it should have been grouped by the actual bank name, case sensitive and all. So I changed the collation for the bank name column so that it would be case sensitive and it pulled back the data back in the correct order:

Value1 Value2 Value3 Bankone
Value5 Value5 Value6 Bankone

For example, what good is it to say that variable names must start with the type if people can all use the following to indicate the same variable name?

Then what good are numbers? I can use all of the following to mean the same thing:

12
12.0
24 / 2

Similarly, I can refer to my wife as:

Betsy
Bitsy
Liz
Beth

All totally valid forms of the name “Elizabeth”.

People intuitively know that a variable “HtmlTag” is equivalent to “HTMLTag”. Computers don’t. Why should we penalize human beings to save a zillionth of a second of computer time? Computers get faster every day; our brains don’t.

Since I have started using Visual Studio and C#, I have not had one instance where case-sensitivity hurt my productivity

I type lower case “console” all the time, and it’s wrong every single time. Pop quiz: is it Exception or exception?

I’m totally for relying on the IDE to enforce consistency, but the other way around: let it be optional: case insensitive but case preserving. In other words “preserve” the way the token was originally cased.

It would be exceedingly stupid for a developer to name two different members, methods, or properties the same except with a different case.

It is exceedingly stupid, yet it happens ALL THE TIME. Case sensitivity lets the worst instincts of developers run wild.

And similarly, don’t you think it’s more than a little dangerous to have two customers distinguished by the difference between “BankOne” and “Bankone”?

"People intuitively know that a variable “HtmlTag” is equivalent to “HTMLTag”. "

No they don’t. And they don’t intuitively know that HtMlTaG is equivalent to hTmLTAG. They need to scan it very closely. You know this… I’m not sure why you are clinging to it so hard. It’s obvious to everyone else but you that casing impacts readability and that humans can not distinguish casing differences as quickly or easily as computers do. It is also obvious that computers can compare two strings quicker using exact case than they can using case insensitivity.

"I type lower case “console” all the time, and it’s wrong every single time. Pop quiz: is it Exception or exception? "

It’s obviously Console and Exception. Why? Because Microsoft specifies casing rules when they talk about naming conventions (sound familiar?). I’m not sure why you have problems with this but you might want to brush up on your .NET naming conventions. .NET is a heck of a lot easier in this regard than Java is. Every public method/property/class/field is capitalized.

All you have to do is post another blog entry to get us off of this topic… or just admit that casing realy isn’t as big of an issue as you are making it out to be. :wink: Why is it so darn hard for people to admit they are wrong? Or even admit that they aren’t as right as they think they are?

I agree that case sensitivity is not a necessary thing. But when a language let you bite your own foot by letting you use any undeclared variable and not inform about it, I blame the language. I hate scripting languages because this solely reason (spent hours trying to find why my “shoping cart” was always empty.)

And they don’t intuitively know that HtMlTaG is equivalent to hTmLTAG. They need to scan it very closely

You’re citing a pathological case. “HTMLTag and HtmlTag” are as equal as “matt and Matt”. Which one are you?

Why is it so darn hard for people to admit they are wrong? Or even admit that they aren’t as right as they think they are?

It’s obviously Console and Exception.

Yes, obviously, because when I type “console”, I couldn’t possibly be referring to “Console”.

Why is it so darn hard for people to admit they are wrong? Or even admit that they aren’t as right as they think they are?

Like the abortion question I referenced earlier, this is ultimately a religious issue. Either you think case is significant, or you don’t.

Given the vast number of case sensitivity horror stories out there*, I was hoping people would have a little more empathy for their fellow developers.

In response to:

lets compare apples with apples here. It seems that most of us are talking about case sensitivity as it applies to programming languages, not the users experience. In the cited example, I think it’s obvious that case insensitivity is the correct way to go - but that doesn’t make it true for PHP or C#.

(You could just as easily have developed the logon dialog with a case insensitive language, and the user logon may still be case sensitive…)

It seems that most of us are talking about case sensitivity as it applies to programming languages, not the users experience

So developers aren’t users? How does it suck any less to type case-sensitive data in a login form compared to my IDE?

I think developers are users too:
http://www.codinghorror.com/blog/archives/000239.html

I’ll agree: I didn’t say that programmers aren’t users - but I would say that that when I, as a programmer, develop, I expect case sensitivity in my language. And when I log on, I think Case insensitivity is the way to go. they are two different things.

You can make an argument for case insensitivity in logging on, but that mean the same argument applies to programming languages. when I said we should ‘compare apples to apples’ that’s what I meant.

So why do some people WANT case sensitivity so badly? Do you routinely name variables the same name only with case differences?

Quick, non-scientific poll of the people arguing in favor of case-sensitivity. How often do you have two or more variables whose name differs only in case?
e.g. int foo;int Foo;foo = Foo;

The only difference between statically typed, case-sensitive langauges and dynamic scripting languages is the time at which you are notified of your casing error.(at least as it applies to case-sensitivity). With compiled languages, the compiler tells you that you have an undeclared identifier. With scripting languages, the error can be harder to trace down and occurs at runtime (or during your unit test). Neither one prevents you from making the casing error in the first place, EXCEPT the VB IDE. :wink:

“I think Case insensitivity is the way to go”

Well, that’s a whole other kettle of Pandoras box.You reduce the complexity of a password by making it case-insensitive. But’s lets focus on the current holy war. :wink:

“And they don’t intuitively know that HtMlTaG is equivalent to hTmLTAG. They need to scan it very closely.”

So if I say ,“I have aids” what do I mean? What about, “I have AIDS”? What about “I have aids to help me.” The only difference is the context, which the brain picks up on very quickly. Much quicker than any, and I mean any, computer. Provided the context between hTmLTAG and HtMLTaG doesn’t change, it’s easy for humans to note the difference and note that the case difference doesn’t matter.

Yeah, let’s get rid of case sensitivity; then replace semi-colons with whitespace or carriage returns; then the whole curly-brace thing can go in favour of constructs in plain english. Then all languages will be the same - derivatives of BASIC! Yeah, right on. Why not just stick to languages that work the way you expect, and leave the rest of us to take care of casing.

The ***** (Java) wasted half of my day because of a case error. I understand that Java is a case-sensitive language, but why would it then let me use (and even propose the usage of) CAPS name when the browser Java wouldn’t actually allow it?

But case sensitivity wasn’t the problem in your example! Read the rest of the thread - the uppercase constant, Color.BLACK, was added in JRE 1.4 and the user was running this in a browser with a 1.3 plugin. The problem was using different versions of the JRE, coupled with a crappy browser implementation that didn’t notify the user about the error.

He would have wasted the same amount of time if they would have changed Color.BLACK from a long to an object from 1.3 to 1.4.

I’m surprised that noone has mentioned a related issue: XML markup case sensivitity. HTML markup is case-insensitive but XML markup is not. Why? According to Tim Bray:

---- quote ---- quote ---- quote ----
XML markup is case-sensitive because the cost of monocasing in Unicode is horrible, horrible, horrible. Go look at the source code in your local java or .Net library.

Also, not only is it expensive, it’s just weird. The upper-case of e’ is different in France and Quebec, and the lower-case of ‘I’ is different here and in Turkey.

XML was monocase until quite late in its design, when we ran across this ugliness. I had a Java-language processor called Lark - the world’s first - and when XML went case-sensitive, I got a factor of three performance improvement, it was all being spent in toLowerCase().
---- quote ---- quote ---- quote ----

So for XML it was mostly a performance issue, not a developer preference…

A friend of a friend of mine worked for a guy who was so sloppy that he would constantly type HtMlTaG or hTmLtAg instead of HtmlTag. Thank goodness the compiler would flag it as an error. Can you imagine how much time would be wasted by programmers trying to read this guy’s code?!? Maintenance costs would go through the roof!

Wouldn’t it would be ridiculous to even have naming standards for coding if you didn’t also specifiy rules for casing? So it appears to me that naming standards is a pretty good non-empirical benefit of requiring case sensitivity.

All this arguing is silly. I have one golden rule: Case-perserving, not case-sensitive.

In my experience, most people who scream for case-SENsitivity are really only concerned with PERSERVING case. They still haven’t gotten over mS-dOS manging their pretty 8.3 file names.

I TEND TO AGREE CASING IS IRRELEVANT AS IS CORRECT SPELLING AND PUNCTUATION PROGRAMMING SHOULD BE EASY COMPUTERS SHOULD DO WHAT I WANT THEM TO DO NOT WHAT I TELL THEM TO DO THIS MAKES COMPUTERS MUCH MORE PREDICTABLE

I agree with Armen:

In Visual Basic, you declare a variable, for example, as:

Dim strName as String

Now, if you type

strname= “Coding Horror”

or

STRNAME=“Coding Horror”

the IDE “corrects” your code after you press the ENTER key so that it appears as this:

strName = “Coding Horror”

The benefit of this is that if you type

strnam = “Coding Horror”

the variable name doesn’t “fix” itself; it shows that you made an error.

Sounds as though we need better tools.