Recent from talks
Nothing was collected or created yet.
Camel case
View on Wikipedia

The writing format camel case (sometimes stylized autologically as camelCase or CamelCase, also known as camel caps or more formally as medial capitals) is the practice of writing phrases without spaces or punctuation and with capitalized words. The format indicates the first word starting with either case, then the following words having an initial uppercase letter. Common examples include YouTube,[1] PowerPoint, HarperCollins, FedEx, iPhone, eBay,[2] and LaGuardia.[3] Camel case is often used as a naming convention in computer programming. It is also sometimes used in online usernames such as JohnSmith, and to make multi-word domain names more legible, for example in promoting EasyWidgetCompany.com.
The more specific terms Pascal case and upper camel case refer to a joined phrase where the first letter of each word is capitalized, including the initial letter of the first word. Similarly, lower camel case (also known as dromedary case) requires an initial lowercase letter. Some people and organizations, notably Microsoft, use the term camel case only for lower camel case, designating Pascal case for the upper camel case.[4] Some programming styles prefer camel case with the first letter capitalized, others not.[5][4][6] For clarity, this article leaves the definition of camel case ambiguous with respect to capitalization of the first word, and uses the more specific terms when necessary.
Camel case is distinct from several other styles: title case, which capitalizes all words but retains the spaces between them; Tall Man lettering, which uses capitals to emphasize the differences between similar-looking product names such as predniSONE and predniSOLONE; and snake case, which uses underscores interspersed with lowercase letters (sometimes with the first letter capitalized). A combination of snake and camel case (identifiers Written_Like_This) is recommended in the Ada 95 style guide.[7]
Variations and synonyms
[edit]The practice has various names, including:
- camelBack (or camel-back) notation[8] or CamelCaps[9]
- camel case or CamelCase
- CapitalizedWords or CapWords for upper camel case in Python[10]
- compoundNames[11]
- Embedded caps (or embedded capitals)[12]
- HumpBack (or hump-back) notation[13]
- InterCaps or intercapping[14] (abbreviation of Internal Capitalization[15])
- medial capitals, recommended by the Oxford English Dictionary[16]
- mixedCase for lower camel case in Python[10]
- PascalCase for upper camel case[17][18][19] (after the Pascal programming language)
- Smalltalk case
- WikiWord[20] or WikiCase[21] (especially in older wikis)
History
[edit]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.[22] The earliest use of the name "Camel Case" occurs in 1995, in a post by Newton Love.[23] 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."[24] The term "Pascal Case" was coined in design discussions for the .NET Framework, first released in 2002.[25]
Traditional use in natural language
[edit]In word combinations
[edit]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 ("I have not found time to answer you" – where Le means "to you").
In German, many nouns denoting people lack a gender-neutral form, which is why often, especially colloquially, the male form of a noun is used generically to address everyone, regardless of their gender (this is called generisches Maskulinum in German). Another, more recent approach is using the medial capital letter I, called Binnen-I, in written text for words like StudentInnen ("students") to indicate that both Studenten ("male students") and Studentinnen ("female students") are referred to simultaneously. However, mid-word capitalization does not conform to the German orthography prescribed by the Rat für deutsche Rechtschreibung (Council for German Orthography) apart from proper names like McDonald. In order to adhere to orthography, the introductory “students” example could be corrected using parentheses to Student(inn)en, which is analogous to writing "congress(wo)men" in English.[26]
In Irish, camel case is used when an inflectional prefix is attached to a proper noun, for example i nGaillimh ("in Galway"), from Gaillimh ("Galway"); an tAlbanach ("the Scottish person"), from Albanach ("Scottish person"); and go hÉirinn ("to Ireland"), from Éire ("Ireland"). In recent Scottish Gaelic orthography, a hyphen has been inserted: an t-Albannach.
This convention of inflectional prefix is also used by several written Bantu languages (e.g. isiZulu, "Zulu language") and several indigenous languages of Mexico (e.g. Nahuatl, Totonacan, Mixe–Zoque, and some Oto-Manguean languages).
In Dutch, when capitalizing the digraph ij, both the letter I and the letter J are capitalized, for example in the country name IJsland ("Iceland").
In Chinese pinyin, camel case is sometimes used for place names so that readers can more easily pick out the different parts of the name. For example, places like Beijing (北京), Qinhuangdao (秦皇岛), and Daxing'anling (大兴安岭) can be written as BeiJing, QinHuangDao, and DaXingAnLing respectively, with the number of capital letters equaling the number of Chinese characters. Writing word compounds only by the initial letter of each character is also acceptable in some cases, so Beijing can be written as BJ, Qinghuangdao as QHD, and Daxing'anling as DXAL.
In English, medial capitals are usually only found in Scottish or Irish "Mac-" or "Mc-" patronymic names, where for example MacDonald, McDonald, and Macdonald are common spelling variants of MacDonald (son of Dòmhnall), and in Anglo-Norman "Fitz-" names, where for example both FitzGerald and Fitzgerald (son of Gerald) 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 (as against King Mark-like) and Anglo-SouthAmerican (as against Anglo-South American). However, they described the system as "too hopelessly contrary to use at present".[27]
Some French names also uses CamelCase names, such as LeBeau (surname), LaRue, DeMordaunt, and Italian names DeRose/DeRosa.
In transliterations
[edit]In the scholarly transliteration of languages written in other scripts, medial capitals are used in similar situations. For example, in transliterated Hebrew, haIvri 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 Chechnya and Ingushetia; the letter "I" (palochka) is not actually capital, denoting a phoneme distinct from the one transcribed as "i".
In abbreviations
[edit]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. A more recent example is NaNoWriMo, a contraction of National Novel Writing Month and the designation for both the annual event and the nonprofit organization that runs it. In German, the names of statutes are abbreviated using embedded capitals, e.g. StGB for Strafgesetzbuch (Criminal Code), PatG for Patentgesetz (Patent Act), BVerfG for Bundesverfassungsgericht (Federal Constitutional Court), or the very common GmbH, for Gesellschaft mit beschränkter Haftung (private limited company). In this context, there can even be three or more camel case capitals, e.g. in TzBfG for Teilzeit- und Befristungsgesetz (Act on Part-Time and Limited Term Occupations). In French, camel case acronyms such as OuLiPo (1960) 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
[edit]Chemical formulas
[edit]The first systematic and widespread use of medial capitals for technical purposes was the notation for chemical formulas 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 formulas like "NaCl" to be written without spaces and still be parsed without ambiguity.[28][29]
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 (especially in the field of organic chemistry, for instance "Et" for "ethyl-"). This has been further extended to describe the amino acid sequences of proteins and other similar domains.
Early use in trademarks
[edit]Since the early 20th century, medial capitals have occasionally been used for corporate names and product trademarks, such as
- DryIce Corporation (1925) marketed the solid form of carbon dioxide (CO2) as "Dry Ice", thus leading to its common name.[30]
- CinemaScope and VistaVision, rival widescreen movie formats (1953)
- ShopKo (1962), retail stores, later renamed Shopko
- MisteRogers Neighborhood, the TV series also called Mister Rogers' Neighborhood (1968)[31]
- ChemGrass (1965), later renamed AstroTurf (1967)
- ConAgra (1971), formerly Consolidated Mills
- MasterCraft (1968), a sports boat manufacturer
- AeroVironment (1971)
- PolyGram (1972), formerly Grammophon-Philips Group
- United HealthCare (1977)[32]
- MasterCard (1979), formerly Master Charge
- SportsCenter (1979)
Computer programming
[edit]This section possibly contains original research. (May 2011) |
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[33] occasionally informally referred to IBM's Speedcoding system as "SpeedCo". Christopher Strachey's paper on GPM (1965),[34] shows a program that includes some medial capital identifiers, including "NextCh" and "WriteSymbol" (This was most likely the influence of the CPL language, of which Strachey was one of the designers)
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 (able to be charted), whereas charTable means a table of chars .
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": Lisp because it worked well with prefix notation (a Lisp parser would not treat a hyphen in the middle of a symbol as a subtraction operator) 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 (1955) and ALGOL (1958), 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 (as well as in later languages influenced by C, such as Perl and Python). However, some languages and programmers chose to avoid underscores 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(s) at the start of a (capitalized) variable name to denote its type. One account[citation needed] 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 (whose place was taken by a left arrow "←"), 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 (1979) 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.[35]
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 (or "Pascal 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.
C# variable names are recommended to follow the lower camel case convention.[36]
Computer companies and products
[edit]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:
- (1977) CompuServe
- (1978) WordStar
- (1979) VisiCalc
- (1982) MicroProse, WordPerfect
- (1983) NetWare
- (1984) LaserJet, MacWorks, PostScript
- (1985) PageMaker
- (1987) ClarisWorks, HyperCard, PowerPoint
- (1990) WorldWideWeb (the first web browser), later renamed Nexus
Spread to mainstream usage
[edit]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:
- (1980) EchoStar
- (1984) BellSouth
- (1985) EastEnders
- (1986) SpaceCamp
- (1990) HarperCollins, SeaTac
- (1998) PricewaterhouseCoopers, merger of Price Waterhouse and Coopers
During the dot-com bubble of the late 1990s, the lowercase prefixes "e" (for "electronic") and "i" (for "Internet",[37] "information", "intelligent", etc.) 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.[38] This usage was not widely adopted.
Camel case is sometimes used for abbreviated names of certain neighborhoods, e.g. New York City neighborhoods SoHo (South of Houston Street) and TriBeCa (Triangle Below Canal Street) and San Francisco's SoMa (South of Market). 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 (1983).
Current usage in computing
[edit]Programming and coding
[edit]The use of medial caps for compound identifiers is recommended by the coding style guidelines of many organizations or software projects. For some languages (such as Mesa, Pascal, Modula, Java and Microsoft's .NET) 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" (not data 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 (e.g., "parse DBM XML" would become "parseDBMXML") or when the standard mandates lower camel case but the name begins with an abbreviation (e.g. "SQL server" would become "sQLServer"). For this reason, some programmers prefer to treat abbreviations as if they were words and write "oldHtmlFile", "parseDbmXml" or "sqlServer".[39] However, this can make it harder to recognize that a given word is intended as an acronym.[40]
Difficulties arise when identifiers have different meaning depending only on the case, as can occur with mathematical functions or trademarks. In this situation changing the case of an identifier might not be an option and an alternative name need be chosen.
Wiki link markup
[edit]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,[41] 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[42] and many other wiki sites have done the same. MediaWiki, for example, does not support camel case for linking. Some wikis that do not use camel case linking may still use the camel case as a naming convention, such as AboutUs.
Other uses
[edit]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 (usually requiring the name to be put in quotes). Therefore, users of those systems often resort to camel case (or underscores, hyphens and other "safe" characters) for compound file names like MyJobResume.pdf.
Social media accessibility
[edit]Microblogging and social networking services 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 camelCase or PascalCase to maintain readability (e.g. #collegeStudentProblems is easier to read than #collegestudentproblems);[43] this practice improves accessibility as screen readers recognize camelCase and PascalCase in parsing composite hashtags.[44]
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
[edit]Camel case has been criticized as negatively impacting readability due to the removal of spaces and uppercasing of every word.[45]
A 2009 study of 135 subjects comparing snake case (underscored identifiers) to camel case found that camel case identifiers were recognized with higher accuracy among all subjects. Subjects recognized snake case identifiers more quickly than camel case identifiers. Training in camel case sped up camel case recognition and slowed snake case recognition, although this effect involved coefficients with high p-values. The study also conducted a subjective survey and found that non-programmers either preferred underscores or had no preference, and 38% of programmers trained in camel case stated a preference for underscores. However, these preferences had no statistical correlation to accuracy or speed when controlling for other variables.[46]
A 2010 follow-up study used a similar study design with 15 subjects consisting of expert programmers trained primarily in snake case. It used a static rather than animated stimulus and found perfect accuracy in both styles except for one incorrect camel case response. Subjects recognized identifiers in snake case more quickly than camel case. The study used eye-tracking equipment and found that the difference in speed for its subjects was primarily due to the fact that average duration of fixations for camel-case was significantly higher than that of snake case for 3-part identifiers. The survey recorded a mixture of preferred identifier styles but again there was no correlation of preferred style to accuracy or speed.[47]
See also
[edit]References
[edit]- ^ Fogarty, Mignon (27 October 2009). The Grammar Devotional: Daily Tips for Successful Writing from Grammar Girl. St. Martin's Publishing Group. p. 14. ISBN 978-1-4299-6440-1.
- ^ Brown, Adam (21 September 2018). Understanding and Teaching English Spelling: A Strategic Guide. Routledge. pp. 173–174. ISBN 978-1-351-62186-1.
- ^ Dreyer, Benjamin (4 August 2020). Dreyer's English: An Utterly Correct Guide to Clarity and Style. Random House Publishing Group. p. 228. ISBN 978-0-8129-8571-9.
- ^ a b "Capitalization Styles - .NET Framework 1.1". 17 November 2006. Retrieved 5 December 2012.
- ^ "Naming Conventions". Scala. Retrieved 5 December 2012.
- ^ "Camel Case". Retrieved 10 March 2016.
- ^ "Ada 95 Quality and Style Guide". October 1995. Section 3.1.3. Retrieved 25 January 2020.
- ^ C# Coding Standards and Guidelines Archived 11 April 2008 at the Wayback Machine at Purdue University College of Technology
- ^ "CamelCase@Everything2.com". Everything2.com. Retrieved 4 June 2010.
- ^ a b Style Guide for Python Code at www.python.org
- ^ Feldman, Ian (29 March 1990). "compoundNames". Newsgroup: alt.folklore.computers. Usenet: 3230@draken.nada.kth.se.
- ^ "[#APF-1088] If class name has embedded capitals, AppGen code fails UI tests and generated hyperlinks are incorrect. – AppFuse JIRA". Issues.appfuse.org. Archived from the original on 25 June 2017. Retrieved 4 June 2010.
- ^ ASP Naming Conventions Archived 8 April 2009 at the Wayback Machine, by Nannette Thacker (05/01/1999)
- ^ Iverson, Cheryl; Christiansen, Stacy; Flanagin, Annette; Fontanarosa, Phil B.; Glass, Richard M.; Gregoline, Brenda; Lurie, Stephen J.; Meyer, Harriet S.; Winker, Margaret A.; Young, Rozanne K., eds. (2007). AMA Manual of Style (10th ed.). Oxford, Oxfordshire: Oxford University Press. ISBN 978-0-19-517633-9.
- ^ Hult, Christine A.; Huckin, Thomas N. "The Brief New Century Handbook – Rules for internal capitalization". Pearson Education. Archived from the original on 7 April 2012.
- ^ "What is the name for a word containing two capital letters (like WordPad)?". AskOxford. Internet Archive. Archived from the original on 25 October 2008. Retrieved 12 June 2022.
- ^ "Brad Abrams: History around Pascal Casing and Camel Casing". learn.microsoft.com. 3 February 2004. Retrieved 21 October 2024.
- ^ "Pascal Case". C2.com. 27 September 2012. Retrieved 4 January 2014.
- ^ "NET Framework General Reference Capitalization Styles". MSDN2. 17 November 2006. Retrieved 4 January 2014.
- ^ "WikiWord". Twiki.org. Archived from the original on 19 June 2010. Retrieved 4 June 2010.
- ^ "Wiki Case". C2.com. 8 February 2010. Retrieved 4 June 2010.
- ^ Rappoport, Avi (3 April 1990). "compoundNames". Newsgroup: alt.folklore.computers.
- ^ Newton Love (12 September 1995). "I'm happy again! – comp.os.os2.advocacy | Google Groups". Groups.google.com. Retrieved 23 May 2009.
- ^ "Newton Love". Saint Louis Unix Users Group.[dead link]
- ^ Abrams, Brad (3 February 2004). "History around Pascal Casing and Camel Casing". learn.microsoft.com. Retrieved 1 February 2025.
- ^ Richtiges und gutes Deutsch: Das Wörterbuch der sprachlichen Zweifelsfälle. Duden (in German). Vol. 9 (7th ed.). Mannheim: Bibliographisches Institut. 2011. p. 418. ISBN 978-3411040971.
- ^ Fowler, Henry W.; Fowler, Francis G. (1908). "Chapter IV. Punctuation – Hyphens". The King's English (2nd ed.). Oxford. Archived from the original on 31 December 2009. Retrieved 19 December 2009.
- ^ Jöns Jacob Berzelius (1813). 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, 3, 51-52; (1814) 93-106, 244-255, 353-364.
- ^ Henry M. Leicester & Herbert S. Klickstein, eds. 1952, A Source Book in Chemistry, 1400-1900 (Cambridge, MA: Harvard)
- ^ The Trade-mark Reporter. United States Trademark Association. 1930. ISBN 1-59888-091-8.
{{cite book}}: ISBN / Date incompatibility (help) - ^ "Mister Rogers Neighborhood Season 1 (Episode 4)". Retrieved 21 June 2022.
- ^ "Our History". unitedhealthgroup.com. Archived from the original on 1 May 2019. Retrieved 15 May 2019.
- ^ ""Resume of Session 8". Digital Computers: Advanced Coding Techniques. Summer Session 1954, Massachusetts Institute of Technology" (PDF). 1954. pp. 8–6. Archived from the original (PDF) on 29 February 2012. Retrieved 4 January 2014.
- ^ Strachey, Christopher (October 1965). "A General Purpose Macrogenerator". Computer Journal. 8 (3): 225–241. doi:10.1093/comjnl/8.3.225.
- ^ Niklaus Wirth (2007). "Modula-2 and Oberon". Proceedings of the third ACM SIGPLAN conference on History of programming languages. HOPL III - San Diego. pp. 3-1 – 3-10. CiteSeerX 10.1.1.91.1447. doi:10.1145/1238844.1238847. ISBN 9781595937667. S2CID 1918928.
- ^ wwlpublish. "Declare variables - Training". learn.microsoft.com. Retrieved 29 August 2023.
- ^ Farhad Manjoo (30 April 2002). "Grads Want to Study on EMacs, Too". Wired.com. Retrieved 4 June 2010.
- ^ Feedback, 20 June 1998 Vol 158 No 2139 New Scientist 20 June 1998
- ^ "Google Java Style Guide". google.github.io. Retrieved 2 November 2022.
- ^ Dave Binkley; Marcia Davis; Dawn Lawrie; Christopher Morrell (2009). "To CamelCase or Under_score". IEEE 17th International Conference on Program Comprehension, 2009. ICPC '09. IEEE: 158–167. CiteSeerX 10.1.1.158.9499.
In terms of camel-cased identifiers, this has a greater impact on identifiers that include short words and especially acronyms. For example, consider the acronym ID found in the identifier kIOuterIIDPath. Because of the run of uppercase letters, the task of reading kIOuterIIDPath, in particular the identification of the word ID, is more difficult.
- ^ Andrew Lih, The Wikipedia Revolution: How a Bunch of Nobodies Created the World's Greatest Encyclopedia (New York: Hyperion, 2009), pp. 57–58.
- ^ Lih, The Wikipedia Revolution, pp. 62–63, 67.
- ^ Blackwood, Jessica; Brown, Kate. "Accessible Use of CamelCase and Structuring Posts". Accessible Digital Content Training. McMaster University.
- ^ "Social Media Accessibility Guidelines". Princeton University. 2022. Archived from the original on 12 October 2022. Retrieved 12 October 2022.
- ^ Caleb Crain (23 November 2009). "Against Camel Case". New York Times.
- ^ Dave Binkley; Marcia Davis; Dawn Lawrie; Christopher Morrell (2009). "To CamelCase or Under_score". IEEE 17th International Conference on Program Comprehension, 2009. ICPC '09. IEEE: 158–167. CiteSeerX 10.1.1.158.9499.
The experiment builds on past work of others who study how readers of natural language perform such tasks. Results indicate that camel casing leads to higher accuracy among all subjects regardless of training, and those trained in camel casing are able to recognize identifiers in the camel case style faster than identifiers in the underscore style.
- ^ Bonita Sharif; Jonathan I. Maletic (2010). "An Eye Tracking Study on camelCase and under_score Identifier Styles". 2010 IEEE 18th International Conference on Program Comprehension. IEEE. pp. 196–205. CiteSeerX 10.1.1.421.6137. doi:10.1109/ICPC.2010.41. ISBN 978-1-4244-7604-6. S2CID 14170019. (download PDF).
An empirical study to determine if identifier-naming conventions (i.e., camelCase and under_score) affect code comprehension is presented. An eye tracker is used to capture quantitative data from human subjects during an experiment. The intent of this study is to replicate a previous study published at ICPC 2009 (Binkley et al.) that used a timed response test method to acquire data. The use of eye-tracking equipment gives additional insight and overcomes some limitations of traditional data gathering techniques. Similarities and differences between the two studies are discussed. One main difference is that subjects were trained mainly in the underscore style and were all programmers. While results indicate no difference in accuracy between the two styles, subjects recognize identifiers in the underscore style more quickly.
External links
[edit]- Camel Case Guide & Converter, further reading on usage with examples
- 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
- Convert text to CamelCase
- OASIS Cover Pages: CamelCase for Naming XML-Related Components Archived 10 January 2008 at the Wayback Machine
- Convert text to CamelCase, Title Case, Uppercase and lowercase
- Demystifying Common Casings in Programming: What They Are and When to Use Them
Camel case
View on GrokipediamyVariableName.[1] This style derives its name from the resemblance of the protruding capital letters to the humps on a camel's back.[2] A closely related variant, known as Pascal case or upper camel case, capitalizes the first letter of the entire compound as well, such as MyClassName.[3] Originating in early computing practices and gaining prominence in modern programming languages, camel case enhances readability in code while adhering to syntax rules that prohibit spaces in identifiers.[1] It is standard in languages like Java, JavaScript, and C# for variables, methods, and properties (lower camel case) and for classes and types (upper camel case), promoting consistency across large codebases.[4]
Definitions and Variations
Core Definition and Characteristics
Camel case, also known as lower camel case or dromedary case, is a naming convention for compound words or phrases in which individual words are joined without intervening spaces or punctuation, the initial word starts with a lowercase letter, and each following word begins with an uppercase letter.[1] This format is commonly illustrated by examples such ascamelCase and userName.[5] The style contrasts with alternatives like snake_case, which uses underscores to separate words, by relying on capitalization for word boundaries.[6]
The term "camel case" originates from the resemblance of the protruding uppercase letters to the humps on a camel's back, evoking the animal's distinctive silhouette.[5] It differs from Pascal case (or upper camel case), which capitalizes the first letter of the initial word as well, as in CamelCase.[7] This distinction arose in programming communities to specify conventions for identifiers like variables and functions.[8]
Key characteristics of camel case include its promotion of readability in space-constrained environments, such as programming language syntax where identifiers cannot contain spaces.[6] By visually segmenting words through capitalization, it reduces parsing effort and enhances code maintainability without introducing non-alphabetic separators.[9] It is widely adopted in languages like JavaScript, Java, and C# for local variables, methods, and properties, fostering consistency across codebases.[7]
Distinct Variations
Camel case, as a compound word naming convention, exhibits two primary variations distinguished by the capitalization of the initial letter. In lower camel case (also termed dromedary case or simply camelCase), the first word begins with a lowercase letter, while subsequent words commence with uppercase letters, forming a pattern such asiPhone or xmlParser.[3][10] This style is widely adopted in programming for variables, functions, and methods in languages like Java and JavaScript, where it enhances readability by visually separating words without delimiters.[4]
Conversely, upper camel case (also known as Pascal case or PascalCase) capitalizes the first letter of every word, yielding examples like CamelCase or HttpResponse.[3][11] Originating from Pascal programming language conventions, this form is prevalent for class names, types, and modules in ecosystems such as C#, .NET, and certain XML standards, as it treats the entire identifier uniformly from the outset.[10][4]
These variations diverge fundamentally in their application: lower camel case prioritizes indicating the start of a compound as subordinate or instance-level, whereas upper camel case signals a proper noun-like or declarative entity.[7] No other structural variants qualify as camel case, as alternatives like snake_case (using underscores) or kebab-case (using hyphens) introduce separators rather than relying solely on capitalization humps.[3][12]
Related Terms and Synonyms
Camel case, specifically referring to the convention where the first word begins with a lowercase letter followed by subsequent words capitalized (e.g.,iPhone), is synonymous with lower camel case.[1] This form contrasts with upper camel case, where the initial letter is also uppercase (e.g., ICalculator), a variation sometimes called Pascal case due to its adoption in the Pascal programming language.[4][7]
Additional synonyms for the broader practice of capitalizing internal word boundaries without separators include InterCaps and medial capitals, terms that describe the "humps" formed by uppercase letters amid lowercase ones.[5] Upper variants may also be termed studly case or studly caps, emphasizing irregular capitalization for readability in compound identifiers.
While not direct synonyms, closely related naming conventions include snake case (lowercase words separated by underscores, e.g., my_variable) and kebab case (lowercase with hyphens, e.g., my-variable), which serve similar word-separation purposes but differ in syntax and are prevalent in contexts like URLs or database fields.[13] These alternatives highlight camel case's position within a spectrum of identifier styles prioritizing compactness over explicit delimiters.[14]
Historical Origins
Pre-Modern Linguistic Applications
In ancient Greek and Roman writing systems, texts employed scriptio continua, a convention of continuous script without inter-word spaces or punctuation, rendered entirely in majuscule (capital) letters. This practice, evident from the 2nd century CE onward in Latin inscriptions and manuscripts, necessitated parsing word boundaries through phonetic recitation or contextual inference, as the uniform uppercase precluded internal capitalization for demarcation.[15][16] The emergence of minuscule (lowercase) scripts in the early Middle Ages, particularly Carolingian minuscule around the 8th century, provided the typographic distinction between upper and lower case essential for medial capitals. Yet, linguistic orthographies did not adopt internal uppercase letters to signal word or morpheme boundaries in compound phrases; instead, word spacing—initially introduced by Irish and English scribes in the 7th and 8th centuries for Latin liturgical texts—became the dominant method for enhancing readability in natural language prose.[15] This shift, widespread by the 13th century, prioritized spatial separation over capitalization within words, reflecting a preference for clarity in vernacular and classical compositions without the concatenated, hump-like protrusions characteristic of later camel case.[15] Pre-modern applications of medial capitals in strictly linguistic contexts remained incidental, confined largely to abbreviations reflecting expanded forms (e.g., denoting initial letters of proper nouns) rather than systematic phrase structuring. No widespread orthographic tradition in European or Mediterranean languages utilized camel case equivalents for everyday writing, as the availability of spaces rendered such conventions unnecessary for semantic disambiguation.Early Scientific and Technical Uses
The first systematic employment of medial capitals—a stylistic element central to camel case—in technical notation emerged in chemistry during the early 19th century. In 1813, Swedish chemist Jöns Jacob Berzelius devised a uniform system of chemical symbols to represent elements, using one or two abbreviated letters per element, with the first letter consistently uppercase and any second letter lowercase. This approach, exemplified in formulas like "H2O" for water or "NaCl" for sodium chloride, relied on the uppercase initials to visually demarcate boundaries between distinct elemental symbols within compounds, enhancing readability and precision in analytical work.[17][18] Berzelius's innovation addressed the limitations of prior ad hoc notations, such as Lavoisier's descriptive phrases or Dalton's circled symbols, by prioritizing brevity and logical structure amid the growing catalog of known elements—over 40 by 1813. Adopted rapidly by contemporaries like Humphry Davy, this convention standardized chemical literature and laid groundwork for quantitative analysis, including atomic weight determinations that Berzelius pioneered through precise experimentation.[19][20] Though focused on elemental abbreviations rather than multi-word phrases, Berzelius's use of medial capitals represented a deliberate technical adaptation for disambiguation in dense, symbolic expressions, predating broader applications by over a century. Sporadic instances appeared in other scientific domains, such as early electrical engineering schematics or pharmaceutical compounding notations in the mid-19th century, but lacked the institutional standardization seen in chemistry until trademarks like "CinemaScope" in 1953 popularized the form commercially.[21]Initial Commercial Adoption
One of the earliest documented commercial uses of medial capitals, a stylistic precursor to modern camel case, occurred in trademarks during the mid-20th century. The CinemaScope widescreen film projection system, developed by 20th Century Fox and debuted in the 1953 film The Robe, represented a prominent example, employing "CinemaScope" to create a distinctive, single-word brand for its anamorphic lens technology.[22][23] This approach facilitated trademark protection by forming compound words without spaces or hyphens, enhancing visual memorability in advertising.[24] Following CinemaScope, similar conventions appeared in consumer products and retail branding. AstroTurf, an artificial turf brand introduced in 1967 by Monsanto Company, utilized upper camel case ("AstroTurf") to denote its synthetic grass innovation for sports fields.[23] ShopKo, a discount department store chain founded in 1962, adopted "ShopKo" for its logo and signage, reflecting early retail experimentation with the style to evoke compactness and modernity. These instances prioritized proprietary naming over readability, often in industries like entertainment and manufacturing where brand differentiation was key.[24] By the late 1970s, camel case gained traction in emerging technology sectors, coinciding with the commercialization of computing services. CompuServe, launched in 1977 as one of the first major online service providers, branded itself "CompuServe" to signify computer-based servicing, marking an initial pivot toward tech product nomenclature. This period saw medial capitals as a practical solution for avoiding spaces in early digital interfaces and printed materials, predating widespread programming standards.[24]Development in Computing
Pioneering Implementations in Programming Languages
One of the earliest systematic implementations of camel case in a programming language occurred in Smalltalk, an object-oriented language developed at Xerox PARC starting in 1970, with the first version, Smalltalk-72, released in 1972. In Smalltalk, identifiers such as method names and variables conventionally employed medial capitals to delineate word boundaries without separators, enhancing readability in code where underscores were avoided.[25] This convention, often referred to as mixed case or studly caps in early documentation, was integral to Smalltalk's design philosophy, which emphasized concise, descriptive naming for objects and messages; for instance, method selectors likeaddDependent: exemplified lowerCamelCase for actions and upperCamelCase for classes like OrderedCollection.[22] [26]
Smalltalk's adoption of camel case predated its widespread influence, appearing consistently in implementations from Smalltalk-76 onward and formalized in the influential Smalltalk-80 release of 1980.[27] The language's case-sensitive syntax explicitly supported this style, distinguishing identifiers like maxLimit from MaxLimit, and it was documented as a preferred practice to aid scanning for word breaks in dense code.[25] This approach contrasted with contemporary languages like C, which favored underscores (e.g., in Kernighan and Ritchie's 1978 examples), highlighting Smalltalk's pioneering role in promoting hump-like capitalization for multi-word identifiers in object-oriented contexts.[28]
Subsequent early adopters built on Smalltalk's precedent; for example, Modula-2, released in 1978 by Niklaus Wirth, incorporated similar mixed-case naming in some modules, though less rigidly standardized than in Smalltalk.[29] By the 1980s, this convention spread to derivatives like Objective-C (1984), where NeXT's frameworks used camel case for methods and properties, influencing later ecosystems.[30] These implementations established camel case as a hallmark of readable, space-efficient naming in dynamic and object-oriented languages, setting the stage for its dominance in Java (1995) and beyond.[26]
Influence on Standards and Ecosystems
Camel case has profoundly shaped naming standards in object-oriented programming languages, particularly through its endorsement in official guidelines for Java and JavaScript, which dominate enterprise and web ecosystems. In Java, the official code conventions specify lower camel case—starting with a lowercase letter followed by capitalized internal words—for method names (e.g.,getName) and non-constant variables, a practice outlined in Sun Microsystems' 1997 guidelines and maintained by Oracle.[31] This convention extends to classes using upper camel case (Pascal case variant), influencing over 10 million developers annually via platforms like Android and Spring Framework, where adherence ensures code maintainability and IDE auto-completion efficiency.[31]
JavaScript ecosystems similarly standardize on camel case for functions and variables, as recommended by MDN Web Docs and Google's style guide, aligning with browser APIs like the DOM's addEventListener.[32][33] Although ECMAScript lacks prescriptive naming rules, this de facto adoption in Node.js and front-end frameworks such as React—handling billions of web requests daily—has propagated to serverless and full-stack environments, reducing cognitive load in mixed-language projects.
In API and data interchange standards, camel case facilitates interoperability, notably in JSON payloads. The JSON:API specification, ratified in 2015 and used in production by companies like Netflix, explicitly recommends camel-cased member names (e.g., firstName) to match JavaScript object handling, avoiding parsing discrepancies in client-side code.[34] RESTful services often pair kebab-case URLs with camel-case JSON keys, as seen in Google Cloud APIs, reflecting Java and JavaScript's ecosystem dominance and enabling seamless data flow across microservices architectures.[35]
Empirical evidence from controlled studies underscores its standardization benefits, showing camel case yields 13.5% higher recognition accuracy than underscore-separated alternatives in identifier comprehension tasks, informing style guides that prioritize developer productivity in large-scale ecosystems.[36] This has cemented camel case as a foundational element in JVM, npm, and Maven repositories, where inconsistent naming historically increased integration errors by up to 20% in polyglot teams.
Expansion to Software Products and Branding
The adoption of camel case in software product naming emerged in the 1970s and 1980s, paralleling the maturation of commercial software markets, where developers leveraged the convention's readability and compactness from programming practices to craft brandable identifiers. This allowed for single-word trademarks that avoided spaces—problematic in early file systems—and hyphens, which could complicate parsing or aesthetics, while preserving word boundaries through medial capitals. Early motivations included space efficiency on limited displays and the creation of proprietary names that evoked functionality, such as combining descriptive terms into unified brands.[24] Pioneering examples appeared with network and productivity software. CompuServe, an early online service provider founded in 1969, employed the name to denote computational serving, setting a precedent for tech firms. WordPerfect, a word processing application first released in 1979 by Satellite Software International (later acquired by Novell), used the convention to signal comprehensive text refinement capabilities. Novell's NetWare, launched in 1983 as a network operating system, similarly integrated "net" and "ware" for a sleek, professional image. Microsoft's PowerPoint, originally developed in 1984 and rebranded upon acquisition in 1987, capitalized on the style for its presentation software, aligning with emerging graphical user interfaces. These instances reflected a causal link: programming's need for delimiter-free identifiers influenced product naming to maintain internal consistency and external appeal.[24] Apple accelerated the trend in multimedia and consumer products during the 1990s, integrating camel case with innovative prefixes. QuickTime, Apple's multimedia framework debuted on April 23, 1991, combined "quick" for speed and "time" for temporal media handling, enabling seamless video playback in applications. This was followed by hardware-software hybrids like the iMac G3, unveiled on August 6, 1998, where the lowercase "i" prefix (denoting internet integration) preceded capitalized elements, influencing subsequent lines such as iPod (2001). Apple's approach stemmed from design principles favoring intuitive, typeable names that supported marketing in a digital era, while ensuring compatibility with case-sensitive environments like Unix-derived systems.[37][24] By the 2000s, camel case permeated broader software branding, as seen in JavaScript (coined in 1995 by Netscape for its scripting language) and later web-era products, prioritizing global searchability and logo versatility. Empirical advantages included reduced visual clutter in documentation and UIs, though critics noted potential readability issues for non-native English speakers or in all-caps contexts. Overall, this expansion underscored camel case's utility in balancing proprietary uniqueness with semantic clarity, driven by technological constraints rather than mere stylistic preference.[24]Contemporary Applications
Coding and Development Practices
In programming languages influenced by C-style syntax, such as Java, JavaScript, and C#, lower camel case—starting with a lowercase letter and capitalizing subsequent words—is the standard convention for naming variables, methods, and functions to enhance code readability without relying on separators like underscores. [7] Upper camel case, also known as Pascal case, is conventionally applied to class names, interfaces, and types, where the first letter is capitalized along with the initial letters of subsequent words. [31] The Oracle Java Code Conventions, established in 1997 and still referenced, explicitly mandate lower camel case for variables (e.g.,myVariableName) and upper camel case for classes (e.g., MyClassName), advising developers to select descriptive names that reflect purpose while adhering to this casing to maintain consistency across projects. [31] Similarly, the Google Java Style Guide recommends camel case for all identifiers, underscoring its role in facilitating comprehension of expansive codebases by standardizing format and minimizing cognitive load during maintenance. [38]
In broader development practices, adherence to camel case conventions is enforced through integrated development environment (IDE) configurations, static analysis tools like linters, and peer code reviews, which collectively reduce naming-related defects and improve collaboration in team environments. [4] For instance, languages like Scala prescribe camel case for most identifiers, with the first word optionally lowercase, integrating this into official style documentation to guide scalable software architecture. [39] These practices prioritize empirical benefits in legibility over alternatives like snake case, particularly in object-oriented paradigms where identifier proliferation demands clear word boundaries. [14]
Markup Languages and Web Protocols
In XML, names for elements, attributes, and other identifiers may incorporate CamelCase to concatenate words, as the language treats names as case-sensitive strings without imposing a mandatory casing rule.[40] This flexibility allows developers to use CamelCase in custom schemas for improved readability of compound terms, though lowercase or hyphenated alternatives are also common; for instance, polyglot markup compatible with both HTML and XHTML occasionally employs CamelCase for specific elements to ensure cross-compatibility.[41] In HTML and related web markup, CamelCase appears in attribute values, IDs, and JavaScript-interfaced properties rather than core element names, which are standardized in lowercase per HTML5 specifications.[1] Custom elements in modern web components pair kebab-case tags with underlying CamelCase properties in associated JavaScript objects, facilitating dynamic data binding. For web protocols, CamelCase is prevalent in data serialization formats like JSON used within HTTP-based APIs, where it aligns with JavaScript's object property conventions for client-side handling. The JSON:API specification explicitly recommends camel-cased member names (e.g.,firstName) to promote consistency across implementations, starting with a lowercase letter followed by capitalized subsequent words.[34] In contrast, HTTP header field names adhere to a hyphen-separated title-case format (e.g., "Content-Type") and are defined as case-insensitive under RFC 7230, though programmatic access in languages like JavaScript often normalizes them to lowercase or converts to CamelCase equivalents for internal use.[42] This distinction underscores CamelCase's role in application-layer data structures rather than protocol headers themselves, reducing parsing overhead in dynamic web environments.[43]
Broader Digital and Social Contexts
In branding and product naming, CamelCase has been employed to create memorable, space-free compound identifiers, with examples including YouTube, iPhone, eBay, and FedEx.[5] This convention facilitates visual distinction of word boundaries in logos and trademarks, enhancing recognizability without relying on separators like hyphens or underscores.[8] Domain names and URLs often incorporate CamelCase to mirror brand styling, as seen in registrations like PayPal.com and LinkedIn.com, where it aligns with corporate identity while adhering to DNS technical constraints that prohibit spaces.[3] On social media platforms, CamelCase gained prominence in hashtag practices starting around 2020, particularly for multi-word phrases, to boost readability and accessibility.[44] Guidelines from institutions like New York University recommend capitalizing the first letter of each word in hashtags (e.g., #DigitalAccessibility), as this aids screen readers in parsing them as distinct words rather than undifferentiated strings, benefiting users with visual impairments.[45][46] Adoption of this practice reflects broader digital inclusivity efforts, with marketing resources noting its role in making content more comprehensible to diverse audiences, though hashtags remain case-insensitive for search functionality across platforms like Twitter (now X) and Instagram.[47][48] In online usernames and handles, CamelCase serves to concatenate personal or descriptive elements without spaces, such as JohnSmith in forums, gaming profiles, or email aliases, promoting compactness in character-limited environments.[1] This usage extends to internet subcultures, where it informally denotes compound terms in discussions or memes, though it lacks standardization outside technical domains.[49]Analytical Perspectives
Readability and Cognitive Studies
Empirical studies have examined the cognitive impact of camelCase on identifier readability in programming contexts, focusing on recognition accuracy and processing time. A 2009 study by Binkley et al. involving 135 participants, including both programmers and non-programmers, used a timed recognition task where subjects identified multi-word identifiers presented amid visual distractions. Results showed camelCase yielding higher accuracy (88.8% correct identifications) compared to underscore-separated styles (84.3%), with an odds ratio of 1.617 favoring camelCase (p=0.0127), though recognition took 13.5% longer on average (0.42 seconds more per identifier, p<0.0001).[50] Participants familiar with camelCase from training or experience processed it faster relative to underscores, suggesting adaptation mitigates time costs.[50] Subsequent eye-tracking research by Sharif and Maletic in 2010 replicated aspects of the Binkley study using 11 participants (programmers) in a code comprehension task, measuring fixations and reading times for source code snippets. While accuracy differences were not statistically significant, camelCase identifiers required 20% longer total reading time (average 932 ms more) than underscore variants, with increased fixations indicating higher cognitive effort for word boundary detection.[51][52] The study attributed this to the lack of explicit separators in camelCase, potentially increasing mental parsing demands during initial exposure, though experienced developers showed no accuracy penalty.[51] A 2023 systematic literature review of 15 studies on code formatting elements, including identifier styles, highlighted inconsistent findings: some evidence supports camelCase for improved legibility in trained users, while others favor underscores for faster processing, particularly for novices or non-native English speakers.[53] Overall, cognitive benefits of camelCase appear tied to domain-specific familiarity, with trade-offs in speed versus precision; no consensus exists on universal superiority, underscoring the need for context-dependent conventions in reducing cognitive load during code maintenance.[53] These results derive from controlled experiments but may not fully generalize to real-world, long-duration coding sessions involving semantic context beyond isolated identifiers.[50][52]Advantages and Empirical Benefits
Camel case enhances readability by using uppercase letters to delineate word boundaries within compound identifiers, facilitating quicker mental parsing compared to continuous lowercase strings. This convention leverages visual cues akin to natural language capitalization, aiding in the decomposition of multi-word terms without additional separators.[50] Empirical evidence from a study involving 135 participants, including programmers and non-programmers, demonstrates that camel case yields higher accuracy in recognizing individual words within identifiers, achieving 88.8% correctness versus 84.3% for underscore-separated styles, with odds of correctness 51.5% higher (p=0.0127).[50] Participants trained in camel case also recognized identifiers faster than those trained in underscores, suggesting adaptation improves efficiency (interaction p=0.0342).[50] While recognition time averaged 13.5% longer (0.42 seconds) for camel case overall, the accuracy advantage persists across training levels, indicating a net benefit for comprehension tasks where precision outweighs marginal speed differences.[50] The compactness of camel case reduces identifier length by eliminating underscores, conserving horizontal space in code and minimizing visual clutter in dense listings—a practical benefit in languages like Java and JavaScript where it is standard.[54] This brevity can lower cognitive load during scanning, as shorter tokens align with principles of minimizing extraneous visual elements in software engineering. Adoption in major ecosystems fosters familiarity, reducing onboarding friction for developers; for instance, its prevalence in object-oriented paradigms correlates with faster convention adherence in collaborative projects. In markup and protocol contexts, such as XML attribute names, camel case avoids conflicts with special characters like hyphens, which may require quoting, streamlining authoring without sacrificing descriptiveness. Empirical support for broader benefits remains limited, though cognitive alignment with word hump recognition supports its efficacy in professional coding environments over alternatives requiring explicit separators.[52]Criticisms and Limitations
One limitation of camel case arises in empirical assessments of readability, where processing times differ based on user training. In a 2009 study involving 135 participants, camel case identifiers achieved higher recognition accuracy (95.4% vs. 89.9% for underscores) but required 13.5% more time on average (0.42 seconds longer per identifier) compared to underscore style, particularly for subjects not specifically trained in camel case.[50] Subsequent eye-tracking research has highlighted further nuances. A 2010 study replicating aspects of the prior work found that underscore-separated identifiers elicited fewer fixations and regressions during reading tasks among participants primarily trained in that convention, suggesting camel case may impose higher cognitive load in mixed or underscore-dominant environments.[52] Practical drawbacks include challenges in identifier refactoring and maintenance. Prefixing a new word to an existing camel case identifier, such as changing "userName" to "activeUserName," necessitates recasing the original first letter from uppercase to lowercase, which disrupts the visual "humps" and increases error risk during edits. This issue stems from the convention's asymmetric treatment of the initial word (lowercase start in lower camel case), making systematic modifications less intuitive than in delimited styles.[55] Camel case also exhibits inconsistencies in handling acronyms and abbreviations, leading to project-specific variations like "HTTPRequest" versus "HttpRequest," which can hinder uniformity and automated tools for word boundary detection. Such ambiguities require additional style guide rules, complicating adoption in collaborative settings without enforced standards.[56] In case-insensitive systems, such as certain file systems or databases, camel case risks identifier collisions when case is folded (e.g., "userId" equating to "userid"), potentially causing runtime errors absent in fully lowercase delimited alternatives. This limitation underscores its dependency on case-sensitive parsing, limiting portability in heterogeneous ecosystems.[57]Comparisons with Alternative Conventions
CamelCase, which concatenates words with initial letters capitalized except the first, contrasts with snake_case, employing all lowercase letters separated by underscores (e.g.,my_variable_name). Snake_case provides explicit visual separation akin to spaces, potentially aiding rapid word boundary detection in natural reading patterns, and is the standard in languages like Python and Ruby, where creator Guido van Rossum prioritized readability over compactness. An empirical study involving 135 participants found snake_case enabled faster identifier recognition, though CamelCase yielded higher accuracy in source code comprehension tasks (88.8% correct vs. 84.3%, odds ratio 1.617, p=0.0127), albeit 13.5% slower on average (0.42 seconds longer, p<0.0001); trained programmers processed CamelCase more quickly, suggesting familiarity mitigates speed deficits.[50][52]
PascalCase, identical to CamelCase but capitalizing the initial letter (e.g., MyClassName), serves primarily for type and class declarations in languages such as Java and C#, distinguishing them from lowercase-starting variables or methods to enforce semantic hierarchy without additional separators. This convention reduces token count in parsers compared to delimited styles, aligning with object-oriented design principles that emphasize constructor-like naming for types.[31]
Kebab-case, featuring lowercase words joined by hyphens (e.g., my-variable-name), is rarely viable for programming identifiers due to hyphen interpretation as subtraction operators in most languages, but dominates web contexts like CSS selectors and URLs, where hyphens signal word breaks to search engines—unlike underscores, which are treated as intra-word connectors, potentially harming SEO by merging terms. CamelCase avoids such parsing ambiguities and special characters, facilitating keyboard efficiency in IDEs without shift-key dependencies for underscores, though it demands cognitive parsing of humps for boundaries, which eye-tracking studies indicate underscores resolve more swiftly in untrained eyes.[52]
| Convention | Primary Contexts | Key Trade-offs |
|---|---|---|
| CamelCase | Variables/methods in Java, JavaScript | Compact; higher accuracy with training but initial speed penalty vs. delimiters[50] |
| Snake_case | Variables/functions in Python, Ruby | Explicit separation for readability; slower typing due to underscores |
| Kebab-case | URLs, CSS classes | SEO-friendly separators; invalid in most code syntax |
| PascalCase | Classes/types in C#, Java | Semantic distinction from instances; similar to CamelCase in processing demands |