Koder Koda
- Area: Foundation
- Path:
engines/lang/koda - Version: 7.28.1
- Kind: Programming language + self-hosted AOT compiler + runtime + standard library
Role in the stack
Koder Koda is the native programming language of the platform. It is the language Koder products are written in when the choice is open, the language taught in Koder docs and examples, and the language served by the Kode IDE as a first-class citizen. Sister module engines/lang/kmd defines Koder Markdown, the documentation format used across the monorepo.
The compiler is self-hosted: engines/lang/koda/koda is itself compiled from Koda source via a NASM-syntax AOT backend, then assembled and linked entirely by the in-tree self-hosted toolchain (kasm + klink). The compiler pipeline is: Koda source → bytecode → x86-64 NASM-syntax assembly → ELF object → ELF binary.
Primary couplings
| Consumer | Relationship |
|---|---|
products/dev/kode |
IDE — parses, analyzes and edits Koder Koda source, ships LSP integration |
engines/lang/kmd |
Sister module — Markdown format used alongside the language for docs and RFCs |
| All modules | Products that choose Koda as their implementation language |
Public interfaces
| Binary | Purpose |
|---|---|
koda |
AOT compiler: koda <src.kd> <out.asm> |
koda_typecheck |
Structural type checker CLI (default + --lsp-check + --satisfies) |
koda_lsp |
LSP server for IDE integration |
kasm |
Self-hosted assembler (experimental) |
koda_link_smoke |
Self-hosted ELF64 static linker (klink F1, #708/#709) — modes: -r resolver, -l layout, -x fixup pipeline, -w out path1.o path2.o… full link |
Language features
- Duck typing (default): no type annotations required; all values are Any
- Structural typing (opt-in): type annotations on params/return types;
interfacedefines structural contracts - Generic classes (LANG-642):
class Stack[T]+Stack[Int].newinstantiation; type args checked bykoder_typecheck - Runtime polymorphism (LANG-641): multi-class dispatch via class_id stored at object offset 0
- Interfaces: structural; no
implementsdeclaration; checked bykoda_typecheck --satisfies - LSP diagnostics (LANG-643):
koda_typecheck --lsp-check <file>emits JSON diagnostic objects for IDE integration - SIMD Vector value type (#701, RFC-022): first-class
Vector(i32x4/x8,i64x2/x4,f32x4/x8,f64x2/x4) over AVX2SSENEON with scalar fallback, full-OOP method set (+ - * / .dot .sum .normalize .[i] .length .map …). OneTAG_VECTOR=11, header-discriminated shape, GC mark-leaf (raw payload, no traverse —Bytes-pattern), runtime feature dispatch (one portable binary). Built on the existing runtime Float (TAG_FLOAT=3, full SSE arithmetic). Phase 1a landed v7.28.16 (2026-05-30): integer-vector foundation (I32x4I32x8.new,v[i]v[i]=/v.length) — self-compile fixed point (nasm + self-hosted kasm+klink chains) + GC mark-leaf survival validated ons.khost1.dev-linux-koda. Phase 1b (operators + full-OOP completion), Phase 2 (float shapes), Phase 3 (NEON), Phase 4 (kodec consumer) pending.
Type checker (stdlib_typechecker.kd)
Three-phase structural checker:
- Collect: scan AST for interface/class definitions, extract method signatures and type params
- Satisfy: structural satisfaction check (class implements all interface methods)
- Walk: check typed call sites — interface method existence, generic arg type compatibility
Self-hosted toolchain (klink + kasm)
Toward make build-fully-self-hosted (#711). Current state:
- kasm (assembler) — works for koda.o and most inputs; full 817 K-line
stage1 self-host completes in 47 s post-RFC-019 cascade (2026-05-20, meets #748 criterion 3 by 43 s margin). Some codegen bugs catalogued at
706 still mask full self-host build.
- klink (linker, F1 minimum-viable) — 5 modules in
self-hosted/lib/elf_*.kd: reader, symbol resolver, section layout, fixup processor, exec writer. Smoke driverkoda_link_smokeexposes 4 modes; kasm.o → klink and koda.o → klink both produce binaries that are functionally byte-identical to ld-linked equivalents (compilation md5 matches). Perf: koda.o link in ~1.0 s vs ld 0.046 s (~22×) — Gate 1 (≤1.10× ld) blocked on #750 runtime hash bug. - Regressions lock the pipeline:
tests/regression/173–178coverreader, resolver, layout, fixup, exec writer, and cross-validate vs ld.
scripts/bench-klink.shis the perf gate (#709).
Public URL
- Canonical: https://koda.koder.dev/ (per
registries/component-names.mdslug
koda;koder-lang.koder.devis a 301 redirect since 2026-05-20.lang.koder.devretired 2026-05-22 — was the Koder Lang landing before rename to Koda; alias dropped per owner request)
Status
Active development. Self-hosted AOT backend is stable; generics and type checking are new (LANG-598, LANG-641, LANG-642, LANG-643). Goroutines (LANG-597) and C transpiler (LANG-600) are planned. Self-hosted linker (klink F1 #708) ships minimum-viable; perf parity (#709) advanced to geomean ~2.17× ld post stream-write Phase 4 (Gate 1 target ≤1.10×). Kasm large-input cliff (#764) and Major GC reclaim (#748) closed 2026-05-20 via RFC-019 cascade + label intern (#765); #768 baseline regression also closed. RFC-019 cascade FULLY CLOSED 2026-05-24 — bite 4 (#772) validation gate passed on s.khost1.dev-linux-koda VM with gen-2gen-3 byte-stable bootstrap (md5 87d99225… fixed point); #750 family closes with #772. Baseline test-suite FAILs catalogued under #784 for VM env setup + per-test triage. Minor-GC young-gen collection (#800) REVERTED 2026-05-30 — REOPENED, blocked on #804. The RFC-021 construction-window pin + remembered-set lifecycle fix shipped 2026-05-29 (v7.28.14) but was unshipped (v7.28.15): the shipped binary flakily SIGSEGVs self-compiling the 850K-line stage1 — it still misses a generational root under heavy allocation (verified on s.khost1.dev-linux-koda: v7.28.14 crashes rc139, the pre-#800 2de33 binary compiles the same source fine; the "gen2=gen3 PASS" was a heap-layout-dependent flaky false positive). Generational root coverage (card table + write barrier / 16384-entry remembered-set overflow hole) is #804 (promoted P1, now blocks #800#730/#801). Toolchain restored green: v7.28.15 binary (pre-#800 stable GC), make verify-fully-self-hosted (gate #794) PASS.