Fennel Functional/Lisp Programming Language Template! (Updated 2026-10-20)
Ever wanted to write a Picotron cart in a functional programming language supported by lua?
This cart include the Fennel bootstrap compiler and was taken on 2025/11/02, any additions or updates to the language post that date will not be present til the cart is updated again.
Credit to @abledbody for the quick sort algo and @kimiyoribaka for making it work like table sort.
Update 19-10-26:
Improve the compilation time so running a fennel cart is imperceptible in terms of performance from a normal cart.
Spruced up the metadata a bit.
Update 20-10-26:
Further example code.
Added a init function due to the global _init being used to compile the fennel code.
Update 05-11-26:
Added support for multiple files, e.g. any fennel file within the cart will be picked up and compiled as if its part of a single file (similar to how the require works in normal lua, but automatic)
I'm so glad you tagged me! Now I can tell you oh god please don't use that algorithm. Picotron actually does have a native sorting function, but it's part of userdata. ud:sort(column) is orders of magnitude faster than my quick sort. If you put your compared values in one column and their respective indices in the other, you can call it and get a list of indices which you can use to pull values out of the original in the correct order. Granted, I don't think there's any way to represent table.sort's comparison function like this, but it's such a world of difference that I think it would be worth it to at least make it as a fast path.
@abledbody Thank you for this! Not currently sure what to do with it as I need to support the comparison function, otherwise I'll have a hard time getting the fennel bootstrapper working, but I'll look into it and hopefully find a solution that supports the ud:sort() as well as the comp function input.
Appreciate the input though, will try and update later today!
Updated this just now, nothing of actual note bar a performance optimisation I missed when creating this cart.
Updated to include further example code and added an init function that can be added to instead of the overrided global _init used to compile the fennel code.
Updated to compile all fnl files within the cart so you can split up the logic over more than just main! (Should have been included to start with but at least its there now)
[Please log in to post a comment]




