I hate underscores. They are ugly. They are like the neon orange belt pack of syntax. Dated and unfashionable no matter what era they are found in. As the former owner of a neon orange belt pack, I feel I can speak with authority on this. Aesthetically speaking, underscores are one step shy of “
Only nerds even know what an underscore is. What’s the first thing I have to teach people who are brand new to programming? What the hell an underscore is, and where to find it on the keyboard. No, not that line. The other line. Hold down shift. There you go.
Underscores require me to hit the Shift key. When writing prose, I only hit the shift once or twice per sentence. In Ruby, I have to hit the shift key every few letters. Awkward. Inefficient.
I’ve been thinking about rebinding the dash key to underscore in Emacs ruby-mode. It’s stupid that I’m even considering such a thing.
Underscores are visually ambiguous. When the font is underlined for some reason, the underscores get muddled up with the underlining. In badly-rendered text boxes it’s not always clear where the underscore leaves off and the bottom border begins.
CamelCase is no better. I still have to hit Shift all the time. Plus it relies on a peculiarity of the Latin family of languages.
Lisp gets it right. Lisp S-expressions have one basic rule that vastly simplifies the syntax: whitespace separates tokens. Always.
This means that “
foo - bar” parses out to the three tokens “foo”, “-“, “bar”. Whereas “
foo-bar” is a single token that happens to have a dash in the middle. That’s right, your tokens can have dashes in the middle. Ordinary, easy-to-type, recognizable, visually unambiguous dashes. Lisp functions have names like:
All you have give up for this is tightly-packed arithmetic statements, like this:
Instead, you have to give your tokens some breathing room:
5 * 5 - 3
That’s a trade-off I’ll gladly make if it means using dashed identifiers instead of underscores.
I mostly code in Ruby these days, and I love almost every aspect of its very rich syntax. But I hate all the
snake_casing. I want a Ruby that lets me use dashes in identifiers. If I never type another underscore, it will be too soon.
UPDATE: The Recursive blog points out that Japanese keyboards may be more comfortable for typing Ruby.