CamelCase
From Free net encyclopedia
Image:CamelCase sign.jpg CamelCase, camel case or medial capitals is the practice of writing compound words or phrases where the words are joined without spaces, and each word is capitalized within the compound. The name comes from the uppercase "bumps" in the middle of the compound word, suggesting the humps of a camel.
This practice is known by a large variety of names, including BiCapitalization, InterCaps, MixedCase, etc., and many of its users do not ascribe a name to it at all.
CamelCase is a standard identifier naming convention for several programming languages, and has become fashionable in marketing for names of products and companies. Outside these contexts, however, CamelCase is rarely used in formal written English, and most style guides recommend against it.
Contents |
Variations and synonyms
There are two common varieties of CamelCase, distinguished by their handling of the initial letter of what would otherwise be the first of separate words. Where the first letter is capitalized is commonly called UpperCamelCase, PascalCase, or BiCapitalized. Where the first letter is left in lowercase is commonly called lowerCamelCase. This variant has also been occasionally called dromedaryCase or camelCase. For clarity, this article will use the terms UpperCamelCase and lowerCamelCase, respectively.
camelCaseLooksLikeThis lowerCamelCaseLooksTheSame UpperCamelCaseLooksLikeThis
The term StudlyCaps is similar — but not necessarily identical — to CamelCase. It is sometimes used in reference to CamelCase but can also refer to random mixed capitalization (as in "MiXeD CaPitALiZaTioN") as popularly used in online culture.
Other synonyms include:
- BumpyCaps
- BumpyCase
- camelBase Case
- CamelCaps
- CamelHumpedWord
- CapWords in Python (reference)
- mixedCase (for lowerCamelCase) in Python (reference)
- ClCl (Capital-lower Capital-lower) and sometimes ClC
- HumpBackNotation
- InterCaps
- InternalCapitalization
- NerdCaps
- WordMixing
- WordsStrungTogether or WordsRunTogether
The name CamelCase is not related to the "Camel book" (Programming Perl), which uses all-lowercase identifiers with underscores in its sample code.
Coding standards
Internal capitalization is recommended or enforced by many computer systems, and mandated by the coding standards of many programming languages — such as Mesa, the systems programming language of the Xerox Alto (late 1970s), or the modern language Java. It is also the official convention for file names in Java and of the Amiga personal computers.
Coding standards often distinguish between UpperCamelCase and lowerCamelCase, typically specifying which variety should be used for specific kinds of entities: variables, record fields, methods, procedures, types, etc..
For instance, the Java coding style dictates that UpperCamelCase be used for classes, and lowerCamelCase be used for instances and members. The original Hungarian notation for programming specifies that a lowercase abbreviation for the "usage type" (not data type) should be prefixed on all variable names, with the remainder of the name in UpperCamelCase; as such it is a form of lowerCamelCase.
NIEM standards require that XML Data Elements use UpperCamelCase and XML Attributes use lowerCamelCase.
Some wikis, especially the earlier ones, use CamelCase to mark words that should be automatically linked. In many modern wikis (such Wikipedia and other MediaWiki-based wikis) this convention was abandoned in favor of explicit link markup, e.g. with [[…]].
History
Early uses
CamelCase has been sporadically used since ancient times, for example as a traditional spelling style for certain surnames, such as in Scottish names like McLean ("son of Gilian") and Hiberno-Norman names like FitzGerald (originally, "son of Gerald"), or the French duPont or DuPont ("of/from the bridge"). In the early 20th century, it was used occasionally for trademarking corporations and products, such as the CinemaScope movie projection system introduced in the 1950s. CamelCase also occurred sometimes in acronyms like DoD, or technical codes and formulas like HeLa (1983).
CamelCase has been used in languages other than English for a variety or purposes, such as the transcription of Tibetan names like rLobsang, or names of Bantu languages like kiSwahili or isiZulu. In French, abbreviations such as OuLiPo (1960) were favored for a time as alternatives to acronyms.
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 various possible origins, and it may have developed independently from multiple sources. Two of these theories are exposed below.
Background: multi-word identifiers
In programs of any significant size, there is a need for descriptive (hence multi-word) identifiers, like "previous balance" or "end of file". Writing the words together as in "endoffile" is not satisfactory because the names often become unreadable. Therefore, the pioneer programming language COBOL allowed a hyphen ("-") to be used between words of compound identifiers, as in "END-OF-FILE". The contemporary "algebraic" language Fortran reserved the hyphen as the minus operator, but allowed spaces to be arbitrarily embedded into identifiers, so that "TOTAMP" could be written "TOT AMP" (or "TO TAMP"). (This feature was of little use, however, because most Fortran compilers did not allow identifiers longer than six letters.)
The common punched card character sets of the time had no lower-case letters and no special character that would be adequate as a word separator in identifiers. However, by the late 1960s the ASCII character set standard had been established, allowing the designers of the C language to adopt the underscore character "_" as a word joiner. Underscore-separated compounds like "end_of_file" are still prevalent in C programs and libraries.
The "Lazy Programmer" origin
One explanation of 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.
On most keyboards, the underscore key is inconveniently placed. Additionally, in some fonts the underscore character can be confused with a minus sign; it can be overlooked because it falls below the string of characters, or it can be lost entirely when displayed or printed underlined, or when printed on a dot-matrix printer with a defective pin or misaligned ribbon. Moreover, compiler limits on identifier length and the small computer displays available in the 1970s worked together to encourage brevity. So many programmers chose to use CamelCase instead, because it yielded legible compound names with fewer keystrokes and fewer characters. Hungarian Notation is an extension of this style.
The "Alto Keyboard" origin
Another explanation is that CamelCase started 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 CamelCase as the only viable scheme for readable multiword names. The PARC Mesa Language Manual (1979) included a coding standard with specific rules for Upper- and lowerCamelCase which was strictly followed by the Mesa libraries and the Alto operating system.
The Smalltalk language, which was developed originally on the Alto and became quite popular in the early 1980s, may have been instrumental in spreading the style outside PARC. CamelCase was also used in the PostScript graphics language, another very popular PARC invention. Further boost was provided by Niklaus Wirth — the inventor of Pascal — who acquired a taste for CamelCase during a sabbatical at PARC, and used it in Modula, his next programming language.
Spread to mainstream usage
During the same period in which personal computers exposed hacker culture to a more mainstream audience in the 1980s and 1990s, CamelCase became fashionable for corporate trade names, first in computer-related fields but later expanding further into the mainstream. During the dot-com boom of in the late 1990s, in particular, the lowercase prefixes "e" (for "electronic") and "i" (for "Internet", "information", or perhaps "intelligent") became quite common. Here are some examples ranging from the 1960s to the 2000s, sorted by year:
- ShopKo (1962)
- AstroTurf (1967)
- CompuServe (1969)
- ConAgra (1971) (formerly Consolidated Mills)
- MicroSoft (now Microsoft) (1975)
- VisiCalc (1979)
- EchoStar (1980)
- WordPerfect (1982)
- NetWare (1983)
- BellSouth (1984)
- MacWorks (1984)
- PageMaker (1985)
- ClarisWorks (1987)
- HarperCollins (1990)
- QuickTime (1991)
- SuperAmerica (1991)
- OutKast hip hop band (1992)
- ThinkPad (1992)
- EarthLink (1994)
- PlayStation (1994)
- easyJet (1995)
- FrontPage (1995)
- eBay (spelled "ebaY" in their logo) (1995)
- WorldCom (now MCI) (1995)
- InuYasha (1996), although the CamelCase version didn't emerge until the English translation
- RadioShack (formerly Radio Shack) (1996)
- TiVo (1997)
- AppleWorks (1997)
- VisiBroker (1997)
- DaimlerChrysler (1998)
- iMac (1998)
- PricewaterhouseCoopers (1998) logo
- StarCraft (1998)
- UnitedHealth (formerly United HealthCare) (1998)
- BlackBerry (1999)
- CloneCD (1999)
- ExxonMobil (1999)
- SpongeBob SquarePants (1999)
- FedEx (formerly Federal Express) (2000)
- GlaxoSmithKline (2000)
- iPod (2000)
- OpenOffice.org (2000)
- AmerisourceBergen (2001)
- ChevronTexaco (now Chevron) (2001)
- GameCube (2001)
- RuneScape (2001)
- ConocoPhillips (2002)
- OpenCola
- JPMorgan Chase & Co.
- Weekly supplements of The Guardian, such as SocietyGuardian (2005)
- NetOp (???)
- MediaWiki (2001?)
- eSyndiCat (2005)
This fashion has become so pervasive that it is often incorrectly applied to names that do not use it officially, as in TransAmerica (Transamerica), FireFox (Firefox), UseNet (Usenet), TimeWarner (Time Warner, whose new logo does appear in CamelCase fashion), GameBoy (Game Boy), MicroSoft (Microsoft) and KarmelKorn (Karmelkorn).
History of the name
The original name of the practice, used in media studies, grammars, and the Oxford English Dictionary, was "medial capitals". The fancier names such as "InterCaps", "CamelCase", and variations thereof are relatively recent, and seem more common in computer-related communities.
The earliest known occurrence of InterCaps on Usenet is in an April 1990 post to the group alt.folklore.computers by Avi Rappoport [1], with BiCapitalization appearing slightly later in a 1991 post by Eric S. Raymond to the same group [2]. The earliest use of the name "CamelCase" occurs in 1995, in a post by Newton Love. [3]. "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," said Newton, [4] "The citation above was just the first time I had used the name on USENET."
See also
References
External links
- Examples and history of CamelCase
- .NET Framework General Reference Capitalization Styles
- What's in a nAME(cq)?, by Bill Walsh, at The Slot
- The Science of Word Recognition, by Kevin Larson, Advanced Reading Technology, Microsoft Corporationca:CamelCase
da:CamelCase de:Binnenmajuskel es:CamelCase fr:CamelCase it:CamelCase nl:CamelCase ja:キャメルケース pl:CamelCase pt:CamelCase sv:CamelCase