The example lab

See the ideas
under pressure.

These are not decorative snippets. They are small programs and semantic tests inside the Ostrin repository, used to validate what the language accepts and rejects.

source programs + verified testscopy and inspect

Browse the catalogue

From hello world to the type system.

Start with the small programs, then look at the examples that exercise generics, traits, pattern matching and the concurrency model.

types / quantities

physics.ostrin

Units, derived dimensions, generic quantities and a complete small program.

View source ↗
runtime / concurrency

concurrency.ostrin

Channels, spawned tasks and joining results in the deterministic interpreter, cooperative C runtime and native-thread backend.

View source ↗
language / basics

hello.ostrin

The smallest useful starting point for learning the file and function shape.

View source ↗
language / collections

collections.ostrin

Collection literals, iteration and the operations currently covered by the core.

View source ↗
language / traits

traits.ostrin

Traits and implementations as the basis for reusable behavior.

View source ↗
language / dynamic traits

native_dyn_trait_generic_field.ostrin

A generic record stores a dynamically dispatched trait value, replaces it safely and keeps an alias alive through the change.

View source ↗
language / dynamic traits

native_dyn_trait_wrappers.ostrin

Optional, fallible, list-nested and record-stored dynamic trait values keep their data and vtable together through replacement, ownership and dispatch.

View source ↗
checker / failures

errors.ostrin

Intentional mistakes used to exercise dimensional, mutation and type errors.

View source ↗
language / matching

match_nested.ostrin

Nested patterns and the shape of exhaustive control flow.

View source ↗
scientific / complex algebra

numeric_complex_linear_algebra.ostrin

Dense complex matrices, adjoints, matrix products and pivoted solves with residual checks.

View source ↗
types / generics

generics.ostrin

Generic functions, bounds and the type information they preserve.

View source ↗
checker / diagnostics

match_non_exhaustive.ostrin

A deliberately incomplete match used to make a missing case visible.

View source ↗

Run the catalogue

Small programs. Real output.

These demos use the same compiler WebAssembly module as the full playground. Edit them, check them, run them, reset them or copy them without leaving the catalogue.

scientific / quantities

Meaningful units

Physical quantities make an invalid combination visible before execution.

Loading the compiler…
general / standard library

Useful data operations

Lists, math helpers, dates, JSON and ordinary application logic belong here too.

Loading the compiler…
language / records and enums

Model application data

Records, enums and exhaustive matching are useful beyond scientific code.

Loading the compiler…
runtime / concurrency

Coordinate work

Channels and spawned tasks share one checked API across the runtime modes.

Loading the compiler…
scientific / temperature

Absolute temperatures

Points on a temperature scale are not intervals: the mean of 20 °C, 68 °F and 300 K is an affine combination, and the span between the extremes is an interval in kelvin.

Loading the compiler…
scientific / numerical methods

Quadrature and roots

Adaptive Simpson returns its error estimate and whether it converged; Brent finds roots. Every result is checked against a closed-form value.

Loading the compiler…

Read the output

Three examples, one mental model.

These panels summarize real repository programs. Run an editable copy in the browser playground, or clone the repository to execute the source through ostrinc.

physics.ostrin
01a = 5 nm
02b = 2 m
03total = a + b
04v = velocity(10 m, 2 s)
05print(v)

compiler output

✓ type check passed

total: 2.000005 m
velocity: 5 m/s
concurrency.ostrin
01ch = channel<Int>()
02producer = spawn {
03    ch.send(1)
04    ch.close()
05}
06for value in ch { print(value) }

interpreter output

✓ model accepted

1
channel closed
runtime: interpreter + native C
errors.ostrin
01a = 5 nm
02b = 10 s
03c = a + b

checker output

× rejected before run

line 03: incompatible dimensions
found: Length + Time
help: use values with the same dimension