Camel Case

New text symbols created by uniting capitalized words or capitalizing one or more components of a word. The appearance of such a identifier resembles the outline of a camel:

upload.wikimedia.org


Camel Case is the collective name for the following, whereas upper camel case is what Camel Case means if not specified otherwise.

upper camel case, a.k.a. Pascal Case: ThisIsAnExample. thisIsNotAnExample.

lower camel case: thisIsAnExample. ThisIsNotAnExample.

For Camel Case to work on this wiki as forming a link to a page, it is required that all of the following conditions are met:

The first letter is capitalized.

One or more letters in that word are also capitalised.

The word does not end on a capitalized letter: CamelCasE

No two capitalised letters shall follow directly each other: CamelCAse

No number in that word at any place: CamelCase1more

No dot(.), under_score or dash (-) within the word, only letters: Camel_Case

No 'foreign' letters in it like äöüß or accentuated like áéí. CämélCáße

If You study the code in Wiki Base you find that the rule for Camel Case page names is thus:

It must begin with a capitalized letter, followed by at least one that is not. Then one or more instances of the above complete the pattern. Only letters are allowed, and every capital letter must be followed by at least one lower case letter. Digits and punctuation end the Regular Expression match.

See Capitalization Rules for synonyms and related terms.


History

According to this document - www.fpml.com on the Financial Products Markup Language site, upper camel case a.k.a. Camel Case is a naming convention that originated with Smalltalk Language. Anybody want to confirm or deny that? Perhaps give some history? -- Steven Newton

This page Camel Case provides a bit of history and supports the Smalltalk Language connection. -- Hans Wobbe

I think I remember this style of word break in BCPL code (e.g., at BBN), long before Smalltalk, in the early 70s. -- Chris Ryland

The earliest commercial example of (upper) Camel Case is the 1950s "Cinema Scope" film projection system.


Camel Case words are harder to read than their non-camel-case counterparts, ParticularlyWhenTheCamelCaseWordIsLong.

I'd be interested to see a measurement of this. Personally I find CamelCase words just as easy to read as "normal", and so does everyone I've asked. It would be an interesting study to see what the distribution is of reading slow-down rates against percentage of people. Does anyone have an honours, honours Masters or Ph.D. student looking for a project in the psychology of programming?

I can easily obtain such a student. I'll try to remember this next time one of them comes sniffing around for a thesis topic. -- Dave Voorhis (09/2008

I, too, am quite sceptical about the claim that Camel Case reduces reading speed, if only because I recall some studies that suggested the reading process is actually based on recognizing the shapes of words. If true, then Camel Case could improve the speed since the shapes are definitely more distinct. -- Hans Wobbe

Fast reading (in English, anyway) is based on the shapes of words (that's mainly how Speed Reading works). When you don't recognize the shape of a word, you have to stop and analyse the spelling of the word - a huge slow-down. Note: more advanced readers even recognize the shapes of common phrases, such as "of the".

Camel Case reduces my reading speed, quite drastically, exactly because it alters the normal shapes of the words. For me, Camel Case makes me stop reading fast in order to find the capital letters to know what the individual words are. This may be because I am a native English speaker, where words are separated by white space. It may be different for a native German speaker, who frequently has to parse compound nouns. -- Doug King

I am a native English speaker, and I find Camel Case to be just as fast as reading normal text. I find underscored_phrases_like_this to be slower, but not by much. All in all, I prefer upper camel case. It's faster to type than underscores, and faster to read. -- Samuel Falvo

Have you trained yourself in Speed Reading? I mean, I too read Camel Case and Pascal Case just as fast as English text... but I've never been a fast reader; only my love for English-subtitled animé has managed to get me to the point I could read almost as fast as I could comprehend spoken language.

No; I am actually an incredibly slow reader of normal, non-code prose. I've read books that friends of mine finish in a few days, but it takes me months to finish. -- Samuel Falvo

For what it's worth, I had a hard time with camel case and used _ all the time. As my typing improved, my resistance to camel case declined. My main objection to camel case was its reliance on case, given that not all languages are case sensitive (or in the case of mainframes even had case). This is still an issue, but less so as the years go on. I still have typo issues, but I am getting used to it - I still find issues with writing camel case, but reading is no longer an issue. This is a good thing as it is now ubiquitous and the merits or lack thereof are moot. -- Marc Grundfest

Lisp Language and other languages without operators can use - which is easier to type (no shift key on US keyboards). This is sometimes known as Kebab Case.


Alternative Names

Wouldn't that be Dromedary Case? -- Moss Collum

No. A dromedary can only have one hump, while a camel can have one or two (in English, a dromedary is a camel with one hump, whilst a bactrian camel has two humps); i.e. Convert Spaces To Tabs. And I agree with John that the initial character must be non-cap for it to be camelCase. Also, acronyms are usually all upper case so "visit NASA today" would become "visitNASAToday". -- Kurt George Gjerde

This is not the case for wiki page names and many Java identifiers, where the above would be munged to "visitNasaToday" for some reason.

A one hump camel has a bump A two hump camel has the mumps If you should see a three hump camel There's too much turps in your enamel. -- Sorry, couldn't resist.

If you think of the initial capital as the camel's head, then Camel Case works quite well. Besides, it has such nice alliteration, I want to use it all the time. Perhaps we can call both kinds "Camel Case", with the further specification of Sulking Camel Case for camelCase (the camel's head is down you see) and Capital Camel Case (yay, more alliteration!) for Camel Case as it's discussed on wikis. It only need be mentioned once whether the camel is sulking, unless you're working in an environment in which it would be ambiguous. Is this too complicated? Maybe. But I think it's worth it to be able to use the word Camel Case twice as often!

