Camel case


Camel case is the practice of writing phrases such that each word or abbreviation in the middle of the phrase begins with a capital letter, with no intervening spaces or punctuation. Common examples include "iPhone" and "eBay". It is also sometimes used in online usernames such as "johnSmith", and to make multi-word domain names more legible, for example in advertisements.
Camel case is often used as a naming convention in computer programming. Some programming styles prefer camel case with the first letter capitalised, others not. For clarity, this article calls the two alternatives upper camel case and lower camel case. Some people and organizations, notably Microsoft, use the term camel case only for lower camel case. Pascal case means only upper camel case.
Camel case is distinct from Title Case, which capitalises all words but retains the spaces between them, and from Tall Man lettering, which uses capitals to emphasize the differences between similar-looking words such as "predniSONE" and "predniSOLONE". Camel case is also distinct from snake case, which uses underscores interspersed with lowercase letters. A combination of snake and camel case is recommended in the Ada 95 style guide.

Variations and synonyms

The original name of the practice, used in media studies, grammars and the Oxford English Dictionary, was "medial capitals". Other synonyms include:
The earliest known occurrence of the term "InterCaps" on Usenet is in an April 1990 post to the group alt.folklore.computers by Avi Rappoport. The earliest use of the name "Camel Case" occurs in 1995, in a post by Newton Love. Love has since said, "With the advent of programming languages having these sorts of constructs, the humpiness of the style made me call it HumpyCase at first, before I settled on CamelCase. I had been calling it CamelCase for years.... The citation above was just the first time I had used the name on USENET."

Traditional use in natural language

In word combinations

The use of medial capitals as a convention in the regular spelling of everyday texts is rare, but is used in some languages as a solution to particular problems which arise when two words or segments are combined.
In Italian, pronouns can be suffixed to verbs, and because the honorific form of second-person pronouns is capitalized, this can produce a sentence like non ho trovato il tempo di risponderLe.
In German, the medial capital letter I, called Binnen-I, is sometimes used in a word like StudentInnen to indicate that both Studenten and Studentinnen are intended simultaneously. However, mid-word capitalisation does not conform to German orthography; the previous example could be correctly written using parentheses as Studenten, analogous to "congressman" in English.
In Irish, camel case is used when an inflectional prefix is attached to a proper noun, for example i nGaillimh, from Gaillimh ; an tAlbanach, from Albanach ; and go hÉirinn, from Éire. In recent Scottish Gaelic orthography, a hyphen has been inserted: an t-Albannach.
This convention is also used by several written Bantu languages and several indigenous languages of Mexico.
In Dutch, when capitalizing the digraph ij, both the letter I and the letter J are capitalized, for example in the countryname IJsland.
In English, medial capitals are usually only found in Scottish or Irish "Mac-" or "Mc-" names, where for example MacDonald, McDonald, and Macdonald are common spelling variants of the same name, and in Anglo-Norman "Fitz-" names, where for example both FitzGerald and Fitzgerald are found.
In their English style guide The King's English, first published in 1906, H. W. and F. G. Fowler suggested that medial capitals could be used in triple compound words where hyphens would cause ambiguity—the examples they give are KingMark-like and Anglo-SouthAmerican. However, they described the system as "too hopelessly contrary to use at present."

In transliterations

In the scholarly transliteration of languages written in other scripts, medial capitals are used in similar situations. For example, in transliterated Hebrew, ha'Ivri means "the Hebrew person" or "the Jew" and b'Yerushalayim means "in Jerusalem". In Tibetan proper names like rLobsang, the "r" stands for a prefix glyph in the original script that functions as tone marker rather than a normal letter. Another example is tsIurku, a Latin transcription of the Chechen term for the capping stone of the characteristic Medieval defensive towers of Chechenia and Ingushetia; the capital letter "I" here denoting a phoneme distinct from the one transcribed as "i".

In abbreviations

Medial capitals are traditionally used in abbreviations to reflect the capitalization that the words would have when written out in full, for example in the academic titles PhD or BSc. In German, the names of statutes are abbreviated using embedded capitals, e.g. StGB for Strafgesetzbuch, PatG for Patentgesetz, BVerfG for Bundesverfassungsgericht, or the very common GmbH, for Gesellschaft mit beschränkter Haftung. In this context, there can even be three or more camel case capitals, e.g. in TzBfG for Teilzeit- und Befristungsgesetz. In French, camel case acronyms such as OuLiPo were favored for a time as alternatives to initialisms.
Camel case is often used to transliterate initialisms into alphabets where two letters may be required to represent a single character of the original alphabet, e.g., DShK from Cyrillic ДШК.

