Speculation about the origin of CamelCase
Prompted by Avdi Grimm’s post on underscores in program identifiers, I’ll publicly air my guess about why theBlightOfCamelCaseInfestsOurPrograms when_identifiers_with_underscores_are_obviously_more_readable. (Although Avdi is right that dashes are superior to both.)
As far as I can tell, the popularity of camel case came from Java, which got it from Smalltalk. But where did Smalltalk get it, and why did such smart people go so badly astray?
Flash back to 1979-1981. I was a computer operator for a PDP-10 mainframe at the University of Illinois Coordinated Science Lab. (I still have two pieces of that computer in my basement.) We had a bunch of VT-100 act-alike terminals. But off in a corner, where no one ever used it, we had a single terminal we called “the European terminal”. One interesting thing about the European terminal was that it had no underscore key. Instead, it had a back-arrow key. I have a faint recollection that if you viewed text with underscores on that terminal, it would show up with back arrows instead. (Or was it that the keyboard did have an underscore on it, but when you pressed it, it displayed a back arrow?)
It’s unlikely you’d write←identifiers←with←back←arrows←in←them and, in any case, some programming languages (such as Smalltalk) use back arrow to mean assignment (instead of, as was common before C took off, `:=`).
All of which makes me think—especially since Smalltalk came from Simula, and Simula came from Europe—was there no underscore available to the people who built Smalltalk back in its early days? Was that why they fell back on StudlyCaps?
(I even have a very dim memory of some language—I don’t think it was Smalltalk—where underscore, as well as a back arrow, could be used for assignment.)
Does anyone know?
May 15th, 2012 at 10:33 am
S, and therefore R, uses underscore as well as ASCII ‘
May 15th, 2012 at 10:41 am
@kragan says: “Yes, Smalltalk used the ASCII-1963 standard, in which _ was ← and ^ was ↑, rather than 1967. And ← was assignment. Still is.”
and
“Squeak only adopted a font where _ was _ and not ← sometime around 2005, and you can still use _ for assignment IIRC.”
and
“I think the popularity of camelCase in the mainstream actually predates Java; it comes from C++ programmers aping Smalltalk.”
May 15th, 2012 at 10:47 am
Oh, and this from Wikipedia:
May 15th, 2012 at 10:52 am
I don’t know where camel case came from, but I know why it’s better: one less keystroke.
May 30th, 2012 at 1:37 pm
Picking up where bl0rq left off, I’ll add that I prefer camelCase because I’m yet another QWERTY sucker. All things being equal, I try to avoid characters on the top row of the keyboard. Ruby’s a lovely language conceptually, but ergonomically, it’s fat on @, #, and _. The hyphen in -> isn’t winning it any points, either.
I think a good 20% of the negative side of my ambivalence about Lisp comes from the parens. Not that one can hope to escape them in any language. And I don’t mind top-row characters in genuinely mathematical expressions. Math isn’t English, I’ve made my peace with that. But there comes a point when enough is plenty. It reminds me of a moment in Salinger (I’m thinking “Raise High the Roofbeams, Carpenter”, but the internets tell me it’s “Seymour — An Introduction”), when Buddy Glass writes, confessing and only half-apologizing for his deeply nested syntax, “I privately say to you, old friend, please accept from me this unpretentious bouquet of very early-blooming parentheses: (((( ))))”. Lisp and Salinger, two things from the sixties that I liked in my teens and twenties and have reservations about now.
Returning to the OT, everyone loves languages that are readable, but let’s not forget about being able to type them, too. In fact, this extra keyboard workout may be the only sense in which Ruby is “strongly typed”. Heh.