Lang

Koder Koda

  • *rea:*Foundation
  • *ath:*engines/lang/koda
  • *ersion:*7.28.0
  • *ind:*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 selfhosted: engines/lang/koda/koder is itself compiled from Koder source via a NASMsyntax AOT backend, then assembled and linked entirely by the intree selfhosted toolchain (kasm + klink). The compiler pipeline is: Koder source → bytecode → x8664 NASMsyntax 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 Koder Koda as their implementation language

Public interfaces

Binary Purpose
koder AOT compiler: koder <src.kd> <out.asm>
koder_typecheck Structural type checker CLI (default + --lsp-check + --satisfies)
koder_lsp LSP server for IDE integration
kasm Self-hosted assembler (experimental)
koder_link_smoke Selfhosted 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

  • *uck typing*(default): no type annotations required; all values are Any
  • *tructural typing*(opt-in): type annotations on params/return types; interface defines structural contracts
  • *eneric classes*(LANG-642): class Stack[T] + Stack[Int].new instantiation; type args checked by koder_typecheck
  • *untime polymorphism*(LANG641): multiclass dispatch via class_id stored at object offset 0
  • *nterfaces* structural; no implements declaration; checked by koder_typecheck --satisfies
  • *SP diagnostics*(LANG643): `koder_typecheck -lsp-check file` emits JSON diagnostic objects for IDE integration

Type checker (stdlib_typechecker.kd)

Three-phase structural checker:

  1. *ollect* scan AST for interface/class definitions, extract method signatures and type params
  2. *atisfy* structural satisfaction check (class implements all interface methods)
  3. *alk* check typed call sites — interface method existence, generic arg type compatibility

Toward make build-fully-self-hosted (#711). Current state:

  • *asm*(assembler) — works for koder.o and most inputs; full 817 K-line

    stage1 selfhost completes in *7 s*postRFC019 cascade (202605-20, meets #748 criterion 3 by 43 s margin). Some codegen bugs catalogued at

    706 still mask full self-host build.

  • *link*(linker, F1 minimum-viable) — 5 modules in

    self-hosted/lib/elf_*.kd: reader, symbol resolver, section layout, fixup processor, exec writer. Smoke driver koder_link_smoke exposes 4 modes; *asm.o → klink*and *oder.o → klink*both produce binaries that are functionally byteidentical to ldlinked equivalents (compilation md5 matches). Perf: koder.o link in ~1.0 s vs ld 0.046 s (~22×) — Gate 1 (≤1.10× ld) blocked on #750 runtime hash bug.

  • *egressions*lock the pipeline: tests/regression/173–178 cover

    reader, resolver, layout, fixup, exec writer, and cross-validate vs ld. scripts/bench-klink.sh is the perf gate (#709).

Public URL

  • Canonical: https://koda.koder.dev/ (per registries/component-names.md

    slug koda; koder-lang.koder.dev is a 301 redirect since 20260520. lang.koder.dev retired 20260522 — was the Koder Lang landing before rename to Koda; alias dropped per owner request)

Status

Active development. Selfhosted AOT backend is stable; generics and type checking are new (LANG598, LANG641, LANG642, LANG643). Goroutines (LANG597) and C transpiler (LANG600) are planned. Selfhosted linker (klink F1 #708) ships minimumviable; perf parity (#709) advanced to geomean ~2.17× ld post streamwrite Phase 4 (Gate 1 target ≤1.10×). Kasm largeinput cliff (#764) and Major GC reclaim (#748) closed 20260520 via RFC019 cascade + label intern (#765); #768 baseline regression also closed. *FC019 cascade FULLY CLOSED 20260524*— bite 4 (#772) validation gate passed on `s.khost1.devlinuxkoda` VM with gen2/gen3 bytestable bootstrap (md5 87d99225… fixed point); #750 family closes with #772. Baseline testsuite FAILs catalogued under #784 for VM env setup + pertest triage.

Source: ../home/koder/dev/koder/meta/docs/stack/modules/lang.md