History of modern technical use

Chemical formulae

The first systematic and widespread use of medial capitals for technical purposes was the notation for chemical formulae invented by the Swedish chemist Jacob Berzelius in 1813. To replace the multitude of naming and symbol conventions used by chemists until that time, he proposed to indicate each chemical element by a symbol of one or two letters, the first one being capitalized. The capitalization allowed formulae like "NaCl" to be written without spaces and still be parsed without ambiguity.
Berzelius' system continues to be used, augmented with three-letter symbols such as "Uue" for unconfirmed or unknown elements and abbreviations for some common substituents. This has been further extended to describe the amino acid sequences of proteins and other similar domains.

Early use in trademarks

Since the early 20th century, medial capitals have occasionally been used for corporate names and product trademarks, such as
In the 1970s and 1980s, medial capitals were adopted as a standard or alternative naming convention for multi-word identifiers in several programming languages. The precise origin of the convention in computer programming has not yet been settled. A 1954 conference proceedings occasionally informally referred to IBM's Speedcoding system as "SpeedCo". Christopher Strachey's paper on GPM, shows a program that includes some medial capital identifiers, including "NextCh" and "WriteSymbol".
Multiple-word descriptive identifiers with embedded spaces such as end of file or char table cannot be used in most programming languages because the spaces between the words would be parsed as delimiters between tokens. The alternative of running the words together as in endoffile or chartable is difficult to understand and possibly misleading; for example, chartable is an English word.
Some early programming languages, notably Lisp and COBOL, addressed this problem by allowing a hyphen to be used between words of compound identifiers, as in "END-OF-FILE": Lisp because it worked well with prefix notation and COBOL because its operators were individual English words. This convention remains in use in these languages, and is also common in program names entered on a command line, as in Unix.
However, this solution was not adequate for mathematically-oriented languages such as FORTRAN and ALGOL, which used the hyphen as an infix subtraction operator. FORTRAN ignored blanks altogether, so programmers could use embedded spaces in variable names. However, this feature was not very useful since the early versions of the language restricted identifiers to no more than six characters.
Exacerbating the problem, common punched card character sets of the time were uppercase only and lacked other special characters. It was only in the late 1960s that the widespread adoption of the ASCII character set made both lowercase and the underscore character _ universally available. Some languages, notably C, promptly adopted underscores as word separators, and identifiers such as end_of_file are still prevalent in C programs and libraries. However, some languages and programmers chose to avoid underscores—among other reasons to prevent confusing them with whitespace—and adopted camel case instead.
Charles Simonyi, who worked at Xerox PARC in the 1970s and later oversaw the creation of Microsoft's Office suite of applications, invented and taught the use of Hungarian Notation, one version of which uses the lowercase letter at the start of a variable name to denote its type. One account claims that the camel case style first became popular at Xerox PARC around 1978, with the Mesa programming language developed for the Xerox Alto computer. This machine lacked an underscore key, and the hyphen and space characters were not permitted in identifiers, leaving camel case as the only viable scheme for readable multiword names. The PARC Mesa Language Manual included a coding standard with specific rules for upper and lower camel case that was strictly followed by the Mesa libraries and the Alto operating system. Niklaus Wirth, the inventor of Pascal, came to appreciate camel case during a sabbatical at PARC and used it in Modula, his next programming language.
The Smalltalk language, which was developed originally on the Alto, also uses camel case instead of underscores. This language became quite popular in the early 1980s, and thus may also have been instrumental in spreading the style outside PARC.
Upper camel case is used in Wolfram Language in computer algebraic system Mathematica for predefined identifiers. User defined identifiers should start with a lower case letter. This avoids the conflict between predefined and user defined identifiers both today and in all future versions.

Computer companies and products

