Kod¶
Kod is a toy language that compiles to AArch64 (Apple Silicon) machine code for macOS. The self-hosted compiler (sh_kodc) compiles Kod programs, including itself.
Features¶
- Compiled to native ARM64 machine code (via
as+clang) - Static types:
int64,str,bool, arrays[T], structs, enums, optionalsT?, generic typesT[U, V]and functionsf[T] - Union types:
int64 | str, taken apart withn: int64patterns - Pattern matching via
match, plusif X is .Variant(bindings)sugar - F-string interpolation (
f"hello {name}"), auto-to_strfor non-string interpolands - Interfaces with vtable dispatch; primitives implement them via implicit boxing
- Error handling via
T or Error,try/must/throw test "description" { ... }syntax withassert <expr>(source captured)- Modules and imports (
import "kod/ast",import "./helper") - Self-hosted ARM64 codegen written in Kod itself
Status¶
The self-hosted compiler (sh_kodc) is the only implementation. A checked-in snapshot of it builds the current sources (see Self-hosting).