{"id":114,"date":"2005-10-27T19:05:21","date_gmt":"2005-10-27T09:05:21","guid":{"rendered":"http:\/\/www.somethinkodd.com\/oddthinking\/?p=114"},"modified":"2007-12-29T12:45:55","modified_gmt":"2007-12-29T02:45:55","slug":"the-case-for-case-preserving-case-insensitivity","status":"publish","type":"post","link":"https:\/\/www.somethinkodd.com\/oddthinking\/2005\/10\/27\/the-case-for-case-preserving-case-insensitivity\/","title":{"rendered":"The Case for Case-Preserving, Case-Insensitivity"},"content":{"rendered":"<p><!-- UnMarkedDown_2_01132526463--><\/p>\n<blockquote><p><em>It is a mistake to consider the prime characteristic of high-level languages to be that they allow us to express programs merely in their shortest possible form and in terms of letters, words, and mathematical symbols instead of coded numbers.  Instead, the language is to provide a framework of abstractions and structures that are appropriately adapted to our mental habits, capabilities, and limitations.<\/em> &#8211; <a href=\"http:\/\/www.cs.inf.ethz.ch\/~wirth\/\">Niklaus Wirth<\/a> <a href=\"http:\/\/members.aol.com\/SergeyP\/paper.html\">[Ref]<\/a><\/p><\/blockquote>\n<h2>Introduction<\/h2>\n<p>Okay, now that I&#8217;ve got the framework for my argument in place, I am ready to start in earnest.<\/p>\n<p>We have reviewed what <a href=\"http:\/\/www.somethinkodd.com\/oddthinking\/2005\/10\/26\/the-world-of-case-sensitivity\/\">case sensitivity<\/a> is, and what the options are. How should we decide which one to use?<\/p>\n<p>I think that <em>case-preserving, case-insensitivity<\/em> is, almost always, the optimal behaviour. This may be somewhat controversial, so let me explain my position.<\/p>\n<h2>Addressing the Arguments Against<\/h2>\n<p>I&#8217;ll start by addressing the reasons <em>against<\/em> case-insensitivity &#8211; that is, <em>for<\/em> case-<em>sensitivity<\/em>.<\/p>\n<h3>Simplicity of Development<\/h3>\n<p>One argument <em>for<\/em> case-<em>sensitivity<\/em>, in internationalised software, is that it neatly side-steps all the <a href=\"http:\/\/www.somethinkodd.com\/oddthinking\/2005\/10\/25\/the-world-of-upper-lower-case-mappings\/\">clumsiness and complexity<\/a>  of dealing with case issues in multiple characters sets and locales. It makes the programmer&#8217;s job a lot easier by not trying to find the corresponding upper- (or lower-) case character from the user&#8217;s input.<\/p>\n<p>It is also slightly more efficient, with less effort (both computational and development) spent on processing the characters.<\/p>\n<p>I can understand this argument, and I have a certain amount of sympathy for the programmer who is trying to support internationalisation of their software &#8211; I&#8217;ve been there myself.<\/p>\n<p>However, this argument, to me, sounds too similar to the &#8220;elegance and efficiency&#8221; argument about Reverse Polish Notation that I described <a href=\"http:\/\/www.somethinkodd.com\/oddthinking\/2005\/10\/24\/whatever-happened-to-rpn\/\">before<\/a>. Making things slightly easier for the programmer, at a cost of ignoring the capabilities of the user, is a short-term solution. <\/p>\n<p>Perhaps during the initial development of Unix in the 1970s, the extra effort involved in finding a canonical form of a filename &#8211; even in ASCII, rather than Unicode &#8211; was too slow, but this is no longer an adequate argument.<\/p>\n<h3>Conciseness of Identifiers<\/h3>\n<p>Another argument <em>for<\/em> case-<em>sensitivity<\/em> is that it makes it possible to use the same word as two different identifiers. A common example is to let an instance be named after a class, but with different case. <\/p>\n<p>e.g. <code>class Foo foo(\"bar\");<\/code><\/p>\n<p>While I will admit to having often adopted such a coding style in C++, I find it very hard to defend this practice.<\/p>\n<p><a href=\"http:\/\/www.somethinkodd.com\/oddthinking\/2005\/10\/25\/obvious-coding-style-observation\/\">We have seen before<\/a> that similar sounding variable names in the same scope is deplorable, and the opportunity for confusion here is enormous. The gap between the concepts of an instance and the class is greater than a simple case-shift of the initial letter might indicate. The <em>reason<\/em> for the existence of the instance should be included in the identifier.<\/p>\n<p>Yes, that may mean typing in a few more characters per identifier. Some programmers seem to find that abhorrently inefficient. I don&#8217;t share such views. The time taken to add a few more characters aids the readability of the code. Wirth&#8217;s quote describes my position well.<\/p>\n<h2>Addressing the Arguments For<\/h2>\n<p>Wirth asks for software to be adapted to our &#8220;mental habits, capabilities, and limitations&#8221;. When we examine these properties, as it comes to case, we can see that English-speaking humans treat upper- and lower-case to be both very similar, and yet slightly different. This similarity suggests that the software cannot afford to be case-sensitive. This difference suggests that non-case preservation will hinder understanding.<\/p>\n<h3>Upper- and Lower-Case are the same&#8230;<\/h3>\n<p>The capabilities and limitations of English speaking humans include getting easily confused between two strings that are very similar to our language-processing brains &#8211; even where they are clearly different to a character-encoding-processing machine.<\/p>\n<p>Suppose I declare that &#8220;KEANU REEVES <a href=\"http:\/\/www.somethinkodd.com\/oddthinking\/2005\/09\/13\/judging-the-wordpress-google-sitemap-plugins-redux\/\">interferes with elephants<\/a>.&#8221;. Can I claim that I was not libelling the wooden Hollywood actor, purely because I spelt his name in all-caps? Can I claim to a judge that <code>KEANU REEVES<\/code> was a undeclared identifier and therefore the entire statement was semantically meaningless? Of course not. The English language is flexible enough to recognise that &#8220;KEANU&#8221; and &#8220;Keanu&#8221; are the same name.  Even mail addressed to &#8220;KeAnU rEeVeS&#8221; will be delivered to the correct person.<\/p>\n<p>If a computer can also  disambiguate this accurately, it should do so too. If the software fails to adapt to the similarity of upper- and lower-case, it leads to frustration.<\/p>\n<p>For me, an example of this frustration appears in both Python and PHP. Each of them have the same killer combination: they are case-sensitive with identifiers, but they are scripting language that do not resolve identifiers at parse-time. I consistently fall for the same traps. A distressingly large percentage of my debugging time is spent correcting mistyped identifiers &#8211; often not detected until several minutes into a test run. The most common mistyping I make is incorrect capitalisation. Of those, the two most common capitalisation errors I make are: HOlding DOwn THe SHift KEy TOo LOng, and being inconsistent in CamelCasing  the term &#8220;fileName&#8221; (I never did resolve satisfactorily whether it was one word or two!)<\/p>\n<p>I do not feel that the punishment I receive for this type of error fits the crime. The language should be case-insensitive and forgive me these transgressions.<\/p>\n<h3>Upper- and Lower-Case are different&#8230;<\/h3>\n<p>While upper- and lower-case versions of text may be considered similar, <a href=\"http:\/\/en.wikipedia.org\/wiki\/List_of_case_sensitive_English_words\" title=\"Wikipedia definition of List_of_case_sensitive_English_words\" class=\"wikipedia\">capitalisation in English is not completely  irrelevant<\/a>. <\/p>\n<p>Capitalisation serves a useful purpose in clarifying proper nouns, acronyms and initialisms. Where identifiers are precluded from containing spaces, capitals also provide hints to word-breaks.<\/p>\n<p>Smashing case, whether by technology (e.g. FAT16) or by convention (e.g. Unix programmers generally eshewing capital letters &#8211; and most vowels!) unnecessarily hinders the ability to produce easyToRead identifiers.<\/p>\n<h2>Summing Up<\/h2>\n<p>For the large number of computer users who speak English or any of the other Germanic, Italic or other minuscule-supporting language families, case is an integral part of the way they think. The difference between &#8216;A&#8217; and &#8216;a&#8217; is minuscule (pun intended!) compared to the difference between &#8216;A&#8217; and &#8216;B&#8217;.<\/p>\n<p>Ideally, our software should be adapted to this mind-set.  Case-preserving, case-insensitive software is the best way to do this.<\/p>\n<p>Even though case-transformation is not <em>trivial<\/em>, it is still easy enough. Computers, long ago, became powerful enough to perform these operations practically for free &#8211; in terms of run-time cost and development cost. <\/p>\n<p>There is no longer any excuse for making humans learn and handle the quirks of the way computers store upper- and lower-case characters. Instead, software should handle the quirks of human language. <\/p>\n<p><em>It is time for integration of the cases! Case-Preserving Case-Insensitivity: equal and yet different!<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I think that *case-preserving, case-insensitivity* is, almost always, the optimal behaviour. This may be somewhat controversial, so let me explain my position.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_s2mail":"yes","footnotes":""},"categories":[29,25,34],"tags":[201,200,199,374],"class_list":["post-114","post","type-post","status-publish","format-standard","hentry","category-influencing-others","category-insufficiently-advanced-technology","category-software-development","tag-argument","tag-case-preserving","tag-case-sensitivity","tag-software-development"],"_links":{"self":[{"href":"https:\/\/www.somethinkodd.com\/oddthinking\/wp-json\/wp\/v2\/posts\/114","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.somethinkodd.com\/oddthinking\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.somethinkodd.com\/oddthinking\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.somethinkodd.com\/oddthinking\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.somethinkodd.com\/oddthinking\/wp-json\/wp\/v2\/comments?post=114"}],"version-history":[{"count":1,"href":"https:\/\/www.somethinkodd.com\/oddthinking\/wp-json\/wp\/v2\/posts\/114\/revisions"}],"predecessor-version":[{"id":1902,"href":"https:\/\/www.somethinkodd.com\/oddthinking\/wp-json\/wp\/v2\/posts\/114\/revisions\/1902"}],"wp:attachment":[{"href":"https:\/\/www.somethinkodd.com\/oddthinking\/wp-json\/wp\/v2\/media?parent=114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.somethinkodd.com\/oddthinking\/wp-json\/wp\/v2\/categories?post=114"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.somethinkodd.com\/oddthinking\/wp-json\/wp\/v2\/tags?post=114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}