Whatever its origins in the computing field, the convention was used in the names of computer companies and their commercial brands, since the late 1970s — a trend that continues to this day:
In the 1980s and 1990s, after the advent of the personal computer exposed hacker culture to the world, camel case then became fashionable for corporate trade names in non-computer fields as well. Mainstream usage was well established by 1990:
During the dot-com bubble of the late 1990s, the lowercase prefixes "e" and "i" became quite common, giving rise to names like Apple's iMac and the eBox software platform.
In 1998, Dave Yost suggested that chemists use medial capitals to aid readability of long chemical names, e.g. write AmidoPhosphoRibosylTransferase instead of amidophosphoribosyltransferase. This usage was not widely adopted.
Camel case is sometimes used for abbreviated names of certain neighborhoods, e.g. New York City neighborhoods SoHo and TriBeCa and San Francisco's SoMa. Such usages erode quickly, so the neighborhoods are now typically rendered as Soho, Tribeca, and Soma.
Internal capitalization has also been used for other technical codes like HeLa.

Current usage in computing

Programming and coding

The use of medial caps for compound identifiers is recommended by the coding style guidelines of many organizations or software projects. For some languages this practice is recommended by the language developers or by authoritative manuals and has therefore become part of the language's "culture".
Style guidelines often distinguish between upper and lower camel case, typically specifying which variety should be used for specific kinds of entities: variables, record fields, methods, procedures, functions, subroutines, types, etc. These rules are sometimes supported by static analysis tools that check source code for adherence.
The original Hungarian notation for programming, for example, specifies that a lowercase abbreviation for the "usage type" should prefix all variable names, with the remainder of the name in upper camel case; as such it is a form of lower camel case.
Programming identifiers often need to contain acronyms and initialisms that are already in uppercase, such as "old HTML file". By analogy with the title case rules, the natural camel case rendering would have the abbreviation all in uppercase, namely "oldHTMLFile". However, this approach is problematic when two acronyms occur together or when the standard mandates lower camel case but the name begins with an abbreviation. For this reason, some programmers prefer to treat abbreviations as if they were lowercase words and write "oldHtmlFile", "parseDbmXml" or "sqlServer". However, this can make it harder to recognise that a given word is intended as an acronym.

Wiki link markup

Camel case is used in some wiki markup languages for terms that should be automatically linked to other wiki pages. This convention was originally used in Ward Cunningham's original wiki software, WikiWikiWeb, and can be activated in most other wikis. Some wiki engines such as TiddlyWiki, Trac and PmWiki make use of it in the default settings, but usually also provide a configuration mechanism or plugin to disable it. Wikipedia formerly used camel case linking as well, but switched to explicit link markup using square brackets and many other wiki sites have done the same. Some wikis that do not use camel case linking may still use the camel case as a naming convention, such as AboutUs.

Other uses

The NIEM registry requires that XML data elements use upper camel case and XML attributes use lower camel case.
Most popular command-line interfaces and scripting languages cannot easily handle file names that contain embedded spaces. Therefore, users of those systems often resort to camel case for compound file names like MyJobResume.pdf.
Microblogging and social networking sites that limit the number of characters in a message are potential outlets for medial capitals. Using camel case between words reduces the number of spaces, and thus the number of characters, in a given message, allowing more content to fit into the limited space. Hashtags, especially long ones, often use camel case to maintain readability.
In website URLs, spaces are percent-encoded as "%20", making the address longer and less human readable. By omitting spaces, camel case does not have this problem.

Readability studies

Camel case has been criticised as negatively impacting readability due to the removal of spaces and uppercasing of every word.
A 2009 study comparing snake case to camel case found that camel case identifiers could be recognised with higher accuracy among both programmers and non-programmers, and that programmers already trained in camel case were able to recognise those identifiers faster than underscored snake-case identifiers.
A 2010 follow-up study, under the same conditions but using an improved measurement method with use of eye-tracking equipment, indicates: "While results indicate no difference in accuracy between the two styles, subjects recognize identifiers in the underscore style more quickly."
Inconsistency of multi-word style, or combinations of style within a single name, can be confusing. An interesting example is "Creative Commons Attribution-ShareAlike 3.0 Unported License", which names a "thing" using three multi-word combination methods at once: space, dash and upper CamelCase. Difficulties arise when a new thing is created by combining things with different naming conventions. When the creation is dynamic and ongoing over time, it can be more confusing to try to transform from the individual native styles, to a consistent overall style.