In computer programming, spaces are often forbidden in the declaration of variable names, so programmers have created alternate methods of identifying word boundaries in variable names: camel case and underscores being two of the most popular.



There's no shortage of debate about the superiority of one or the other on the internet, including within Stack Exchange, and on blogs approaching the question from a variety of perspectives, but like many questions in psychology there's probably no clear winner here. Instead, there are likely to be advantages and disadvantages of each approach.

What does the cognitive science literature say about the relative advantages and disadvantages of camel case and underscore case programming conventions?

  • 3
    $\begingroup$ I checked before I posted. There is a surprising amount of research on the topic! $\endgroup$ May 15 '15 at 23:41

As the author of the blog post you refer to, I can state that at the time of writing (early 2011) there were not too many studies reporting on this specific topic, which is why I reported on the single study I found at the time (Binkley et al. 2009). However, I advise you to read a follow-up study by a different group of researchers (Sharif and Maletic 2010). They address some of the shortcomings in the earlier study.

The common finding for both studies is that camelCasing is slower to read, which I summarized in a follow-up post:

No difference in accuracy was reported (as opposed to Binkley et al.), but on average, camel-cased identifiers took 932ms (20%) longer than underscored identifiers, in line with the 13,5% longer as reported by Binkley et al. The eye tracking results also give some insight into visual effort. Camel-cased identifiers require a higher average duration of fixations.

Based on more general studies in cognitive science (Epelboim et al. 2009) (as I mentioned in the summary of the first study) this was to be expected:

Natural language research in psychology found that replacing spaces with Latin letters, Greek letters or digits had a negative impact on reading. However, shaded boxes (similar to underscores) have essentially no effect on reading times or on recognition of individual words. Removing spaces altogether slows down reading 10-20%.

However, I haven't done any follow-up research on this, thus it would definitely be worthwhile to dig into more recent citations. The ones listed below should provide a suitable starting point to this end.

Binkley, D., Davis, M., Lawrie, D., & Morrell, C. (2009, May). To camelcase or under_score. In Program Comprehension, 2009. ICPC'09. IEEE 17th International Conference on (pp. 158-167). IEEE. [PDF]
Sharif, B., & Maletic, J. I. (2010, June). An eye tracking study on camelcase and under_score identifier styles. In Program Comprehension (ICPC), 2010 IEEE 18th International Conference on (pp. 196-205). IEEE. [PDF]
Epelboim, J., Booth, J. R., Ashkenazy, R., Taleghani, A., & Steinman, R. M. (1997). Fillers and spaces in text: The importance of word recognition during reading. Vision Research, 37(20), 2899-2914.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.