Examples

Programs that have to keep working.

Every example on this page is compiled and run by CI on each commit. They are not illustrations of what the language might do — they are the acceptance tests that decide whether a change ships.

Language basics

Run any of these with ./build/luke BUILD ../examples/build/<name>.luke -o out && ./out.

  • hello

    Printing, bindings, string concatenation, integer arithmetic.

  • functions

    Typed parameters and return types, compiled to plain C calls.

  • oop

    Structs, constructors, inheritance and super dispatch.

  • collections

    Lists and maps, membership, deletion, and the error path.

  • integer_rules

    Where arithmetic is exact and how overflow is reported.

  • modules

    Importing a sibling file and the standard library in one program.

  • packages

    Consuming a package resolved into luke_modules/.

  • arena_scope

    Arena allocation and release at scope exit — no collector involved.

Reactive

Fourteen conformance programs pin the engine's behaviour. Each one prints a marker the test suite greps for, so a regression fails the build rather than the demo.

signal price = 100
signal quantity = 3
derived total = price * quantity
print("total=" + total)   // total=300

Live Graph

These run as a set: a server watching a SQLite row, a browser client bound to the stream, and an updater that changes the row from outside. The assertion is that the client observes the new value and repaints exactly one region.

  • live_graph_server

    A row-backed cell pushed over the wire, with resume-from-log.

  • live_graph_client

    A browser cell bound to that stream, printing its paint count.

  • live_graph_join

    Incremental view maintenance across a join, recomputed by delta.

  • live_graph_agg

    Incremental aggregates, including ranged and function variants.

  • live_graph_scrub

    Time travel over the change log — scrub back and forward.

  • wall

    The deployed proof: server, browser client and a Caddy TLS front.

Backend

  • backend_api

    Routes, JSON, SQLite — a small API in one file.

  • auth_api

    Argon2id registration and login, sessions, and the current user.

  • http_c10k_ok

    Keep-alive, chunked responses and client IP at ten thousand connections.

  • http_db_bench

    Pooled statements under concurrent load, measured in the suite.

  • pg_api

    Postgres through libpq with the Slipstream pipelined executor.

  • sql_bind

    Bound parameters — the injection attempt stays a string.

Frontend

Browser examples build to WebAssembly plus a generated page. The suite runs them headlessly through scripts/luke_browser_loader.cjs and asserts on what painted.

  • frontend_widgets

    Text, buttons, selects, tables and modals, with accessibility wired in.

  • frontend_done

    Breakpoints, grids, scroll containers and modal focus traps.

  • reactive_counter

    A component scope that disposes its subscriptions when destroyed.

  • reactive_list_ui

    Keyed list patching — renaming one row does not clear the list.

  • web_app

    Routing, fetching and forms in a compiled browser application.

  • hello_browser

    The smallest possible browser target, for checking your WASI SDK.

Programs that must fail

A language is defined as much by what it rejects. These nine programs are expected to be refused, and CI fails if any of them compiles.

  • bad_types

    Passing a number where the signature declared text.

  • bad_arity

    Calling a two-argument function with one argument.

  • auth_secret_bad_bind

    Binding a secret into the page — refused by the compiler, not by review.

  • backend_mw_bad_order

    Middleware declared in an order that cannot be safe.