Advertisement

CamelCase

From Academic Kids

CamelCase 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.

   camelCaseLooksLikeThis
   lowerCamelCaseLooksTheSame
   UpperCamelCaseLooksLikeThis

CamelCase is a standard identifier naming convention for several programming languages, and has become fashionable in marketing for names of products and companies. Outside of 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. The variety in which the first letter is capitalized is commonly called UpperCamelCase, Pascal case, or BiCapitalized. The variety in which the first letter is left as lowercase is commonly called lowerCamelCase or sometimes simply camelCase. For clarity, this article will use the terms UpperCamelCase and lowerCamelCase, respectively.

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 minority online culture.

Other synonyms include:

  • BumpyCaps
  • BumpyCase
  • camelBase Case
  • CamelCaps
  • CamelHumpedWord
  • CapWords in Python (reference) (http://www.python.org/peps/pep-0008.html)
  • mixedCase (for lowerCamelCase) in Python (reference) (http://www.python.org/peps/pep-0008.html)
  • ClCl (Capital-lower Capital-lower) and sometimes ClC
  • HumpBackNotation
  • InterCaps
  • InternalCapitalization
  • NerdCaps
  • WordsStrungTogether or WordsRunTogether
  • WikiWord
  • WikiName

CamelCase and coding standards

CamelCase 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 should be used for classes, and lowerCamelCase should be used for instances and members. The Hungarian notation for programming specifies that a lowercase abbreviation for the variable type should be prefixed on all variable names, with the remainder of the name in UpperCamelCase; as such it is a form of lowerCamelCase.

History of CamelCase

CamelCase has been sporadically used since ancient times, for example as a traditional spelling style for surnames in certain ethnicities, such as the Scottish McLean or the Dutch-American deJong or DeJong. 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.

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.

Background for modern CamelCase

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"). However, this feature was of little use because most Fortran compilers did not allow identifiers longer than six letters.

It should be noted that 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.

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 lower CamelCase 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.

History of the name

The style had no definite name initially. The earliest occurrence of InterCaps on Usenet is in an April 1990 post to the group alt.folklore.computers by Avi Rappoport [1] (http://groups-beta.google.com/group/alt.folklore.computers/msg/21f332e5b813313e), with BiCapitalization appearing slightly later in a 1991 post by Eric S. Raymond to the same group [2] (http://groups.google.com/groups?selm=1ZJ7Y0%233w7TXB3X6xdT7Fp8Dg1SnxYw%3Deric%40snark.thyrsus.com&output=gplain). The name "CamelCase" occurs only in 1995, in a post by Newton Love. [3] (http://groups.google.com/groups?selm=newton.212.30563F09%40michelob.wustl.edu&output=gplain).

The spread of CamelCase

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. Here are some examples ranging from the 1970s to the 2000s:

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), and GameBoy (Game Boy).

See also

References

External links

da:WikiOrd de:CamelCase es:CamelCase fr:CamelCase nl:CamelCase pl:CamelCase sv:CamelCase

Navigation

Academic Kids Menu

  • Art and Cultures
    • Art (http://www.academickids.com/encyclopedia/index.php/Art)
    • Architecture (http://www.academickids.com/encyclopedia/index.php/Architecture)
    • Cultures (http://www.academickids.com/encyclopedia/index.php/Cultures)
    • Music (http://www.academickids.com/encyclopedia/index.php/Music)
    • Musical Instruments (http://academickids.com/encyclopedia/index.php/List_of_musical_instruments)
  • Biographies (http://www.academickids.com/encyclopedia/index.php/Biographies)
  • Clipart (http://www.academickids.com/encyclopedia/index.php/Clipart)
  • Geography (http://www.academickids.com/encyclopedia/index.php/Geography)
    • Countries of the World (http://www.academickids.com/encyclopedia/index.php/Countries)
    • Maps (http://www.academickids.com/encyclopedia/index.php/Maps)
    • Flags (http://www.academickids.com/encyclopedia/index.php/Flags)
    • Continents (http://www.academickids.com/encyclopedia/index.php/Continents)
  • History (http://www.academickids.com/encyclopedia/index.php/History)
    • Ancient Civilizations (http://www.academickids.com/encyclopedia/index.php/Ancient_Civilizations)
    • Industrial Revolution (http://www.academickids.com/encyclopedia/index.php/Industrial_Revolution)
    • Middle Ages (http://www.academickids.com/encyclopedia/index.php/Middle_Ages)
    • Prehistory (http://www.academickids.com/encyclopedia/index.php/Prehistory)
    • Renaissance (http://www.academickids.com/encyclopedia/index.php/Renaissance)
    • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
    • United States (http://www.academickids.com/encyclopedia/index.php/United_States)
    • Wars (http://www.academickids.com/encyclopedia/index.php/Wars)
    • World History (http://www.academickids.com/encyclopedia/index.php/History_of_the_world)
  • Human Body (http://www.academickids.com/encyclopedia/index.php/Human_Body)
  • Mathematics (http://www.academickids.com/encyclopedia/index.php/Mathematics)
  • Reference (http://www.academickids.com/encyclopedia/index.php/Reference)
  • Science (http://www.academickids.com/encyclopedia/index.php/Science)
    • Animals (http://www.academickids.com/encyclopedia/index.php/Animals)
    • Aviation (http://www.academickids.com/encyclopedia/index.php/Aviation)
    • Dinosaurs (http://www.academickids.com/encyclopedia/index.php/Dinosaurs)
    • Earth (http://www.academickids.com/encyclopedia/index.php/Earth)
    • Inventions (http://www.academickids.com/encyclopedia/index.php/Inventions)
    • Physical Science (http://www.academickids.com/encyclopedia/index.php/Physical_Science)
    • Plants (http://www.academickids.com/encyclopedia/index.php/Plants)
    • Scientists (http://www.academickids.com/encyclopedia/index.php/Scientists)
  • Social Studies (http://www.academickids.com/encyclopedia/index.php/Social_Studies)
    • Anthropology (http://www.academickids.com/encyclopedia/index.php/Anthropology)
    • Economics (http://www.academickids.com/encyclopedia/index.php/Economics)
    • Government (http://www.academickids.com/encyclopedia/index.php/Government)
    • Religion (http://www.academickids.com/encyclopedia/index.php/Religion)
    • Holidays (http://www.academickids.com/encyclopedia/index.php/Holidays)
  • Space and Astronomy
    • Solar System (http://www.academickids.com/encyclopedia/index.php/Solar_System)
    • Planets (http://www.academickids.com/encyclopedia/index.php/Planets)
  • Sports (http://www.academickids.com/encyclopedia/index.php/Sports)
  • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
  • Weather (http://www.academickids.com/encyclopedia/index.php/Weather)
  • US States (http://www.academickids.com/encyclopedia/index.php/US_States)

Information

  • Home Page (http://academickids.com/encyclopedia/index.php)
  • Contact Us (http://www.academickids.com/encyclopedia/index.php/Contactus)

  • Clip Art (http://classroomclipart.com)
Toolbox
Personal tools