Quick Start
Hello World
Section titled “Hello World”Install a checksummed release binary for your platform, or use the browser playground below. You do not need to build the compiler from source for this tutorial.
Run a one-liner:
nulang --eval 'perform IO.print("Hello, Nulang!")'Hello, Nulang!Or start the REPL for an interactive session:
nulang --replYour first local project
Section titled “Your first local project”After installing the compiler, scaffold a project using the bundled nula package manager:
nulang nula new hello-appcd hello-appnulang nula runThe command nulang nula test runs tests discovered under the project’s tests/ directory. Package management and other non-Core operations require the native runtime, not the limited browser playground.
Variables and Functions
Section titled “Variables and Functions”let x = 42let y = x + 8
fn greet(name: String) -> String { "Hello, " + name}
perform IO.print(greet("World"))Records and Pattern Matching
Section titled “Records and Pattern Matching”type Person = { name: String, age: Int }
fn describe(p: Person) -> String { match p { { name: n, age: a } if a < 18 => n + " is young", { name: n, age: a } => n + " is " + perform Int.to_string(a) }}
let alice = { name: "Alice", age: 30 }perform IO.print(describe(alice))Actors — The Heart of Nulang
Section titled “Actors — The Heart of Nulang”actor Counter { state count: Int = 0
behavior inc() { self.count = self.count + 1 }
behavior get() { self.count }}
let c = spawn Counter {} in { ask c inc() ask c inc() ask c get()}Use spawn to create an actor, ask to call a behavior and wait for its return value, and send to fire-and-forget a message (useful in the full runtime where actors process messages concurrently).
Algebraic Effects
Section titled “Algebraic Effects”effect Logger { log: (String) -> Unit}
fn greet_with_log(name: String) { perform Logger.log("Greeting " + name) perform IO.print("Hello, " + name)}
handle greet_with_log("World") { | Logger.log(msg) resume => { perform IO.print("[LOG] " + msg) }}- Dive into Syntax Basics
- Explore the Type System
- Learn about Algebraic Effects
- Build Distributed Actors