r/lua • u/aldapsiger • 4h ago
Project Lua is the Best Language for AI Agents
I've spent the past month working on Tuse, an AI agent written in Rust. But the agent itself writes Lua to work with files, run commands, access the network, and so on. Lua is its only tool. Everything goes through it.
You might be surprised that I use Lua for more than just config (obviously, Lua is the best language for that). I have models write Lua for everything. But what about Python and JavaScript? Don't models know those better? Why Lua?
I chose Lua for three reasons:
- Models are good at working with CPython and Node.js, but once you expose your own global functions, the choice of language doesn't make much difference.
- Python and JavaScript have a lot of features, which makes for heavier runtimes. Tuse is designed to run 100 instances on a single machine.
- Lua is simple and flexible, and its AST is much easier to work with.
Those are just the most obvious reasons. I think Lua will become the go-to language for code mode. Today's models write Lua just as well as they write Python, JavaScript, or Go.
If you want to try Tuse: https://github.com/ethanhamilthon/tuse