Sunday, June 27, 2010

Walk a mile in a Lisp hacker's moccasins

"What's so great about YOUR programming language"? Bob asked Alice. Alice had been here before, she knew that if you are asked that question you should not answer, it's a trap! What Bob's question really meant is "I am OK coasting with the language I already know, you are trying to persuade me to do what seems to be unnecessary work to learn your new-fangled  language". Thinking quickly on his feet he came up with this trick question, which really means "in 30 seconds or less convince me that the language is superior to the one I already know or perfect for my needs". As with any nuanced argument, the case for a particular language cannot really be made in a pithy sentence that has high sound-bite value. In life there are pros and cons for any course of action.

Bob had succumbed to confirmation bias, for whatever reason (I would guess laziness) he had already decided that he was not going to learn the language. What he was really looking for was an excuse. So he posed a question of the form "give me the one killer reason to do it", since there is no ONE magic reason, Alice would fail to provide it and he could live on blissfully and effortlessly too! Alice did not take the bait  though. Instead she offered to teach Bob the basics of the language, little by little through progressively more interesting examples. She followed through on her offer and bit by bit time Bob began to see where her passion for the language stemmed from. At the end of it he was not quite ready to jump ship but he felt enriched by the experience he had a great time and learned a new language in the process.

You can substitute my name for Bob, (though indirectly) Hal Abelson and Gerry Sussman for Alice and Lisp is the unnamed language in the little story above. For long time and for no reason that I can think of other than that the nested braces where a little hard to read I had long resisted learning Lisp despite much cajoling from one or two friends. I had my little reasons like Polish notation arithmetic was hard to read and a host of others. Then one day I came across Abelson and Sussman's recordings from 1986 of the MIT course Structure and Interpretation of Computer Programs (SICP). That chance happening changed my view of Lisp completely in less than two weeks. SICP was taught in Scheme a dialect of Lisp, it took a few attempts but I eventually got into it, watched the videos attentively and was rewarded handsomely.

There are 10 lectures and by the end of the 5th one, having written with ridiculously little effort a host of interesting programs and in the process creating both an embedded an interpreted Domain Specific Language, I was a changed man! I had seen the light, I finally understood the ravings which just a fortnight earlier were incomprehensible.  My eyes no longer blind to the light I realised that similar derisions to those made against Lisp can and have been made against other languages like say Python1 of which I am a great fan. So I whole heartedly encourage you watch the lectures or read the book which is available free on-line. After the first few chapters you may not be rushing to write your next web application in Lisp but I guarantee you will have a much better appreciation of the virtues of Lisp. The Native American prayer really rings true here: Grant that I may not criticize my neighbour until I have walked a mile in his moccasins. What's more with Lisp you need not even walk the full mile, a few hundred yards will do.

1. No curly braces? You rely on indentation to indicate block structure? That is crazy talk!

No comments:

Post a Comment