A while back (around August), I decided to try to learn Common Lisp in earnest. I had decided quite early on this year to learn a Lisp, and got started on 99 Lisp Problems after picking Common Lisp (and SBCL) as my weapon of choice. This was ok to start with, but the problems are quite dull, especially after a few dozen.
So I started reading Land of Lisp to come at the language from another angle. It’s a nice book, certainly, and writing text adventures a la Zork is how I taught myself BASIC back when I was seven. But if I could have written a Tetris or a Super Mario back then, I would have. In fact, I did, as soon as I learned a bit more BASIC, because it wasn’t too difficult to write games back then. This is where I started really challenging myself.
Having picked up the (incredibly minimal) syntax of Lisp, set up Vim with Slimv, discovered QuickLisp and downloaded a copy of the Common Lisp HyperSpec for reference, I ventured into the sparsely documented realm of writing real games in Lisp.
What I found was often frustrating, since my chosen game library, SDL, although supported by a Lisp wrapper from Lispbuilder, required some jiggery-pokery with recompiling SBCL and cocoahelper to make it work on OSX. But eventually, I had some simple sprites in a window with good old WASD keyboard controls. Things were starting to get interesting.
Around about this time, I read a post on Hacker News about refactoring a game written in Python which I disagreed with so vehemently that I started refactoring the refactored code with the intention of posting a corrective response. But as I worked on it, I realised I could translate the game into Lisp as a more useful learning exercise. The result was ASTeroids, which ironically made it onto the front page of HN anyway, presumably because it’s quite perverse to write games in Lisp. Not that ASTeroids is particularly good or even Lisp-y Lisp code.
Now I’ve started experimenting with writing web applications in Lisp, using ningle, which is a very concise Lisp web framework that reminds me of Flask in Python or Sinatra in Ruby. Using Slimv (or SLIME on Emacs) allows you to connect to the Lisp process running the web app and modify the app as it runs, which I like so much it makes me wish I could use Lisp for work!
I think I’m a long way from being a fully fledged Lisp hacker, but I certainly feel comfortable with the language now.
One thing I’ve noticed from the way I’ve learned Lisp is that solving exercises and learning by rote doesn’t seem to work for me beyond a fairly basic level. To really get a feel for a programming language, I think you need to have a problem you want to solve and just experiment and explore for yourself.
Next up, Clojure!