I think that if the first letter is a capital, it is not camel case, at least not in programmers terms. It is instead Pascal Case.

With a bit of loss in precision, then, how about referring to dromedaryCase vs. BactrianCase?

CAMEL ancyn.

I guess the "Camel" in the name refers to the "humps" created by the upper case letters as they are Prairie Dogging over their lower case neighbors.

Out in the 'real world' (e.g. product names), initial capitals are quite common as in 'Power Mac' whereas initial lower case is very rare, as in 'iMac', and is perhaps quite a recent innovation. We need names to distinguish these two types, so it seems natural to use the common word 'camel' for the first (most common) type and 'dromedary' for the second (rare) type. This implies the capitals are humps, and camels are assumed to have 2 humps by default.

When I worked with Hyper Card in pre-Power Mac days, the style of capitalizing the first letter of each word and smushing them together seemed to be called Inter Capping (for both product names and variable names). Searching Google for Inter Capping returns a number of references to support this, many of them expired Wiki Pages. camelCase, on the other hand, seems to be more closely connected with function calls in Pascal, C/C++, Java, and object-oriented languages using the dot-notation. Though Apple Computer has definitely given camelCase exposure with the iMac, eMac, xServe, iTunes, and other numerous hardware and software. -- Marcin Jeske

Actually, lowerCase Camel Caps have been a regular feature in Smalltalk code since at least the 80s, when I first saw them. I'm sure they go back farther.

Regarding what to call what, the Python community seems to have settled on using these terms. From python.net -- those with an initial uppercase letter are known as StudlyCaps and those with an initial lowercase letter are camelCaps. -- Samuel Falvo


I like that sulkingCamelCase :) I think it's Microsoft that started calling wordsLikeThese camel case and Words Like These pascal case. Ever since they bought out the chief architect of one of the best pascal compilers (Turbo Pascal which evolved into Delphi), Anders Hejlsberg in the 90's, and put him to work designing their dot net framework instead of working on a competing product, Delphi, they seem to have taken over the definition of camel case. AFAIK it was always for Words Like These -- Dave Boltie

Concur. Don't know about the etymology, but I always knew of "camel case" as WordsLikeThese, also. Who was the joker who thought it was a Good Idea® to go lowercase on the leading character? Why? If your entity name has only one root word with nothing concatenated behind it then you end up with an entity named with a leading lower case. Does your name have a lower case first letter? No? Then why do your variables, classes, etc. have them? Dumb, dumb, dumb. - Marty Schrader


Please adopt freelinks, they'e much better, and more in keeping with the usual practive on both forums and wikis -- Anonymous Donor


Ca Mel doesn't that look like a camel looking backwards? - Clearly one "M" represents two humps! :-)


Bumpy Case describes Camel Case when used to name identifiers in computer programs.


Contributors: John Douglas Porter


What about a List Of Free Public Wikis That Use Camel Case? Reason: it appears difficult to find those gems by Google Search. -- Fridemar Pache

See original on c2.com