New words created by smashing together capitalized words.
- Are they really smashed? Such violence. Aren't they more cuddly, and in love?
There is disagreement about the precise meaning of the term CamelCase
. Some hold that camel case words must begin with a lowercase letter (thisIsAnExample), others not:
camel case: thisIsAnExample. SomePeopleConsiderThisAnExample.
lower camel case: thisIsAnExample. ThisIsNotAnExample.
upper camel case, a.k.a. PascalCase: ThisIsAnExample. thisIsNotAnExample. (Some people consider this term an OxyMoron.)
In some contexts, CamelCase
words may include digits.
for synonyms and related terms.
According to this document - http://www.fpml.com/documents/standard/FpML-10b2/faq.html#WDConventions2
on the Financial Products Markup Language site, 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.
words are harder to read than their non-camel-case counterparts, P
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. -- DaveVoorhis
I, too, am quite skeptical 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 analyze the spelling of the word - a huge slow-down. Note: more advanced readers even recognize the shapes of common phrases, such as "of the".
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 whitespace. 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 camelCaps. 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 anime 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.
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
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
", 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?
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
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 WikiPage
s. 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?
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 Studly
Caps 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?
Don't know about the etymology, but I always knew of "camel case" as W
ordsLikeThese, 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
doesn't that look like a camel looking backwards? - Clearly one "M" represents two humps! :-)
when used to name identifiers in computer programs.