A shell where talking to
the network is grammar.
Mix is an ARexx-inspired, Bus-native shell and scripting language, written in pure Rust. It is one language for one-off glue, daily shell work, long-running services and the behaviour of every MixViu app. Every runnable example below was executed by mix 0.119.0 when this page was built on 2026-11-27; the output you see is real.
Read this first.
Every variable wears a $. Strings join with ... Statements end at a newline or ;. Blocks close with end. Results come back as structured maps, not string soup.
"hi ${name}"interpolates; a bare$nameinside quotes is literal text.ifis an expression:$x = if $ok then "yes" else "no" end.- Lambdas are terse:
fn($x) = $x * $x. -- commentsrun to the end of the line.
-- Values are structured: lists and maps, not text to re-parse.
$engines = ["mix", "mixd", "viud", "viu"]
print(map($engines, fn($e) = upper($e)))
$disk = {mount: "/", free_gb: 412, used_pct: 37}
if $disk.used_pct < 80 then
print("plenty of room: " .. $disk.free_gb .. " GB free on " .. $disk.mount)
end[MIX, MIXD, VIUD, VIU]
plenty of room: 412 GB free on /Text soup, or structured values
The same small job, two ways: find the busy hosts in a list and print them as JSON.
printf '%s\n' "web1 web 0.42" "mail1 mail 1.87" \
"db1 data 2.31" "edge1 proxy 0.08" \
| sort -k3 -n \
| tee /dev/stderr \
| awk '$3 > 1.5 {print $1}' \
| jq -R . | jq -sc .
# three tools, three syntaxes, and every field is
# a position in a line of text-- Filter, sort and encode without awk, jq or a second language.
$hosts = [
{name: "web1", role: "web", load: 0.42},
{name: "mail1", role: "mail", load: 1.87},
{name: "db1", role: "data", load: 2.31},
{name: "edge1", role: "proxy", load: 0.08}
]
for $h in sort_by($hosts, fn($h) = $h.load)
print($h.name .. " (" .. $h.role .. ") load " .. $h.load)
end
$busy = filter($hosts, fn($h) = $h.load > 1.5)
print(json_encode(map($busy, fn($h) = $h.name)))edge1 (proxy) load 0.08
web1 (web) load 0.42
mail1 (mail) load 1.87
db1 (data) load 2.31
["mail1","db1"]Run programs without quoting games.
External programs run from an argv list. There is no word splitting to defend against, and the result is a map with the exit code, both output streams, timing and whether it timed out.
run_argvreturns the result;run_argv_mustraises a coded error on failure.ssh_mix(host, source, {bindings})runs Mix on another machine, with values passed as data, not spliced into text.
-- Programs run by argv: no quoting games, and the result is a map.
$r = run_argv(["echo", "hello from a real process"])
print("exit code: " .. $r.exit_code)
print("stdout: " .. trim($r.stdout))
print("keys: " .. join(sort(keys($r)), ", "))exit code: 0
stdout: hello from a real process
keys: duration_ms, error, error_code, exit_code, interrupted, ok, signal, stderr, stderr_truncated, stdout, stdout_truncated, timed_out, utf8_lossyFail closed, with a code.
raise(CODE, message) stops with a machine-readable code. try … catch $msg, $err gets the message and the code. Scripts and agents act on codes; people read the message.
-- Fail closed, with a code a script or an agent can act on.
fn parse_port($s)
$n = to_number($s)
if $n == nil or $n < 1 or $n > 65535 then
raise("BAD_PORT", "not a port: " .. $s)
end
return $n
end
try
parse_port("http")
catch $msg, $err
print("refused: " .. $err.code .. " (" .. $msg .. ")")
end
print("ok: " .. parse_port("8443"))refused: BAD_PORT (not a port: http)
ok: 8443send, emit, on, reply
Messaging is part of the language, not a library. send makes a call and fills $reply and $rc. on declares a handler. Run a file with mix --serve and it becomes a supervised Bus citizen, with reconnects and the standard commands handled for you. With no Bus present, send sets $rc to -3 and the script carries on.
-- greeter.mix: run it with `mix --serve greeter.mix`.
-- One `on` handler is a complete Bus service. HELP, INFO and QUIT
-- come free from the runtime, and HELP lists this command and its desc.
on greeter.hello desc "Say hello to someone"
$who = $event.body.name ?? "world"
reply({greeting: "hello, " .. $who})
end-- Any script, any agent, the same one line: `send owner verb`.
send greeter greeter.hello body={name: "Ada"}
print($reply.greeting) -- hello, Ada
-- Ask an app what it can do, then do it. Menus, keys and agents
-- all end in this same execute call.
send dopus dopus.actions
print(len($reply) .. " actions on offer")
send dopus dopus.execute body={id: "view.refresh", params: {}}
print("rc " .. $rc) -- 0 delivered and acceptedFrom the Amiga to the agent era.
ARexx (1987) gave every AmigaOS application a named, addressable message port, and one script could orchestrate all of them. Mix updates that model for networks of machines and Rust services.
An early sketch of the same role ran on Lua. It was removed once the pure-Rust interpreter caught up, and Mix has held the role alone since. The history page has the whole story.
The binary is the manual.
The source lives in the public repository: engines/mix, libraries/mix and libraries/mix-shell.