Define shared behavior
Nominal traits describe what a type can do and provide a stable surface for library design.
The language
Ostrin is being shaped around a simple idea: important meaning should be represented by the language itself, not left as a convention for every programmer to remember.
01 / Physical quantities
A quantity has a magnitude and a dimension. Ostrin keeps the relationship visible through the type system, so derived values can be checked at compile time.
01fn velocity(distance: Quantity<Length>,
02 time: Quantity<Time>) -> Quantity<Length / Time> {
03 distance / time
04}
05
06speed = velocity(10 m, 2 s)02 / Explicit state
Bindings are immutable by default. The mut marker gives changing state a clear place in the program and makes ownership decisions easier to inspect.
01total = 0
02mut running_total = 0
03for value in values {
04 running_total = running_total + value
05}03 / Failure as data
Option, Result and pattern matching keep success and failure in the type model. The compiler can then make missing cases visible instead of letting them disappear into control flow.
01fn load(id: Id) -> Result<Record, LoadError> {
02 try database.fetch(id)
03}
04
05match load(id) {
06 Ok(record) => print(record),
07 Err(error) => report(error)
08}04 / Composable abstractions
The language core includes records, enums, traits, generic functions, implementations and modules. These are the pieces that let a language move from examples to reusable software.
Nominal traits describe what a type can do and provide a stable surface for library design.
Generic functions and bounds let abstractions stay precise without duplicating code.
Visibility and module boundaries make larger codebases easier to navigate and evolve.
Enums and pattern matching give domain models a readable, checkable shape.
05 / Concurrency direction
Ostrin's concurrency model uses channels, spawned tasks and immutable-by-default values. The interpreter and cooperative C runtime are deterministic; --native-threads enables OS threads, blocking channels and cooperative cancellation with the same API.
01channel = channel<Int>()
02producer = spawn {
03 channel.send(1)
04 channel.close()
05}
06for value in channel { print(value) }