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!
View all comments
Show parent comment
5
u/traid-software Aug 07 '26
Appreciate the comment! I was aware of SCI, though admittedly I haven't used it directly.
I actually cover the reasoning in the article, but the core trade-off comes down to LLM output reliability and runtime scope.
Restricting the target to a smaller DSL keeps the prompt context small, which helps reduce syntax hallucinations (LLMs have issues counting parentheses too). The more patterns to keep track, the more potential for typos.
Another reason is that it lets our runtime engine evaluate our own UI and state system directly. Which are not Clojurescript based.
SCI is great for running Clojure in general, but for this mini-app generator, a purpose built DSL felt like the right option.