Lisp Aha! moments

Here are a few things that triggered major Aha! moments for me, in no particular order.

(Source and copyright: http://groups.google.com/group/comp.lang.lisp/browse_thread/thread/a12b2503c989761a/c5318848c215296f#c5318848c215296f)

  • seeing the output of DISASSEMBLE for the first time (it was on a native-compiling Lisp), and the realization that the functionality is part of standard CL
  • reading the source of cl-ppcre, which illustrated:
  • run-time compilation (to chains of closures) without using COMPILE or COMPILE-FILE
  • parsing regular expression strings, with nice error-reporting via conditions
  • that Lisp solutions to practical problems can be concise, comprehensible, and fast
  • reading Keene's CLOS book
  • finding an application of continuable errors; it replaced a convoluted scheme of checking return values at multiple levels with a simple handler-bind wrapper.
  • realizing that file formats and communication protocols are just bits on disk or on a wire or sometimes even in memory, and Lisp is pretty good at generating the right bits and octets; inspired by (among other stuff):
  • learning that CLX is a Lisp program, not a binding to the C xlib
  • learning that Marc's CL-PDF is a Lisp program
  • learning about Frode's binary-types
  • reading Peter's chapters on parsing binary files
  • reading Will Hartung's "Guerilla Lisp Opus"
  • realizing that most Common Lisp implementations are mostly written in Common Lisp

A few themes

  • Despite conceptually understanding how tools like CLOS and closures and conditions work, it took a tricky problem solved neatly by the tool to really make an Aha! moment
  • Aha! moments have made complicated tasks simpler and unapproachable tasks approachable (given the right amount of time and effort). They take the magic out of things. (Philip Greenspun used to say that his course would teach undergrads how to build Amazon in a semester; despite the hyperbole, it really did take the mystery out of how useful web applications can be constructed.)

Advice

  • Be actively curious about how interesting things work ("how can cl-ppcre be faster than Perl?")
  • Be broadly aware of the tools available, and don't worry about immediate application
  • Don't settle for tedium (it's hard to have a breakthrough if you have resigned yourself to something that feels substandard)
  • People who write one interesting thing usually keep it up; find and watch interesting people (trickle-down Aha! effect?)

Minor delights

  • format tricks (~v and ~{~^~} specifically)
  • inspecting a GF object in slime

Slime itself wasn't an aha! moment for me, but ILISP was. The basic revelations for me were that the Lisp system I was interacting with didn't follow the usual cycle of edit, compile+run, test, debug, restart; instead, it was something that had a long life and that accumulated state (in the form of functions and objects), and that gently modifying the state was better than trashing all of it and reloading it from scratch. This isn't something specific SLIME, but SLIME enables it in a very nice way.

(The other nice features like arglist display, inline annotation of compilation notes, the inspector and debugger, etc are great too.)

When I first started using Linux, I accidentally unpacked a nethack tarball in the /dev directory. I had no idea how to see what I had done or how to fix the resulting clutter. So I just reinstalled the system from scratch to get back to a known state. (I would also reinstall when my IP address changed, because I only knew that an installation dialog box prompted for the IP.) This is the same sort of wholesale flushing of state that just isn't necessary if you know how to interrogate your evolving, active system and update it to bring it into the state you need.

I haven't used CLOS's object evolution protocol yet (i.e. update-instance-for-redefined-class, make-instances-obsolete), but the fact that the object system accomodates evolution of state without throwing out progress so far is very encouraging.

---

What are some of the things that triggered your own Aha! moments? What sort of stuff delighted you when you discovered it? What advice would you give people who want to have more Aha! moments?

Zach