Language tour
This tour is a quick, practical overview of mu’s core syntax and semantics.
Hello, mu
fn main() {
println("Hello World!")
}
main()
Variables and control flow
x := 10
if x > 5 {
println("x is big")
} else {
println("x is small")
}
i := 0
while i < 3 {
println(i)
i = i + 1
}
Functions and closures
fn make_counter() {
n := 0
return fn() {
n = n + 1
return n
}
}
counter := make_counter()
println(counter())
println(counter())
Lists and maps
nums := [1, 2, 3]
nums[1] = 42
println(nums)
user := {"name": "ada", "age": 42}
println(user.name)
Errors are values
data := read("missing.txt")
if type(data) == "ERROR" {
println("read failed:", data)
}
Truthiness
Falsey values include false, nil, 0, empty strings, empty lists/maps, and empty buffers.
status := if "" { "truthy" } else { "falsey" }
println(status)
Next steps
- Learn the execution model in the runtime guide.
- Explore the standard library.
- Read the specification for exact semantics.