December 2, 2011

Common Lisp, Web framework, VPS, OSX issues

Goal: 
Develop web apps using common lisp with a web framework in Linux environment.

Environment:
Development environment is OSX 10.6 Snow leopard.  Target environment is Ubuntu 10.10 server running on OpenVZ with very small configuration, provided by VPS hosting service.

Issues:
Two widely used common lisp web frameworks: (1) weblocks, (2) hunchentoot.  (Use quicklisp to install them.)  They both require multithreading support.

1. Development side:

OSX's CLISP binary doesn't support multithreading.  I don't want to spend too much time compiling it from scratch just for that.  Tried SBCL, and its binary (macport) does support multithreading.  Good.

2. Target environment side:

Ubuntu's CLISP package supports multithreading.  However, I couldn't install SBCL using apt-get, reporting there's a problem with memory (don't remember the specific message).  It turns out that SBCL requires 8GB memory for its GC.  However, the VPS has only 512MB memory, and no swap.  no SWAP?!  That's right -- openVZ does not give swap.  I could find a VPS hosting service using XEN, but this hosting service's price is very low, and XEN based VPS hosting service companies are charging almost twice of the company I'm getting service from.

So, in development environment, I have to use SBCL, but on the target machine, CLISP must be used.  (Gotta use the same environment!) Some suggested that LISPBOX has Clozure Common LISP and the binary supports multithreading on OSX, therefore use that (lispbox's clozure).  However, on the Ubuntu in my VPS, installing LISPBOX is a bit of hassle -- compiling many things. (It's because the LISPBOX binary available on the web is a bit old, and does not install on my headless Ubuntu 11.04 VPS.)  Also, I selected Ubuntu to minimize any package compilation, and this defeats the purpose.

I do not have to use common lisp and don't want to waste time on setting up environment -- already wasted good amount of time finding all this -- so decided to go with Clojure instead for frontend, and use clisp for the backend, probably.

Conclusion
I hope my findings help other folks and save their time -- clisp issue on OSX, SBCL on virtual machine based using OpenVZ, etc.  And try Clojure.  It's cooler than Scala, IMHO.