Quick Start
Hello World
Section titled “Hello World”Start the REPL:
cargo run -- --replnulang> perform IO.print("Hello, Nulang!")Hello, Nulang!Or evaluate from the command line:
cargo run -- --eval 'perform IO.print("Hello, Nulang!")'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, age } if age < 18 => name + " is young", { name, age } => name + " is " + Int.to_string(age) }}
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(sender: Actor) { send sender reply(self.count) }}
actor Main { behavior run() { let counter = spawn Counter {} in { send counter inc() send counter inc() send counter get(self) } }
behavior reply(value: Int) { perform IO.print("Count is: " + Int.to_string(value)) }}
spawn Main {} in {}Algebraic Effects
Section titled “Algebraic Effects”effect Logger { op log(msg: 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) => { perform IO.print("[LOG] " + msg); resume(()) }}- Dive into Syntax Basics
- Explore the Type System
- Learn about Algebraic Effects
- Build Distributed Actors