(2024-06-01) Lisp Icing Or Cake

David Thompson: Lisp: Icing or Cake? The Spring Lisp Game Jam 2024 ended one week ago. 48 games were submitted. For the first time ever, Guile came out on top with the most submissions! There’s a very specific reason for this outcome. 11 out of the 15 Guile games were built for the web with Hoot, a Scheme-to-WebAssembly compiler that I work on at the Spritely Institute.

The next most popular language, which is typically the most popular language in these jams, is Fennel. Fennel is a Lisp that compiles to Lua.

The patterns I’m about to talk about could sort of be framed as “The Guile Way vs. The Fennel Way”, but I don’t want to do that. It's not an “us vs. them” thing

both patterns are valid

Lisp as icing

The icing pattern is using Lisp as a “scripting” language on top of a cake that is made from C, Rust, and other static languages. The typical way to do this is by embedding a Lisp interpreter into the larger program

Lisp as cake

The cake pattern is using Lisp to implement as much of the software stack as possible. It’s Lisp all the way down... sorta.

You may recognize this as the classic embed vs. extend debate. You’re correct!

I mentioned Guile as an option for icing, but Guile really shines best as cake

Case studies

Let’s take a look at some of the languages and libraries used for the Lisp Game Jam and evaluate their icing/cake-ness.

Fennel + love2d

Guile + Chickadee

This is the stack that I helped build. Chickadee is a game engine library for Guile that implements almost all of the interesting parts in Scheme, including rendering.

Guile + Chickadee is an example of Lisp as cake.

Hoot + HTML5 canvas

I also helped build this one. Hoot is a Scheme-to-WebAssembly compiler.

Hoot is written entirely in Scheme.

Hoot programs can also easily interoperate with JavaScript. Scheme objects can easily be passed to JavaScript, and vice versa, as they are managed in the same heap

Hoot + HTML5 canvas is mostly dense cake with a bit of icing. On one hand, it took a year and significant funding to boot Hoot. We said “no” to emscripten, built our own toolchain, and extended Guile’s compiler. It's Lisp all the way until you hit the browser runtime!

The cake/icing spectrum

I must acknowledge the limitations of the cake approach. We’re not living in a world of Lisp machines, but a world of glorified PDP-11s. Even the tallest of Lisp cakes sits atop an even larger cake made mostly of C. All modern Lisp systems bottom out at some point. Emacs rests on a C core. Guile’s VM is written in C.

Does spending all this time taking the scenic route matter at all, or are we just deluding ourselves because we have fun writing Lisp code?

I think it does matter. Every piece of the stack that can be reclaimed from the likes of C is a small victory. The parts written in Lisp are much easier to hack on, and some of those things become live hackable while our programs are running.

Moving beyond games, we can look to the Guix project as a great example of just how tasty the cake can get.

I’ve been using Guix since the early days, and back then it was easy to make the argument that Guix was just reinventing wheels for no reason. But now, over 10 years later, the insistence on maximizing the usage of Lisp has been key to the success of the project

I'm a cake boy.


Edited:    |       |    Search Twitter for discussion