Matt's Mind

Saturday, March 26, 2011

Lisp take 2

(This post has the dubious honour of being my first in 4 years. I had all sorts of grandiose ideas about moving this blog from blogger to something slightly more hip like posterous or my own hosting, but that would really have been such a waste of time. In the meantime, the planned move was a good excuse not to write anything. Further excuses like getting married and the birth of our daughter then presented themselves. What decided me to write again was re-reading some old articles and comments, and discovered some things I didn't even remember writing as well as some interesting comments - I realized I missed blogging.

Just for added nerd points, this article was written on an iPad. Using the touch keyboard. Yes, I also, apparently, did not get the memo that the iPad is only for consumption of content [link is to John Gruber's teardown of that strange meme].)

I recently re-read an article I wrote in 2007 about not being able to think in Lisp and worrying about what that meant to my development, or otherwise, as a programmer. Since then, I've resembled even more the developer's equivalent of a midlife crisis, and tried quite a few other languages, including Haskell, Scala, Groovy and, Brainfuck (just joking about that one but, frankly, I'm not convinced J or Forth, which I also had a look at, are that much different :) ).

Recently I've started a new commercial project using Clojure for the server backend and Objective-C on iOS for the (iPhone) client. And I'd like to report that I actually believe I can now, finally, think in Clojure, i.e. Lisp. Yay. It surprises and elates me to no end as it turns out.

What's more, writing significant software in Objective-C has given me an excellent basis of productivity comparison with Lisp and, I have to say, the Lisp code is so much more information dense,* it's a little scary. Partly so because I'm worried that means it's a write-only language from the point of view of anyone else. And also partly because I may not want to go back to OO Java land again.

That's not to say I don't like Obj-C, I do, and I really like the Cocoa/UIKit framework on iOS too: it's quite clearly the result of software API craftsmen working at the highest level. But things like the .h/.m file separation and, particularly, the lack of literal syntax for lists and maps are constant irritants, the latter so much so that I've started writing complex data structures in JSON and using a library to translate this into NSDictionary's/NSArray's at runtime, because it's just too verbose otherwise. And tracking retain/release bugs can be a huge black hole for productive time.

Did learning Lisp make me a Paul Graham-certified programming god? I rather suspect not, but I now I know what I was missing out on. And it was most certainly worth it in terms of mind-expansion and generally feeling more secure as a programmer nearing his 40's.

* The server, which implements a fairly scary data replication database, is less than 3,000 lines of Lisp. Whereas I suspect at least one of the Obj-C classes is probably that big by now :/