Documentation
Luma documentation
Luma is a small programming language with its own compiler. It’s designed to be easy to read and easy to understand completely.
Every Luma program can be run two ways:
- Interpreted:
luma run hello.lumaruns the program straight away. - Compiled:
luma build hello.lumaproduces a small native executable for Linux or Windows that runs on its own.
Both ways behave the same and print the same output.
name: str = "Luma"
version: int = 1
if version > 0 {
print("Hello from")
print(name)
}Output:
Hello from
LumaThe language at a glance
| Feature | Example |
|---|---|
| Comment | // to the end of the line (no /* */) |
| Declare a variable | count: int = 0 |
| Assign | count = count + 1 |
| Types | int float byte bool str error file json [int] {str: int} {str}, and your own obj types |
| Interpolation | "Hello ${name}, you are ${age + 1}" |
| Arithmetic | + - * / % |
| Comparison | == != < <= > >= |
| Logic | && || ! |
| Decision | if x > 0 { ... } else if x < 0 { ... } else { ... } |
| List | nums: [int] = [1, 2, 3] |
| List access | nums[0], nums[0] = 5, nums[] = 4 (append) |
| Map | ages: {str: int} = {"Alice": 30} |
| Map access | ages["Alice"], ages["Bob"] = 25, has(ages, "Bob") |
| Set | names: {str} = {"Alice", "Bob"}, names[] = "Carol" (add) |
| Loop | nums.walk(n) { ... }, ages.walk(name, age) { ... }, skip, stop |
| Error handling | try err { ... }, throw error(100, "message"), err.code, err.message |
| Input | name: str = prompt("Name: "), age: int = prompt("Age: ") |
| Flags | port: int = flag("port", 8080), then ./app --port=9000 |
| Files | notes: file = file("notes.txt"), notes.write(text), lines: [str] = notes.read(), notes.add(line) |
| Text | s.upper(), s.trim(), s.split(","), s.replace(a, b), s.part(0, 3), words.join(" "), len(s) |
| JSON | config: json = convert(text), port: int = convert(config["port"]), user: json = {"name": "Ann", "age": 30} |
| Conversion | n: int = convert("42"), s: str = convert(n): the target type decides |
| Memory | automatic; free(x) ends a variable early |
| Built-in functions | print(x), prompt(text), flag(name, default), file(path), free(x), len(x), remove(x, i), has(x, k), error(code, msg) |
| Function | fn greet(name: str): str { return "Hi ${name}" } |
| Imports | import "lib/text", text.upper(s), (import "lib/text").upper(s), pub fn ... |
| Locked value | lock PI: float = 3.14 (fixed when compiling, usable in functions) |
| Objects | obj Point { x: int = 0 fn move(d: int) { self.x = self.x + d } }, p: Point = Point { x: 1 }, p.move(2) |
| Reserved words | if, else, try, throw, skip, stop, fn, return, import, pub, lock, obj (only these twelve) |
Sections
Install Luma, run your first program, and set up your editor.
How a Luma program is written: values, types, variables and operators.
Working with text, and with groups of values: lists, maps and sets.
Making decisions, repeating things, and handling what goes wrong.
Functions, your own types, traits, and programs of several files.
What a program needs around it: input, flags, files, time, tests and more.
Reading and writing data: JSON, bytes, hashes, HTML, tables and archives.
Web requests, web servers, TCP connections and gRPC.
SQLite, PostgreSQL and MySQL through one database layer.
AI models, tools, MCP, search by meaning, and models run by Luma itself.
Every built-in function, every error, and what Luma doesn’t have yet.
Common errors, surprises, and tips for coming from other languages.
Ways to help Luma grow.
What Luma stands for, where it’s going, and its license.