NetVillage: What is CamelCase?

What is CamelCase?

Bicapitalization or camel case (frequently written CamelCase) is the practice of writing compound words or phrases where the terms are joined without spaces, and every term is capitalized. The name comes from a supposed resemblance between the bumpy outline of the compound word and the humps of a camel.

CamelCase is a standard identifier naming convention for several programming languages, and has become fashionable in marketing for names of products and companies.

The term "camel case" is sometimes used, especially when used with respect to computer languages related to C and Java, to mean naming program variables "likeThis", while Pascal case is reserved for variables named "LikeThis". This usage seems more appropriate to the metaphor, as the humps of camels are in the middle of their bodies, and not on either end.

CamelCase synonyms include:

  • BiCapitalized
  • BumpyCase
  • CamelCaps
  • CamelHumpedWord
  • CapWords in Python (reference)
  • ClCl (Capital-lower Capital-lower) and sometimes ClC
  • HumpBackNotation
  • InterCaps
  • InternalCapitalization
  • MixedCase
  • NerdCaps
  • Pascal case (used by Microsoft)
  • StudlyCaps
  • WordsStrungTogether or WordsRunTogether
  • WikiWord in TikiWiki (reference)
  • WikiName

Origins of CamelCase

CamelCase has been sporadically used since ancient times, for example as a traditional spelling style for Scottish surnames like McDonald, in some acronyms like "DoE" (for the U.S. "Department of Energy"), and in marketing for naming corporations and products, such as the CinemaScope movie projection system introduced in the 1950s.

However, the use of CamelCase became widespread only in the 1970s or 1980s, when it was adopted as a standard or alternative naming convention for multi-word identifiers in several programming languages. There are two theories as to why and where that custom started.

The "Lazy Programmer" theory

One theory on the origins of CamelCase in computing claims that the style originated within the culture of C programmers and hackers, who found it more convenient than the standard underscore-based style.

Indeed, in most keyboards the underscore key is inconveniently placed, and must be typed with the help of the SHIFT key. Also, in many fonts the underscore character is easily confused with a blank space or with a minus sign. Moreover, compiler limits on identifier length and the small computer displays available in the 1970s worked together to encourage brevity. So — according to this theory — many programmers chose to use CamelCase instead, because it yielded legible compound names with fewer keystrokes and fewer characters.

The "Alto Keyboard" theory

Another theory is that CamelCase actually started at Xerox PARC around 1978, with the Mesa programming language developed for the Xerox Alto computer. This machine lacked an underscore key, so the Mesa libraries and the Alto operating system had to be coded all in CamelCase.

The Smalltalk language, which was also developed originally on the Alto and became quite popular in the early 1980s, may have been instrumental in spreading the style outside PARC. Another boost was provided by Niklaus Wirth — the inventor of Pascal — who acquired the taste for CamelCase during a sabbatical at PARC, and used it in Modula, his next programming language.

CamelCase and Wiki

CamelCase was the original wiki/ WikiWiki convention for creating hyperlinks: a word became a link, with the link label equal to this word, and the link target being the page with that name, if it was of this form, with the additional requirement that the capitals are followed by a lower-case letter, hence AlabamA and ABc will not be links, see Wiki:WikiCase. (In the Wiki context, CamelCase was called WikiWord)

The following do not strictly qualify as bicapitalization, but are CamelCase for the purposes of the original version of the WikiWiki software:

  • AlabamA (CamelCased words need at least two components)
  • aNaRcHy cAsE

CamelCasedTerms were not useful for search engine spidering and indexing, as search engines cannot rank links based on individual words in the url describing that link. Having a word in the url generally rates a page as related to that word. Separating words out individually (by placing hyphens between words in local paths or in dns names; the underscore is not a valid character for dns names) addresses this. Removing case sensitivity from links also allows use of tools such as Apache's mod_speling, allowing easier guessing of urls by humans.

Note: This entry is a stub. Want to help out? Register and help along!

Source: Wikipedia, CamelCase
See also: C2 Wiki, CamelCase

CategoryWiki