Foundations: algebraic object-orientation
This page is the conceptual foundation of daitai-lang. For the normative grammar see the v1.4 specification; for the constitution see The principles.
The position
daitai-lang is a small, boring, algebraic object-oriented language. It exists to specify algorithms clearly and deterministically — not to maximize expressiveness, not to win benchmarks, and not to be convenient. Clarity, determinism and correctness are strictly more important than every other property.
What daitai-lang is
- deterministic
- statically typed
- immutable by default
- expression-based
- backend-neutral
What daitai-lang is not
- a runtime
- exception-based
- polymorphic through inheritance
- stateful
- dependent on a host language
daitai-lang describes what an algorithm is, never how it runs.
Algebraic OO in one paragraph
Objects are algebraic data types with associated transformations. Classes are products (records of fields). Interfaces are sums (a closed set of shapes). Methods are pure functions with a receiver. There are no lifecycles and no side effects. Inheritance with behavior, virtual dispatch, mutation, exceptions, global state, IO, reflection and macros are all forbidden in the core.
The four allowed top-level declarations
Only four constructs may appear at the top level:
class— a product type (immutable record + pure methods + static factories)interface— a sum type (a closed shape, no fields, no method bodies, nominal typing only)enum— a discrete set of named valuesfunction— a pure top-level transformation
Anything else is rejected.
Class semantics
class Vec3:
x: Float
y: Float
z: Float
method add(other: Vec3) -> Vec3:
return Vec3(
x = this.x + other.x,
y = this.y + other.y,
z = this.z + other.z
)
static method zero() -> Vec3:
return Vec3(x=0, y=0, z=0)
Rules:
- all fields are
val— assigned once at construction, never mutated - equality is structural, never referential
- there is no object identity
- constructors contain no logic
- methods are pure;
thisis read-only - static methods are factories
Interfaces as shapes
interface Curve
class Line implements Curve:
start: Vec3
end: Vec3
class Arc implements Curve:
center: Vec3
radius: Float
Interfaces have no fields and no method bodies — not even defaults. They name a closed family. Dispatch is done by match, not by virtual tables.
Failure is a value
There are no exceptions. Failable operations return Result<T, E> and absence is Optional<T>. null does not exist in the core.
function parseInt(s: String) -> Result<Int, ParseError>
enum ParseError:
InvalidFormat
Overflow
The forbidden list
The following constructions are rejected by the daitai-lang front-end. They are not stylistic preferences — they are removed from the grammar.
- mutation and variable reassignment
- inheritance with behavior
- virtual dispatch / polymorphic method bodies
- exceptions and
try/catch - implicit typing past declaration boundaries
null- global state
- IO, logging, environment access
- reflection and metaprogramming
- target-language-specific constructs
If a construct is not explicitly permitted by the specification, it is forbidden. When in doubt, simplify the algorithm until it fits.
Reading next
- Specification (v1.4) — the normative reference.
- The principles (P01–P23) — the constitution this rests on.
- Step semantics — how state advances when mutation is forbidden.