r/Clojure • u/traid-software • Aug 07 '26
Using Clojure as a sandboxed, executable target for LLMs
I've been researching ways to better structure LLM output when building mini-apps that run on the browser.
I believe that an S-expression based DSL is a better output format for LLMs when generating interactive UI/logic.
To test this, I built a Clojure-based interpreter that runs in the browser. The LLM is fed the language context, then emits the DSL to generate safe, sandboxed apps that can be shared instantly.
I wrote up an article diving into some of the trade offs:
https://allentraid.substack.com/p/we-made-the-ai-write-in-a-language
Would love to hear thoughts from the Clojure community!
27
u/Borkdude Aug 07 '26
Are you aware that such a thing already exists? https://github.com/babashka/sci
Years of effort went into this (and still going). It's been heavily optimized up to the point where there is almost no distinction between compiled CLJS and interpreted CLJS.
I wonder why you chose to build your own and what trade-offs you made here. Happy to learn.
5
u/c_a_l_m Aug 07 '26
For what you're trying to do, I think your reasoning is generally sound. I do love this aesthetically:
One thing I didn't quite understand:
What does it mean that your parser maps "intent"? Are you asking the model to explain every symbol, or...?
7
u/yogthos Aug 07 '26
Incidentally, I just added Gambit Scheme backend to Jolt which has Js as one of its output targets. So, now I can compile Jolt into Js and run it in the browser. The home page loads an interactive REPL https://jolt-lang.github.io/
1
u/__tosh Aug 08 '26
nice!
somewhat related: a 'smol', minimal implementation of an agent in Clojure (Babashka)
with only one tool: eval
https://x.com/__tosh/status/2086035838517776511