Thursday, May 19, 2005


I wish I'd said that.

From Marginilia, a quote that sums up my feelings pretty well.

There are still things to learn about Java, too, and I’m sure there are many smart people working on it, but here is the difference: studying Lisp is like peeking behind the curtain and mastering the secrets of the universe, whereas studying Java is like learning how fix your old truck — lots of particulars but not much theory.


So what is a closure?

For the Java and other imperative language users, here is a good explanation of what closures are. Read the sections titled "We're no longer in Kansas" and "Does a Fence Keep things in or out?".

Tuesday, May 17, 2005


What brought me to Lisp

Since the main emphasis of my writings will be about my explorations in and around Lisp, I thought I'd start with how I came to Lisp. This is an abreviated version of what's here.

A few years back I started looking into functional programming, and started with Haskell, a pure functional language. This is fine for learning the basic concepts of functional programming, but imperative is better for some things, mainly I/O. Haskell's monads made my head hurt. Sometimes you just want to print something out or access a database without getting a PhD.

This led to OCaml, which seemed to have most of what I wanted. Functional, but not obsessively so (you can printf when you want to). Good execution speed. Support for objects. I read a lot of literature about functional programming vs. object-oriented programming and came to the conclusion that both have their uses so I wanted a language that had both. I started writing some simple OCaml programs as I was learning the language and I liked the way they came out, no having to declare variable types, first-class functions, etc. Then I got farther along in my studies, learning more about how objects and classes are used in OCaml. I started looking at how they handled the FP vs. OOP tension, namely adding functions to a existing class/module vs. adding classes and subclasses, and they started talking about parameterized classes and abstract modules and the syntax started getting more and more complicated.

In Common Lisp, the FP/OOP tension is handled with multimethods - much simpler. Metaprogramming in Common Lisp is done with defmacro, backquote and comma and is done in place, where in OCaml you need a separate preprocessor and a syntax that's rather different than the syntax of the language itself.

I would say that OCaml and Lisp give you much the same power to do things, but my experience is that while doing the simple stuff may be simpler in OCaml than in Lisp, doing the complicated stuff is simpler in Lisp than in OCaml, and I plan on doing a lot more of the complicated stuff than the simple stuff.

I don't want to expend my brainpower wrestling with my programming language, I want to expend it solving problems, and with Lisp I don't wrestle the language. Although some say Common Lisp is a 'big' language, it's basically just parentheses and keywords.

If you think the prefix arithmetic is hard, well it can be, but how often do you put the Pythagorean theorem in your code, vs. just making a function call with parameters? Is foo(bar) that much easier than (foo bar)?

Oh, and about the parentheses? Get a parenthesis-matching editor, and get over it.

This page is powered by Blogger. Isn't yours?