your first rune program
By the end you will have evaluated arithmetic, rendered a piece of UI, and seen the same program written two ways. Every command here is real — run them as you read.
build the CLI
The Rust workspace lives in rs/. From the repo root:
For the rest of this tutorial we invoke it with cargo run --bin rune --.
(If you prefer, the built binary is at rs/target/debug/rune.)
step 1 — evaluate an expression
42
eval parses one expression, lowers it to a Nox noun,
and reduces it. There is no build phase between source and result — this is
rune's instant start.
step 2 — render a piece of UI
rune programs can evaluate to a chunk — a unit of terminal UI. Try the
text constructor:
(# t) hello
The (# t) is the chunk's sigil and render kind — here, a text chunk. error
makes an error chunk, and col lays several out in a column:
(# t) a
(! e) =s~tlevel#terror=s~tsource#t =s~tmessage#tb
Two chunks, one per element.
step 3 — emit through an act
The chunks above were the program's value. A program can also emit UI as it runs, through an act — the boundary where pure evaluation asks the host to do something:
(# t) live
emit is performed by the CLI's host as the program runs. In the
cyb terminal the same act renders straight into the screen.
See acts and the ward for the why.
step 4 — the same program, two registers
The 6 * 7 you wrote is the classic register. rune has a second, pure
register. Write the classic form to a file and convert it:
(mul 6 7)
Same AST, same Nox noun — only the spelling differs. --to=rust converts back.
where to go next
- render prysm chunks — the full chunk vocabulary
- two registers, one AST — why both exist
- the specification — the complete model