Luma and AI: Friendly to Machines, Beautiful for People
Programming is changing faster than ever. AI models answer questions, read documents, write code and call tools. More and more of the programs we build talk to an AI model somewhere, and more and more code is written together with one.
A language made today has to take this seriously. So we’re saying it clearly: AI support is one of Luma’s main focus areas for the future.
But there’s a second half to this story, and it matters just as much to us. While AI writes more code, something is getting lost: the quiet pleasure of writing a program yourself, understanding every line, and being proud of how it reads. Luma wants to bring that back.
Friendly to machines, beautiful for people. That’s the goal. Here’s how we’re working toward both.
AI built in from the start
In Luma 0.2.0, talking to an AI model is as easy as reading a file. The AI features come as mods, ordinary Luma files you get with luma get and import, written in Luma itself, so you can read exactly how they work.
Ask a model
import "claude"
ai: claude.client = claude.connect()
print(ai.ask("In one sentence: what is a monad?"))The same methods work with OpenAI and with nearly every other provider that speaks its API, and with Ollama or a local server on your own computer. Change one line to switch models; the rest of your program stays the same.
Get data, not just text
The most useful AI answers aren’t prose. They’re data your program can use. In Luma, you describe the data as an ordinary obj, and the model’s answer fills it:
import "claude"
// A support ticket, read from an email.
obj Ticket {
customer: str // the customer's name
product: str // which product it is about
urgent: bool // true if the customer can't work
summary: str // the problem in one sentence
}
ai: claude.client = claude.connect()
email: str = file("email.txt").read()
t: Ticket = convert(ai.extract("Read this support email:\n\n${email}", schema(Ticket)))
if t.urgent {
print("Call ${t.customer} now: ${t.summary}")
}schema(Ticket) turns the type into the description the model needs, and here’s the nice part: your comments become the instructions. The // the customer's name you’d write anyway for the next person reading your code is exactly what tells the model what to put in that field. Good code and a good prompt turn out to be the same thing.
Give the model tools
A tool is just a Luma function that the model may call when it needs to:
// A city's weather.
obj Weather {
city: str // the city's name, e.g. Tartu
}
ai.tool("weather", "Call this when the user asks about the weather in a city", schema(Weather), fn(input: json): str {
w: Weather = convert(input)
return lookup(w.city)
})
print(ai.ask("Do I need an umbrella in Tartu today?"))Luma runs the calls, sends back the results, and gives you the final answer. For tools that can’t be undone, such as deleting, paying or sending, you can ask for approval before each call.
Work with AI assistants: MCP
With the mcp mod, a Luma program becomes an MCP server: AI assistants such as Claude Code and Claude Desktop can call your Luma functions as tools. A few lines turn any Luma program into something an assistant can use. Luma can be an MCP client too, using tools other servers offer.
Search by meaning
Luma has a vec type in the language itself, fast in both modes, and mods for turning texts into vectors and searching them. That’s the base for RAG: finding the parts of your own documents that answer a question and giving them to the model.
Run a model yourself
This is the one we’re most excited about. The llama mod runs a model file, the same GGUF files that llama.cpp and Ollama use, in Luma itself. Nothing to install, no server, and nothing leaves your computer:
import "llama"
ai: llama.model = llama.open(file("qwen2.5-0.5b-instruct-q4_k_m.gguf"))
ai.stream("Write a haiku about the sea.", fn(part: str) {
stdout.write(part)
})It reads Llama, Mistral and Qwen models, spreads the work over your processor’s cores, can force the answer to fit a schema, and supports tools. Build it with luma build, and you have a single program that carries its own AI, ready to copy to a computer with no internet.
A language AI can write well
Being AI friendly isn’t only about calling models. More and more code is written with an AI assistant, and some languages are much easier for AI to get right than others. Luma’s design helps here, almost by accident:
- A small language. Fewer features and fewer ways to say the same thing means less to guess and fewer mistakes. There’s one
convert, one way to loop over things, one way to handle errors. - Everything is visible. Types are written out, missing values are explicit, errors are caught where you can see them. An AI, like a person, does best when nothing is hidden.
- Errors that explain the fix. Luma’s compile errors say what’s wrong and, where they can, what to write instead. An assistant reads that message and corrects its own code.
- A manual for the exact version.
luma docgives an assistant precise, tested documentation for the compiler that’s actually installed. No guessing from old versions on the web. - Tests built in. With
assertandluma test, AI-written code can be checked straight away, in both modes.
Bringing back the beauty of writing code yourself
And now the other half.
We don’t think the future is people only reading what AI writes. We think the best programs will still be shaped by people who understand them. For that, the code has to be a pleasure to read and to write.
That’s always been Luma’s heart, and 0.2.0 makes it stronger:
- Code that reads like a sentence.
nums.walk(n) { ... },if email != nil,t.urgent. You can read a Luma program aloud. - One rule everywhere. A variable is
name: type, a parameter isname: type, a function isname(...): type. Learn it once. - No ceremony. No boilerplate, no setup files, no build configuration. A file and
luma runis a whole project. - Small enough to hold in your head. When you know the whole language, you write with confidence instead of searching.
Look again at the ticket example above. It reads an email, asks an AI model to understand it, and acts on the answer, and every line is something you could write yourself, explain to a colleague, or teach in a class. That’s the balance we want: AI does the heavy lifting, and the code stays yours.
Where we go from here
AI support will keep growing in Luma, step by step, the same careful way as everything else: designed first, tested in both modes, documented in the manual. The core stays small; the AI features live in mods you can read and change.
And through it all, we’ll keep asking the same question about every new feature: is this still beautiful to write by hand?
If the answer is no, it isn’t Luma yet.