Language Basics

Variables

Sailfin uses let for bindings. Variables are immutable by default:

let name = "Sailfin";      // immutable
let mut count = 0;          // mutable
count = count + 1;          // OK
// name = "Other";          // ERROR: immutable binding

Primitive Types

TypeDescriptionExample
Int64-bit signed integer42
Float64-bit floating point3.14
BoolBooleantrue, false
StringUTF-8 string"hello"
ByteUnsigned byte0xFF

String Interpolation

Sailfin uses double-brace interpolation:

let name = "world";
let greeting = "Hello, {{name}}!";     // "Hello, world!"
let math = "2 + 2 = {{2 + 2}}";       // "2 + 2 = 4"

Control Flow

If / Else

if temperature > 100 {
    print.warn("Too hot!");
} else if temperature < 0 {
    print.warn("Too cold!");
} else {
    print.info("Just right.");
}

Match

match status {
    "active" => activate(),
    "paused" => pause(),
    "stopped" => stop(),
    _ => print.warn("Unknown status: {{status}}"),
}

Loops

// For loop
for item in items {
    process(item);
}

// Loop with break
loop {
    let event = poll();
    if event.is_done() {
        break;
    }
}

Collections

// Arrays
let numbers: Array<Int> = [1, 2, 3, 4, 5];
let first = numbers[0];

// Vectors (growable)
let mut items = Vec.new();
items.push("alpha");
items.push("beta");

Next Steps