| « Hacking viper-mode | Apple Aluminum Keyboard Firmware Update 1.0 Fixes Control Key » |
Syntax is something you only notice when switching languages. It’s like a smell; it may be impossible to stand at first, but you stop noticing in a couple of minutes. It’s just your brain letting you know that you’re in a new environment and whether it’s likely to be pleasant or not.
Of course smell is not a fool-proof indicator, which is probably why it wears off so fast. Take the worst syntax you can imagine: OCaml. Nice language, terrible syntax. It’s complicated, hard to remember, has ridiculous exceptions to parsing rules and is nothing like ANYTHING except Pascal. -shudder- But if you steel yourself and just start writing code, a couple of weeks in you stop noticing the syntax completely.
For example, over the last month I’ve needed to suddenly write some Javascript after four years of not touching the stuff. I haven’t even used a C-syntax language more than intermittently, and I remember the number-one annoyance is semi-colons, followed closely by braces. Fortunately Javascript lets you omit the semis (although it’s bad practise), and most of the brackets (though it’s really bad practise), so I convinced myself it wouldn’t be that bad. Two days later? I started putting all the brackets in because I wrote a classic dangling-else bug. It didn’t hurt a bit. If this keeps up, I’ll be putting in semis. You just acclimate to new syntax quickly, and learn the pitfalls almost as fast.
This smelly syntax property is really because programming languages are just that: languages. Even though they are technically just systems of notations for describing algorithms, they perform the two most important functions of language: Language lets us communicate with the others in our tribe, and it makes all the other tribes sound stupid for speaking gibberish or, even better, an idiotic version of our language. Programmers form groups based on language and then make fun of other groups. Syntax helps them do that by keeping them together and making the other groups seem stupid.
But, if you decide to switch groups, it’s important that you be able adapt quickly to the language used by the new group. It’s actually easy, because the effect of syntax disappears as soon as you learn it, and the semantics of the language you switch to are rarely so different from those of your old language.
You really don’t need to worry about smelly syntax unless you are trying to drum up support for your tribe. Specifically, the two groups that typically ignore syntax are Lispers and academics. Academics usually take the expedient course of copying the most popular syntax at the time, which sometimes pays off and sometimes backfires*.
This could be an important lesson for Lisp. For good or for bad, outsiders see Lisp as having “no syntax” and drowning in parentheses. (Lispers only say “no syntax” as shorthand for ‘no syntax worth worrying about’, or when they’re trying to sell Lisp to outsiders.) So…syntax only matters to switchers, and potential switchers compare Lisp syntax to oatmeal and fingernails. Which is too bad, because Lisp has the most writable syntax I know. I’d like for it to spread in the same way that Lisp’s semantics have spread.
So how could Lispers work around their syntax disadvantage? Here are some ideas I’ve seen floating around.
Um, obviously most of these ideas are not that great; most are ones that the various Lisp communities have been doing. The best, and probably the hardest, is to force people to get used to the smell because they need to build something awesome and it just happens to be written in a Lisp. This need not be all about macros either. Just something useful that nobody else does well.
Note: when I say ‘Lisper’, I mean a user of any dialect of Lisp. The differences between Common Lisp/Scheme/Arc/Clojure/Nylisp/whatever only serve to illustrate how important dialects are in forming boundaries.
*A notable and beautiful exception is Haskell, which obviously had some thought put into its syntax.