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:


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

For CamelCase to work on this wiki as forming a link to a page, it is required that all of the following conditions are met: If You study the code in WikiBase you find that the rule for CamelCase page names is thus: See CapitalizationRules for synonyms and related terms.


History

According to this document - http://www.fpml.com/documents/standard/FpML-10b2/faq.html#WDConventions2 on the Financial Products Markup Language site, upper camel case a.k.a. CamelCase is a naming convention that originated with SmalltalkLanguage. Anybody want to confirm or deny that? Perhaps give some history? -- StevenNewton

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

The earliest commercial example of (upper) CamelCase is the 1950s "CinemaScope" film projection system.


CamelCase 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, too, am quite sceptical about the claim that CamelCase 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 CamelCase could improve the speed since the shapes are definitely more distinct. -- HansWobbe

Fast reading (in English, anyway) is based on the shapes of words (that's mainly how SpeedReading 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".

CamelCase reduces my reading speed, quite drastically, exactly because it alters the normal shapes of the words. For me, CamelCase 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. -- DougKing

I am a native English speaker, and I find CamelCase 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. -- SamuelFalvo?

Have you trained yourself in SpeedReading? I mean, I too read CamelCase and PascalCase 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. -- SamuelFalvo?

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

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


Alternative Names

Wouldn't that be DromedaryCase? -- MossCollum

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. ConvertSpacesToTabs. 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". -- KurtGeorgeGjerde

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 CamelCase works quite well. Besides, it has such nice alliteration, I want to use it all the time. Perhaps we can call both kinds "CamelCase", with the further specification of SulkingCamelCase? for camelCase (the camel's head is down you see) and CapitalCamelCase? (yay, more alliteration!) for CamelCase 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 CamelCase 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 PascalCase.

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 PrairieDogging over their lower case neighbors.

Out in the 'real world' (e.g. product names), initial capitals are quite common as in 'PowerMac' 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 HyperCard in pre-PowerMac days, the style of capitalizing the first letter of each word and smushing them together seemed to be called InterCapping? (for both product names and variable names). Searching Google for InterCapping? returns a number of references to support this, many of them expired WikiPages. 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 AppleComputer has definitely given camelCase exposure with the iMac, eMac, xServe, iTunes, and other numerous hardware and software. -- MarcinJeske?

Actually, lowerCaseCamelCaps? 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 http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html -- those with an initial uppercase letter are known as StudlyCaps and those with an initial lowercase letter are camelCaps. -- SamuelFalvo?


I like that sulkingCamelCase :) I think it's Microsoft that started calling wordsLikeThese camel case and WordsLikeThese? 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 WordsLikeThese? -- DaveBoltie?

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


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


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


BumpyCase describes CamelCase when used to name identifiers in computer programs.


See: CapitalizationRules, CamelVsNonCamel, HungarianNotation

Contributors: JohnDouglasPorter


What about a ListOfFreePublicWikisThatUseCamelCase? Reason: it appears difficult to find those gems by GoogleSearch. -- FridemarPache

CategoryJargon


EditText of this page (last edited December 18, 2014) or FindPage with title or text search

Meatball