parens-8, a tiny lisp for your pico-8 carts

Published 2023-06-12

first off, a demo. here's a cart that stores the entirety of its game logic in its sprite sheet:

this is a parens-8 port of an old cart of mine. it has the lua code for the parens-8 language, and then parens-8 code for loading parens-8 game logic from ROM. you can find the full source for the game logic here

parens-8 is a lisp interpreter/compiler designed specifically to bypass the lua token limit.
the idea: use a portion of your cart (between 330 and 900 tokens, depending on your use case) to store the parens-8 interpreter, offload performance noncritical code into strings, and then optionally into ROM.

the parens-8 github repo has detailed instructions on how to achieve this, and how to customize parens-8 to best fit your project.

let's look at an excerpt of the original lua code for baloonbomber:

and here is the corresponding parens-8 implementation:

the syntax may seem hostile, but the semantics are very much similar to that of lua. you may even identify common pico-8 patterns like using split or remapping _ENV.

parens-8 comes with a pretty significant performance overhead (see github repo for benchmarks), so while calls to the pico-8 api and lua functions are unaffected, tight loops and the like are dramatically slower in parens-8. make sure you minimize the cpu time spent in parens-8 code.

things you could probably offload as parens-8 code:

things you definitely shouldn't write in parens-8:

baloonbomber - parens-8 edition is the answer to the question "can I offload my entire game to ROM":
yes, but you probably shouldn't.