For a while, I'd been working on cloning twitter in Lisp, since I'd been playing with Lisp web frameworks (weblocks, hunchentoot, caveman, clack) for a while. Now that I know so much more about web development, it seemed like a perfect chance. Also, with hunchensocket around, I could do push notifications with websockets, too, which Rails can't without third party services.

I have a site up now, at Chirp, after many hours of beating my head against the wall. I thought I'd write down some major points for others who try to sort the madness out.


  1. Your app will be compiled, don't expect it to behave like you're running it from the REPL.

    I had my configuration defined using envy's (defconfig) in the top level of a file. That meant that all of the configurations were defined at compile time, when the environment variables I was using weren't defined. So, I had a few nil's in my configurations.

    Now, I wrap the (defconfig)'s in a function call when the app starts up. Works like a charm.

  2. You don't own the database, you just get to use it.

    CLSQL doesn't have permission do do a number of things you might have been doing on your own database server. I had a helper function that made the database and tables if they didn't exist. I got a lot of complaining about "template1," which seems to be some internal postgres thing that administrators get access to. Don't use (clsql:probe-database) or (clsql:create-database), they both try to do things they're not allowed to.

  3. Getting environment variables is a necessary evil.

    Environment variables are not a first-class part of the lisp world, but they're not too hard to get to. Heroku uses a lot of them to show you your configuration, pay special attention to PORT and DATABASE_URL.

    You can get at these two ways. ASDF has a private (getenv) function, which is handy and generally available. If you're using SBCL, you can also (require 'sb-posix) and use (sb-posix:getenv). It has a sibling, (sb-posix:setenv), should you need it.


Hopefully, we'll make a better, more user-friendly buildpack, soon.