CamelCase
CamelCase (also spelled camel case) or medial capitals is the practice of writing compound words or phrases in which the words are joined without spaces and are capitalized within the compound. The term's name comes from the uppercase "bumps" in the middle of the compound word, suggestive of the humps of a camel. An example is BackColor.
There are many other names for this practice, including BiCapitalization, InterCaps, InfixCaps, MixedCase, HumpNotation and PolyCaps. 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 its use.
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. When the first letter is capitalized, it is commonly called UpperCamelCase or PascalCase[1][2]. When the first letter is left in lowercase, it is commonly called lowerCamelCase.[citation needed] For clarity, this article will use the terms UpperCamelCase and lowerCamelCase, respectively.
camelCaseLooksLikeThis lowerCamelCaseLooksTheSame UpperCamelCaseLooksLikeThis
Other synonyms include:
- BumpyCaps[3]
- BumpyCase
- CamelCaps
- CamelHumpedWord
- CapWords in Python [4]
- CoolCaps
- mixedCase (for lowerCamelCase) in Python [4]
- ClCl (Capital-lower Capital-lower) and sometimes ClC
- HumpBackNotation
- InterCaps
- InternalCapitalization
- Multicapitalization
- NerdCaps[3]
- WordCase
- WordMixing
- WordsStrungTogether or WordsRunTogether
Similar terms
The term StudlyCaps is similar — but not necessarily identical — to CamelCase.[3] It is sometimes used in reference to CamelCase but can also refer to random mixed capitalisation (as in "MiXeD CaPitALiSaTioN") as popularly used in online culture.
The term Title Case is also similar, but Title Case has spaces between the words. Title Case also doesn't usually uppercase certain small words such as 'and' and 'the'.[5][6][7]
History
Early uses
CamelCase has been sporadically used in English since ancient times, for example as a traditional spelling style for certain surnames, such as in Scottish MacLean (originally, "son of Gilian") and Hiberno-Norman FitzGerald ("son of Gerald"). This same convention is sometimes used in English for surnames of foreign origin which include prepositions or other particles, e.g. DuPont (from French Dupont or du Pont), DiCaprio (from Italian Di Caprio), and VanDyke (from Dutch Van Dijk).
In the mid-20th century, it was used occasionally for corporate names and product trademarks, such as
- CinemaScope and VistaVision, rival widescreen movie formats (1953)
- ShopKo (1962)
- MisteRogers, the Canadian version of Mister Rogers' Neighborhood (1962) [8]
- AstroTurf (1967)
- ConAgra, formerly Consolidated Mills (1971).
CamelCase has also been used for acronyms like DoD, chemical formulas like NaCl (early 19th century [9]), and other technical codes like HeLa (1983).
Origins of use in computing
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. The origin of this convention has not yet been settled.
Background: multi-word identifiers
CamelCase was adopted by programmers to write descriptive (hence multi-word) identifiers, like "previous balance" or "end of file", which are necessary to make large programs readable. In most programming languages, spaces are not typically permitted inside identifiers, as they are treated as delimiters between tokens. Writing the words together as in "endoffile" was not a satisfactory alternative because such identifiers often become unreadable.
Some early programming languages, notably Lisp (1958) and COBOL (1959), addressed this problem by allowing a hyphen ("-") to be used between words of compound identifiers, as in "END-OF-FILE". However, this solution was not adequate for algebraic-oriented languages like FORTRAN (1955) and ALGOL (1958), which needed the hyphen as a subtraction operator. Since the common punched card character sets of the time had no lower-case letters and no other special character that would be adequate for the purpose, those languages had to do without multi-word identifiers.
It was only in the late 1960s that the widespread adoption of the ASCII character set made both lower case and the underscore character "_" universally available. Some languages, notably C, promptly adopted underscores as word separators; and underscore-separated compounds like "end_of_file" are still prevalent in C programs and libraries. Yet, some languages and programmers chose to avoid underscores and adopted CamelCase instead. Two accounts are commonly given for the origin of this convention.
The "Lazy Programmer" theory
One theory for the origin of the CamelCase convention holds that C programmers and hackers simply found it more convenient than the standard underscore-based style.
Indeed, the underscore key is inconveniently placed in most keyboards. 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, early compilers severely restricted the length of identifiers (e.g., to 8 or 14 letters), or silently truncated all identifiers to that length. Finally, the small size of computer displays available in the 1970s encouraged the use of short identifiers. It was for these reasons, some claim, that many C programmers opted to use CamelCase instead of underscores, for it yielded legible compound names with fewer keystrokes and fewer characters.
The "Alto Keyboard" theory
Another account claims that the CamelCase 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 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 by convention for many names in the PostScript page description language (invented by Adobe Systems founder and ex-PARC scientist John Warnock). 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
Whatever its origins within the computing world, Camelcase spread to a wider audience in the 1980s and 1990s, when the advent of the personal computer exposed hacker culture to the world. CamelCase then became fashionable for corporate trade names, first in computer-related fields but later expanding further into the mainstream. Examples ranging from the 1960s to the 2000s give a history of the spread of the usage:
- (1975) MicroSoft (now Microsoft)
- (1977) CompuServe, UnitedHealthCare (now UnitedHealthcare,[10] with several other variations of capitalization and spacing over the years)
- (1979) MasterCard, SportsCenter, VisiCalc
- (1980) EchoStar
- (1982) WordPerfect
- (1983) NetWare
- (1984) BellSouth, LaserJet, MacWorks, iDEN
- (1985) PageMaker, EastEnders
- (1986) SpaceCamp
- (1987) ClarisWorks, HyperCard, PowerPoint
- (1989) MicroStrategy
- (1990) HarperCollins
- (1991) QuickTime, PowerBook, SuperAmerica
- (1992) OutKast (hip hop band), ThinkPad
- (1993) AmeriCorps, EcoPark, ValuJet (now AirTran Airways), SolidWorks
- (1994) EarthLink, PlayStation, easyJet (an early use of CamelCase with lowercase first letter)
- (1995) RealPlayer, WorldCom (now MCI)
- (1996) RadioShack (formerly Radio Shack)
- (1997) TiVo
- (1998) DaimlerChrysler, PricewaterhouseCoopers[11], iMac, StarCraft
- (1999) BlackBerry, DragonForce (British Power Metal band, originally DragonHeart), SpongeBob SquarePants, jetBlue (officially JetBlue Airways, however jetBlue is used in wordmark)
- (2000) FedEx (formerly Federal Express), GlaxoSmithKline, PayPal
- (2001) AmerisourceBergen, ChevronTexaco (now Chevron), GameCube
- (2002) ConocoPhillips
- (2003) MySpace
- (2005) YouTube, PetSmart (formerly PETsMART)
- (2006) PowerShell
- (2007) SourceLead[12]
This fashion has become so pervasive that it is often incorrectly applied to names that do not use it officially (hypercorrection), as in TransAmerica (Transamerica), FireFox (Firefox), UseNet (Usenet), GameBoy (Game Boy), MacWorld (Macworld), and CalTech (Caltech).
The city of SeaTac, Washington is the first city officially spelled in CamelCase. During the dot-com bubble of the late 1990s, the lowercase prefixes "e" (for "electronic") and "i" (for "Internet", "information", or perhaps "intelligent") became quite common, giving rise to some CamelCase names.
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 the term InterCaps on Usenet is in an April 1990 post to the group alt.folklore.computers by [2], with BiCapitalization appearing slightly later in a 1991 post by Eric S. Raymond to the same group.[13] The earliest use of the name "CamelCase" occurs in 1995, in a post by .[14]. "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, "The citation above was just the first time I had used the name on USENET."[15]
The name CamelCase is not related to the "Camel book" (Programming Perl), which uses all-lowercase identifiers with underscores in its sample code.
Current usage in computing
Programming and coding style
Internal capitalization is sometimes recommended by the coding style guidelines written for source code (e.g., the Mesa programming language and the Java programming language). The recommendations contained in some of these guidelines are supported by static analysis tools that check source code for adherence.
These recommendations 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.
One widely used Java coding style dictates that UpperCamelCase be used for classes, and lowerCamelCase be used for instances and methods.[16] Recognising this usage, some IDEs, such as Eclipse, implement shortcuts based on CamelCase. For instance, in Eclipse's Content assist feature, typing just the upper-case letters of a CamelCase word will suggest any matching class or method name (for example, typing "NPE" and activating content assist could suggest "NullPointerException").
The original Hungarian notation for programming specifies that a lowercase abbreviation for the "usage type" (not data type) should prefix all variable names, with the remainder of the name in UpperCamelCase; as such it is a form of lowerCamelCase. CamelCase is the official convention for file names in Java and for the Amiga personal computer.
Microsoft .NET recommends CamelCase.[17]
The NIEM registry requires that XML Data Elements use UpperCamelCase and XML Attributes use lowerCamelCase.
CamelCase is by no means universal in computing. Users of several modern programming languages, notably those in the Lisp and Forth families, nearly always use hyphens. Among the reasons sometimes given are that doing so does not require shifting on most keyboards, and that the words are more readable when they are separated.
Wiki linking
Ward Cunningham's original wiki software used CamelCase to identify links to other wiki pages. This convention is still used by some wikis, such as JSPWiki. However, among more recent wikis --- including Wikipedia and other MediaWiki-based sites --- this convention is losing ground to explicit link markup (e.g. with [[…]]).
Current usage in natural languages
CamelCase has been used in languages other than English for a variety of purposes, including the ones below:
Orthographic markings
Camel case is sometimes used in the transcription of certain scripts, to differentiate letters or markings. An example is the rendering of Tibetan proper names like rLobsang: the "r" here stands for a prefix glyph in the original script that functions as tone marker rather than a normal letter.
Inflection prefixes
Camel case may also be used when writing proper names in languages that inflect words by attaching prefixes to them. In some of those languages, the custom is to leave the prefix in lower case, and capitalize the root.
This convention is used in Irish orthography; e.g. i nGaillimh ("in Galway"), from Gaillimh ("Galway"); an tAlbanach ("the Scottish person"), from Albanach ("Scottish person"); go hÉireann ("to Ireland"), from Éire ("Ireland).
Several Bantu languages also use this convention, e.g. kiSwahili ("Swahili language" in Swahili) and isiZulu ("Zulu language" in Zulu).
Abbreviations and acronyms
In French, abbreviations such as OuLiPo (1960) were favored for a time as alternatives to acronyms.
CamelCase is often used to transliterate acronyms from alphabets where two letters may be required to represent a single character of the original alphabet, e.g. DShK from Cyrillic ДШК.
Honorifics within compound words
In several languages, including English, pronouns and possessives may be capitalized to indicate respect, e.g. when referring to the reader of a formal letter or to God. In some of those languages, the capitalization is customarily retained even when those words occur within compound words or suffixed to a verb. For example, in Italian one would write porgiamoLe distinti saluti ("we offer to You respectful salutations") or adorarLo ("adore Him").
Other uses
In the German language, nouns carry a grammatical gender, which as for words indicating the role of someone, like job titles, is mostly masculine. The feminine title suffixes In () and Innen (plural), with a capital 'I', have since the 80s been used by some writers and publishers to emphasize the inclusion of females. Example: LeserInnenbriefe ("letters from readers, [male or] Female") instead of Leserbriefe ("letters from readers").
See also
References
- ^ http://c2.com/cgi/wiki?PascalCase
- ^ http://blogs.msdn.com/brada/archive/2004/02/03/67024.aspx
- ^ a b c Brian Hayes, "The Semicolon Wars," American Scientist Online: The Magazine of Sigma XI, the Scientific Research Society July-August 2006, art. pg. 2. [1]
- ^ a b http://www.python.org/peps/pep-0008.html
- ^ http://www.sitepoint.com/blogs/2005/03/15/title-case-in-php/
- ^ http://wordtips.vitalnews.com/Pages/T1685_Intelligent_Title_Case.html
- ^ http://bloggingabout.net/blogs/jschreuder/archive/2006/11/14/How-to_3A00_-Change-casing-in-Text-to-TitleCase.aspx
- ^ http://imdb.com/title/tt0250165/
- ^ Jöns Jacob Berzelius. Essay on the Cause of Chemical Proportions, and on Some Circumstances Relating to Them: Together with a Short and Easy Method of Expressing Them. Annals of Philosophy 2, 443-454 (1813), 3, 51-2, 93-106, 244-255, 353-364 (1814) from Henry M. Leicester & Herbert S. Klickstein, eds., A Source Book in Chemistry, 1400-1900 (Cambridge, MA: Harvard, 1952)
- ^ http://www.uhc.com
- ^ http://www.pwcglobal.com/images/topnav/pwc.gif
- ^ http://www.sourcelead.com
- ^ http://groups.google.com/groups?selm=1ZJ7Y0%233w7TXB3X6xdT7Fp8Dg1SnxYw%3Deric%40snark.thyrsus.com&output=gplain
- ^ http://groups.google.com/groups?selm=newton.212.30563F09%40michelob.wustl.edu&output=gplain
- ^ http://sluug.org/~newt/
- ^ http://java.sun.com/docs/codeconv/html/CodeConventions.doc8.html#367
- ^ http://msdn2.microsoft.com/en-us/library/x2dbyw72(VS.71).aspx
External links
- Examples and history of CamelCase, also WordsSmashedTogetherLikeSo
- .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 Corporation
- evolution of underscores in C++