At night to relax I've still been reading about Common Lisp. There's a lot to like about it.
But there's one thing that drives me crazy:
- Let's define a variable:
- Let's define a method:
- Let's define a macro:
- Let's define a package:
- Let's define a class:
- Let's define a symbol macro:
DEFSYMBOLWhoops, nope, it's
- Let's define a condition class:
DEFCONDITIONSorry, nope, it's
- Let's access an element of a plist:
(GETF SOMELIST :KEY)
- Let's access an element of an array:
(AREF SOMEARRAY INDEX)
- Let's access an element of a vector:
(ELT SOMEVECTOR INDEX)
- Let's access an element of a hash:
(GETHASH SOMEHASH KEY)Wrong! It's
(GETHASH KEY SOMEHASH).
For some macros, you have to quote your arguments. For some others, you don't. For some it's a mixture. Sometimes a symbol will evaluate to a variable. Sometimes it'll be read as a symbol, not evaluated. Sometimes it'll be evaluated but you never want it to be evaluated so you always need to quote it.
Sometimes parameters to function calls need to be grouped into lists and sublists. Sometimes you just pass in a big flat bunch of arguments and the method sorts them out. Often it's an arbitrary mix of the two.
Yeah, my problem is consistency. Programming is hard enough without throwing in a requirement for a bunch of rote memorization of the wording and ordering and grouping of things. Especially when those things are arbitrary, and there's no reason NOT to have them be consistent. In Lisp they're probably even more arbitrary than other languages.
This is Lisp, and if I wanted, I could write my own macros that translate new, consistent versions of those things into the inconsistent default versions. Lisp gives you the power to do that easily. But if I do that, I'm no longer writing the same Lisp everyone else
* is writing. I'm writing my own derivative where I'm replacing standard things with non-standard things of my own.
There's more to a language than being syntactically correct, after all. There are dialects and idioms, and those are very important. If you learned English from a textbook, but never spoke it aloud with anyone speaks English natively, would you be able to communicate well? Would someone from England or America or India understand you? Likely you would be just barely intelligible to all of the above. It's the same English language, but how you use the language matters as much as being strictly grammatically correct. Your accent, your word choice, your general style, those things matter a whole lot.
It's the same with programming languages. If I wrote Ruby and used C-like for loops and 8-character-wide tab-indentation and CamelCase and ended every line with a semicolon, anyone very familiar with the language would cringe to read it. In Lisp, where you can change pretty much everything about the language, there's even more potential for writing things that are unintelligble to the community at large.
Lisp does have a beautiful consistency to it overall though.
*** Everything is an s-expression. (Well, except LOOP. Oops!) Everything returns a value. Code and data and code that writes code are all the same thing. It's only a few little quirks like the ones I mentioned above that drive me crazy. Consistency is also a large part of why I like Ruby: everything is an object, (almost) everything returns a value. And horrible inconsistency is one reason things like Java and PHP drive me absolutely insane.
The power of programming is in abstraction. When a group of things aren't consistent, there is no abstraction that can represent them. Or if there is, the abstraction is likely to be as nasty as the original problem. That's a bad thing.
* "everyone else" is probably around 17 people worldwide.)
** "at large", for lack of a better term.)
*** Jokes about how nobody uses Lisp aside, I do like the language plenty.)