Kiki

Introducing Kiki Lang

2026-12-02 · Kiki Team Open live in editor

Kiki is a statically typed language where prose, tables, queries, and functions live in one plain-text .ki file. It aims for the live surface of a spreadsheet without positional cell references, and the structure of code without splitting a tool across Markdown, SQL, and Python.

This post is itself a .ki file. Every result below is evaluated by the Kiki compiler.

Prose first, code after >

Most languages treat prose as comments inside code. Kiki inverts the default: ordinary lines are prose, and lines starting with > are code.

> hours = 38
> rate = 45
> pay = fn h r -> h * r
> pay hours rate
1710

Prose splices evaluated expressions with \(...). Styling primitives such as bold, italic, and link are ordinary functions, and ~ passes trailing text as a prose value. Writing \(hours) hours come to $\(pay hours rate), calculated \(bold ~ live). produces:

38 hours come to $1710, calculated live.

Top-level definitions form a reactive dataflow graph rather than an imperative script: when an input changes, only the cells downstream of it recompute.

Tables, queries, and presentation values

Tables are first-class literal values written directly in text. _ marks a missing (null) cell:

> shifts = |Name  Day  Hours  Bonus|
            Ana   Mon  8      _
            Ana   Tue  6      25.00
            Ben   Mon  9      _
            Ben   Wed  9      40.00
            Cleo  Tue  8      _

Queries are relational pipelines chained with |>:

> usd = format.money "USD"
> by-person = shifts
    |> group Name Days = (count-distinct Day) Hours = (sum Hours) Bonus = (sum Bonus)
    |> extend Pay = (Hours * 35 + Bonus |> usd)
    |> sort -Pay
> by-person
NameDaysHoursBonusPay
Ben21840.00670.00
Ana21425.00515.00
Cleo180280

Notice (Hours * 35 + Bonus |> usd). A common wart in spreadsheets and reporting SQL is that formatting a number turns it into text, breaking downstream arithmetic and sorting "$90" after "$120". In Kiki, usd attaches presentation metadata to the :decimal value without changing its type—sort -Pay still sorts numerically, and downstream sums still return a :decimal:

> by-person |> aggregate sum Pay |> usd
$1,465.00

Static types and inline tests

Types are inferred across scalars, records, lists, functions, and tables, so most definitions omit annotations. Inspecting shifts shows its inferred column schema, including :decimal? from the _ cells:

> type-of shifts
:|Name = string Day = string Hours = int Bonus = decimal?|

Referencing a nonexistent column (shifts |> select Hourse) or adding incompatible types fails typechecking on that line before evaluation runs.

Tests are written inline with => right next to the rules they verify. Pattern matching and tagged variants (one-of) express domain rules without boilerplate:

> overtime-pay = fn :decimal rate :int h ->
    math.min h 40 * rate + math.max (h - 40) 0 * rate * 1.5
> contract = :(one-of hourly = {rate = decimal hours = int} salaried = decimal)
> weekly-pay = fn 'hourly c      -> overtime-pay c.rate c.hours
               fn 'salaried flat -> flat
> weekly-pay (:contract 'hourly {rate = 30 hours = 44}) => 1380 ✓
> weekly-pay (:contract 'salaried 1500)                 => 1500 ✓

A file is also a module: marking definitions with export lets sibling .ki files import shared tables, formats, and tested functions via import "./records".

One mechanism for errors, nulls, state, and tasks

Rather than separate language rules for exceptions, SQL three-valued NULL, reactive hooks, and async I/O, Kiki models all four as typed algebraic effects:

> safe-ratio = fn :int a :int b ->
    handle !div-by-zero -> resume 0
    a / b
> safe-ratio 10 0
0
> type-of (fn :int a :int b -> a / b)
:(fn int int -> decimal !div-by-zero)
> shifts |> filter Hours >= 8 |> select Name Hours (Bonus or-else 0 |> usd)
NameHoursBonus
Ana80
Ben90
Ben940.00
Cleo80
> subtotal = fn amount -> amount + !tax amount
> handle !tax x -> resume (x * 0.08)
  subtotal 100
108.00

Interactive controls and table lineage

Wrapping a default value in state declares a session-scoped control whose value feeds into any query:

> who = state ((choice ["Everyone" "Ana" "Ben" "Cleo"]) "Everyone")
> shifts |> filter who == "Everyone" or Name == who
NameDayHoursBonus
AnaMon8
AnaTue625.00
BenMon9
BenWed940.00
CleoTue8

Interactive controls and inline edits work live when this page is open in Kiki — open this post in the editor to change the picker above or edit the queries and tables.

In the interactive editor, queries over a literal table (filter, sort, select, lookup) also preserve cell lineage: each projected cell remembers its source row and column, so editing a cell inside a filtered view or clicking a projected button column updates the underlying .ki table text directly.

Implementation notes

Kiki is written in Zig, with a columnar in-memory table engine and a register VM. The same codebase compiles to a native CLI and to WebAssembly, so the compiler, query engine, and editor all run locally in the browser.

Kiki targets operational documents and working datasets that fit in memory rather than analytical warehouses. The language is still young—syntax and diagnostics are evolving. The Kiki compiler is not yet open sourced, and we plan to open source it in the future.

Explore it

Everything below runs locally in your browser via WebAssembly with no sign-up: