Hyphens Make Clojure Macro Names Readable
Clojure macros are ever-growing longer, without bothering to include visual queues for word breaks. Apparently, these macros draw their inspiration, mysteriously, from the German language (e.g. hauptbahnhof; see more examples at Wiktionary's List of German Compound Words).
So. Hard. To. Read. As is my tradition on this medium, I will rant against things gone wrong that will likely never change. In that spirit, I hang my head in shame and ask: Why? Why? Why?
Look at the examples below. Which is more readable? Which would best fit in with Clojure, the language we love?
defcomponent or def-component
defcomponentk or def-component-k
defroute or def-route
defcomponentmethod or def-component-method
The latter (hyphenated) examples are clearer to read. I won't even go into the scientific studies showing that the latter examples are happier, live longer, and are less likely to bully other macros. In the long run, the happy macros are less likely to resort to violence when things inevitably go south.
Clojure developers don't make these hideous name in other contexts. We use hyphens, because it is obviously better. So why do we do it with macros? Probably because we are lemmings.
I suppose the pattern started with defmacro, defrecord, and so on, way back in the days of the first LISPs. That was ok. Or was it? The anti-hyphen, alphabet smoosh-fest style really wins no style points as your macro names grow longer.
Next time you think about concatenating threeormorewordstogether, don't. It you do, you really should have your keyboard privileges revoked. I'm talking to you, defcomponentmethod.










