physics.ostrin
Units, derived dimensions, generic quantities and a complete small program.
View source ↗The example lab
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.
Browse the catalogue
Start with the small programs, then look at the examples that exercise generics, traits, pattern matching and the concurrency model.
Units, derived dimensions, generic quantities and a complete small program.
View source ↗Channels, spawned tasks and joining results in the deterministic interpreter, cooperative C runtime and native-thread backend.
View source ↗The smallest useful starting point for learning the file and function shape.
View source ↗Collection literals, iteration and the operations currently covered by the core.
View source ↗Traits and implementations as the basis for reusable behavior.
View source ↗A generic record stores a dynamically dispatched trait value, replaces it safely and keeps an alias alive through the change.
View source ↗Optional, fallible, list-nested and record-stored dynamic trait values keep their data and vtable together through replacement, ownership and dispatch.
View source ↗Intentional mistakes used to exercise dimensional, mutation and type errors.
View source ↗Nested patterns and the shape of exhaustive control flow.
View source ↗Dense complex matrices, adjoints, matrix products and pivoted solves with residual checks.
View source ↗Generic functions, bounds and the type information they preserve.
View source ↗A deliberately incomplete match used to make a missing case visible.
View source ↗Run the catalogue
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.
Physical quantities make an invalid combination visible before execution.
Loading the compiler…
Lists, math helpers, dates, JSON and ordinary application logic belong here too.
Loading the compiler…
Records, enums and exhaustive matching are useful beyond scientific code.
Loading the compiler…
Channels and spawned tasks share one checked API across the runtime modes.
Loading the compiler…
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…
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
These panels summarize real repository programs. Run an editable copy in the browser playground, or clone the repository to execute the source through ostrinc.
01a = 5 nm
02b = 2 m
03total = a + b
04v = velocity(10 m, 2 s)
05print(v)✓ type check passed total: 2.000005 m velocity: 5 m/s
01ch = channel<Int>()
02producer = spawn {
03 ch.send(1)
04 ch.close()
05}
06for value in ch { print(value) }✓ model accepted 1 channel closed runtime: interpreter + native C
01a = 5 nm
02b = 10 s
03c = a + b× rejected before run line 03: incompatible dimensions found: Length + Time help: use values with the same dimension