Skip to content

Quick start

This page is a fast tour. Each section links to a deeper reference.

int age = 25
float rate = 1.5
bool active = true
string name = "Pluvial"
auto count = 10 # inferred as int
auto title = "Rain" # inferred as string

The initializer is required, and with an explicit type it must match exactly. auto infers the type and then fixes it permanently — auto is not dynamic. See Variables.

The base types are int, float, bool, string, and auto. Any base type can be made nullable with ? (int?, string?). The compound types are array<T>, map<K,V>, tuples like (int, string), user-defined structs and enums, and Result<T> / Result<T, E>.

array<int> nums = [1, 2, 3]
map<string, int> ages = {"alice": 30, "bob": 25}
auto pair = (1, "hello") # a tuple

There are no implicit conversions — int + float is a compile error. See Types.

def add(int a, int b) int {
return a + b
}
def greet(string name) { # no return type → no value returned
println("hi " + name)
}

Functions support default arguments and named arguments, and functions are first-class values: you can store lambdas in variables, pass them as arguments, and return them. See Functions.

if (x > 0) {
println("positive")
} else {
println("non-positive")
}
for item in nums {
println(item)
}
while (count > 0) {
count -= 1
}
match status {
200 => { println("ok") }
_ => { println("other") }
}

Conditions must be bool; braces are mandatory. See Control flow.

Fallible operations return a Result<T>. You must narrow it with is ok / is err before reading .value or .error:

Result<int> r = to_int("42")
if (r is ok) {
println(r.value) # 42
} else {
println(r.error)
}

See Error handling.

struct Point {
int x
int y
def translate(int dx, int dy) Point {
return Point { x: self.x + dx, y: self.y + dy }
}
}
Point p = Point { x: 1, y: 2 }
Point q = p.translate(3, 4)

Structs have value semantics — assignment copies. See Structs.

import "math" # then math.add(1, 2)
from "shapes" import Point, origin # bind names directly
import std.math # standard-library shorthand

See Modules.

Import modules under std/:

from std.io import read_file
from std.http import get
from std.time import now

See the Standard library overview.