Learn · 01

What is Ochre?

An introduction to Ochre — a statically typed, general-purpose programming language written in Rust with Copy-on-Write safety, colorless concurrency, and Cranelift native compilation.

Ochre (.och) is a statically typed, general-purpose programming language written in Rust. It is designed to combine the approachable, low-ceremony ergonomics of TypeScript and Go with the compile-time safety guarantees of Rust — packaged inside a single self-contained binary.

What Makes Ochre Different

Most languages force an early trade-off between fast iteration, static safety, and predictable runtime behavior:

  • No null, no uncaught exceptions: Optionality is modeled with T? (Some(v) / None), and fallible operations return T!E (Ok(v) / Err(e)). You propagate errors with ? or provide defaults with ??.
  • Deep immutability + Copy-on-Write (let vs var): Bindings are immutable by default. Mutable var collections use thread-safe Copy-on-Write (Arc) value semantics, so aliased snapshots never mutate unexpectedly — without needing lifetime annotations.
  • Colorless concurrency: Spawn parallel work with spawn { ... } and exchange typed messages over Channel<T> without splitting your codebase into async and non-async functions.
  • One binary, complete toolchain: ochre ships with the bytecode VM, Cranelift AOT compiler (ochre build), formatter (ochre fmt), test runner (ochre test), project scaffolder (ochre init), REPL (ochre repl), and Language Server (ochre lsp).

A Quick Taste of Ochre

Run this interactive example right in your browser using Ochre's WebAssembly runtime:

struct TaskItem {
    title: Str,
    done: Bool,
}

impl TaskItem {
    fn label(self) -> Str {
        let icon = if self.done { "✓" } else { "○" }
        return "{icon} {self.title}"
    }
}

fn main() {
    let tasks = [
        TaskItem { title: "Learn Ochre syntax", done: true },
        TaskItem { title: "Build a JSON API", done: false },
    ]
    for item in tasks {
        println(item.label())
    }
}

Expected Output

✓ Learn Ochre syntax
○ Build a JSON API

How This Documentation Is Organized

AreaBest For
LearnReading chapter-by-chapter to build a mental model of Ochre from scratch.
GuidesBuilding complete CLI tools, JSON REST APIs, concurrent workers, and native binaries.
ReferenceLooking up exact syntax, operators, built-ins, CLI flags, and diagnostics.
InternalsUnderstanding how Ochre's compiler, bytecode VM, CoW memory, and Cranelift backend work.

Exercise

Modify the runnable example above to add a third TaskItem with done: true and print the total number of tasks using len(tasks).

Show Solution
struct TaskItem {
    title: Str,
    done: Bool,
}

impl TaskItem {
    fn label(self) -> Str {
        let icon = if self.done { "✓" } else { "○" }
        return "{icon} {self.title}"
    }
}

fn main() {
    let tasks = [
        TaskItem { title: "Learn Ochre syntax", done: true },
        TaskItem { title: "Build a JSON API", done: false },
        TaskItem { title: "Write unit tests", done: true },
    ]
    for item in tasks {
        println(item.label())
    }
    println("Total tasks: {len(tasks)}")
}