Your first program
A Brass file is a program. Statements at the top level run from top to bottom, so the smallest program is one line:
print("Hello, Brass")Hello, BrassSave it as hello.brass and run it:
brass run hello.brass # compile and runbrass build hello.brass -o hello --release # a native executablebrass check hello.brass # only check for errorsbrass fmt hello.brass # format the file in placeBrass compiles to C, and the C compiler makes the executable. There is no runtime to install next to it and no garbage collector.
No comments, but reasons
Section titled “No comments, but reasons”Brass has no comments. When code needs an explanation, write why in a
because line right above it. The compiler keeps these lines, the
documentation shows them, and they cannot drift away from the code they
belong to the way a stray comment can.
let prices = [120, 80, 150]let mut total = 0for p in prices { total += p}because shipping is free from 400 onlet shipping = if total >= 400 { 0 } else { 25 }print(f"total {total + shipping}")total 375Unfinished work gets a date: todo(2027-01-31) handle refunds. After that
day the compiler warns, and brass check --strict turns it into an error.
What to read next
Section titled “What to read next”The next pages go through the language in order: values, control flow, functions, your own types, ownership, errors, collections, modules and tests, concurrency, and permissions. Each page is short and every example on it is compiled and run as part of Brass’s test suite.