↩ go back to index

Deploying Common Lisp Programs?

October 10, 2024

I have a handful of Lisp programs running on a personal server, as well as some scripts on my desktop computer; and it's gotten me curious how people typically deploy Common Lisp programs.

This is mostly written from the context of a FOSS project, or I suppose a proprietary project that's only used internally so source code is available.

As far as I can see, these are the main four options:

1. Build a fully standalone executable

2. Build an image that can be loaded

3. Use ASDF `monolithic-bundle-op` to make one big FASL that can be loaded

4. Load the ASDF system and execute the entry point, relying on ASDF to efficiently load FASL files from a cache directory

Obviously the first is the best if you're distributing the binary to arbitrary people and don't want to expect them to install Lisp, but what about deploying on a machine you control and can install what you want on? And which option do people typically use in practice?

My thoughts for each option:

1. The executables will keep working essentially indefinitely but it means you have a bunch of superfluous copies of the Lisp implementation hanging around, possibly all different versions, and you have to remember to manually rebuild all the executables if you want to keep the bundled Lisp versions up to date. This is the fastest to start up too (if you don't use core compression), important for things like CLI utilities or I guess something like old-school CGI programs.

2. You don't have a bunch of copies of the implementation hanging around but you still get the fast startup time, but now you *have* to remember to manually rebuild all the images or they'll stop working after updating the system's Lisp.

3. Same situation to the second in terms of keeping them up-to-date. The only use-case I can think of for this over a normal image is if you need to load the FASL into an already running image (possibly as some sort of plugin or something?), but here I've been assuming the goal is to just need to load and run a single comprehensive image in which case a FASL seems to have no benefit.

4. The slowest but the most convenient in terms of keeping everything up-to-date, since ASDF automatically rebuilds the cached FASLs if the Lisp implementation changes. Deployment is also the easiest with this, because you can just keep a local copy of the repository and `git pull`, and ASDF will automatically recompile the changed source files next time the system is loaded.

Options 2–4 also expect you to write a wrapper script if you want a convenient single command to invoke, but a minor point.

Alternately:

5. Just load code and expect that it'll be loaded from source every time. Seems to work fine for the Python ecosystem; although probably not a good example because Python is not exactly known for any sort of speed lol. (Yes there's byte-compiled Python files but AFAIK typically only libraries installed from Pip get byte-compiled, very rare for normal code run from a source directory.)

↩ go back to index

also available on the web

contact via email: alex [at] nytpu.com

or through anywhere else I'm at

backlinks

-- Copyright © 2024 nytpu - CC BY-SA 4.0


Source