When I read Beating the Averages by Paul Graham, I knew I needed to look into Lisp.
One of the first things I learned was that "Learning Lisp" really meant learning a Lisp. Lisps are a family of languages with some common attributes. The most significant attribute is that Lisp code is written in a Lisp data structure. Since code manipulates data, and code is data, code can manipulate code. This manipulation is done with Lisp macros.
Because there are several languages that are Lisps, I had to pick one. I opted for Clojure, initially because it could compile down to .NET IL or Java byte code or Javascript. Soon I found out how well thought out its data structures and support for concurrency is.
I am confident that Clojure is the right Lisp for me, but that still begs the question, is Lisp right for me. Are Lisp macros really that powerful? Chas Emeric in Clojure Programming describes how Lisp macros are different from other languages' meta-programming support. They are code, not strings. They are applied at compile time, not at run time. They are using the same code that the programs use, not special api calls. But does all this matter?
It was Graham's essay that prompted the question, and I am hoping that one of Graham's books can answer it. On Lisp is available to read free online. According to the preface, the first 6 chapters deal with functions and the remaining 19 deal primarily with macros.
On Lisp should help me learn to think in macros. It is written in Common Lisp, which is different than Clojure. Hopefully translating it will help me to think in Lisp in Clojure.
I am not going to copy the whole book. I plan to post Clojure versions of the examples, with some explanation when it seems appropriate. If you want to play along, start reading Graham's book, and check back here for my Clojure interpretations of it.
"But does all this matter?"
ReplyDeleteI also would really like to know the answer to this question.