As part of my year’s learning goals, I’ve started reading Peter Norvig’s Paradigms of Artificial Intelligence Programming. I’ve gotten through the first few chapters (introductions to Lisp and a small sample program), and so far it’s a great book. Now, since I’m a cover-to-cover kind of guy, I even read the introduction, and I’m sure glad I did. There’s a great money quote that I’ve never seen anyone reference that is so self-explanatory I’ll just shut up and quote it:
“There is a myth that Lisp (and Prolog) are ‘special-purpose’ languages, while languages like Pascal and C are ‘general purpose.’ Actually, just the reverse is true. Pascal and C are special-purpose languages for manipulating the registers and memory of a von Neumann-style computer. The majority of their syntax is devoted to arithmetic and Boolean expressions, and while they provide some facilities for forming data structures, they have poor mechanisms for procedural abstraction or control abstraction. In addition, they are designed for the state-oriented style of programming: computing a result by changing the value of variables through assignment statements.”
“Lisp, on the other hand, has no special syntax for arithmetic. Addition and multiplication are no more or less basic than list operations like appending, or string operations like converting to upper case. But Lisp provides all you will need for programming in general: defining data structures, functions, and the means for combining them.”
This is like the statement in the Preface of the Structure and Interpretation of Computer Programs:
“Underlying our approach to this subject is our conviction that ‘computer science’ is not a science and that its significance has little to do with computers. The computer revolution is a revolution in the way we think and in the way we express what we think. The essence of this change is the emergence of what might best be called procedural epistemology — the study of the structure of knowledge from an imperative point of view, as opposed to the more declarative point of view taken by classical mathematical subjects. Mathematics provides a framework for dealing precisely with notions of ‘what is.’ Computation provides a framework for dealing precisely with notions of ‘how to.'”
I had read the SICP quote before and knew it was important, but Norvig’s quote made it clearer for me.
Fortunately, the gulf between programming languages isn’t as great as it was in 1992 when PAIP was published. While languages like C and C++ are hard to beat for performance and OS interaction, newer languages like Python and Ruby (and even Java/C# with garbage collection) deal more with computation than direct hardware manipulation. Fortunately they haven’t followed Lisp in all ways!
Daniel Weinreb says
Python and Ruby and Java have borrowed a lot of good ideas from Lisp. There are things about Lisp that used to be novel and nearly unique, such as garbage collection, that have moved into the mainstream. So even if Lisp is not one of the prominent languages in use today (we’re working on that!), it has had a lot of influence.
About “special purpose”, a great thing about Lisp is that you get the best of both worlds. Common Lisp is a general purpose language. But when you want/need a special purpose language, you can just build it in Common Lisp, using macros and other facilities. That’s hugely faster than writing a whole new language system from scratch! A lot has been written about these “little languages” and it’s one of the most important things about Common Lisp both in theory and in practice.
At my shop (ITA Software), we use C primarily when we have to do a whole lot of bit-level manipulation – I’m talking about huge amounts, where the performance benefit of C’s special-purpose ability to do this is overwhelming. We also have used C for writing Apache modules and stuff like that. But it’s the language of last resort. We use Java and Python a lot, too, though there are more lines of Common Lisp than anything else.