{"slug": "declare-is-a-ui-language-for-you-and-your-ai", "title": "Declare is a UI language for you and your AI", "summary": "David Temkin released Declare, an MIT-licensed domain-specific language for user interfaces that is designed to be written by AI agents and checked by a compiler, with a calendar app built in 568 lines of code plus 228 of comments and shipped as 177 KB gzipped. In a single-run comparison, the same agent built a ticket-buying app twice: the Declare version was 1,279 lines versus React's 2,666, and its first build that ran passed all eleven hidden checks while React's passed six — results Temkin describes as \"single runs, not yet a benchmark.\" Declare ships with an installable skill, a declare-help lookup for names and error codes, an Inspector that explains live values, and a formal six-rung verification ladder from parse to pixels that reports what each rung proved and what it cannot see.", "body_md": "Just as SQL is a domain-specific language for database queries, Declare is a DSL for user interfaces — for taking the custom, fluid experience you have in mind beyond a prototype, into a real app: structured, verifiable, and with the design written plainly in its code.\n\nDeclare in 10 minutes →\n\nRun the calendar →\n\nThe language, in one file →\n\n01\n\nA calendar that zooms through time, a desktop with real windows: complete programs, each readable end to end and checked by the compiler. Open one, or edit it live in the browser you’re using.\n\n1\n\nDay, week, month and year views are one surface, zooming continuously; a view doesn’t switch so much as become the next one, and every motion can be interrupted. It runs on real data: drag an event to another day, and it’s moved.\n\n568\n\nlines of code, plus 228 of comments — four views, zoom, drag and edit\n\n177 KB\n\nover the wire, gzipped — app (structure, logic, styling) and runtime\n\n0\n\nlines typed by hand — human-designed and directed, built with AI\n\nRun Declare Calendar →\n\nView & edit source →\n\n2\n\n→\n\nThe acid test for a UI language: multiple applications, windows that drag, resize, layer and minimize into live thumbnails, a magnifying dock, menus that follow focus, and separately loaded apps running inside its windows. Elsewhere that is a project assembled from several libraries; here it is one program.\n\n3529 lines — 2011 code, 939 comment · 264 KB over the wire · every pixel drawn from shapes, no image assets\n\n3\n\n1,000,000 issues · search as you type · edit in place, with undo · not one line of virtualization code\n\n1508 lines — 983 code, 251 comment · 194 KB over the wire, before its data · no dependencies\n\nAnd more:\n\nWeather →\n\nMarket Map →\n\nBirds →\n\nTo-do →\n\nAsteroids →\n\n02\n\nDeclare was designed first for the people who make interfaces. Layout, motion, states, theming and drawing are the language itself, not libraries bolted on — so the experience you have in mind is something you can write down directly, and read back later as it was meant.\n\nRules\n\nData\n\nMotion\n\nThree things follow one value: the number, the bar’s length and its color. Click to change v — all three update together, because each is a relationship that stays true, not a step someone remembered to run.\n\nLIVE · EDITABLE\n\nRevert\n\n40\n\nclick anywhere to change v\n\nIn Declare, yes. A small language gets it started; these four tools let it catch its mistakes, fix them, and finish.\n\nOne installable skill: the language, the library, the conventions, the working loop — nothing to reconstruct from a repository. And declare-help answers any name or error code on demand.\n\nEvery diagnostic names the broken rule and the valid rewrite. Try it: change textColor to color in the panel above and read what comes back.\n\nThe Inspector can tell you or an agent why a live value is what it is, what it depends on, and what happens if you change it — live, in the running program, not guessed from source.\n\nA formal six-rung ladder, from parse to pixels, is how an app is shown to be correct. Your AI climbs it one rung at a time, and every rung reports what it proved — and what it cannot see.\n\nMeasured: given the same brief, the same agent built a ticket-buying app twice. The Declare app was 1,279 lines to React’s 2,666, and its first build that ran passed all eleven hidden checks; React’s passed six. Single runs, not yet a benchmark — every run is in the repository.\n\nThe calendar above was built this way: human-designed and directed, built with AI, and kept honest by the compiler.\n\nBuilt in Declare\n\n·\n\nView Source\n\nDocs\n\nThe language\n\nHow it works\n\nGitHub\n\nMIT License\n\n© 2026 David Temkin\n\nDeclare\n\nApps ▾\n\nLearn ▾\n\nAbout ▾\n\nGet started\n\nWHY DECLARE\n\nStart with the obvious objection. AI writes most code now, and it is best at the languages it has seen the most — so the sensible move is to use whatever has the biggest corpus and let the model figure it out. By that logic the era of new programming languages is over.\n\nThat argument gets its facts right and its conclusion backwards. Writing code is now nearly free; trusting it costs what it always did. An AI writing React verifies its work by resemblance — this looks like the billion lines it trained on — and resemblance is not correctness. Meanwhile less and less code passes under human eyes, which leaves the language and its compiler as the one reviewer that is always present. Handing the writing to a machine doesn’t make the language irrelevant. It makes it load-bearing.\n\nDeclare set out to be two things at once.\n\n**Expressive.** A language that can say what a real interface is — not just data entry screens, but fast, polished, custom software designed to be used, even enjoyed: views that become the next view, motion that carries meaning, layouts that answer to content and to the screen they are on.\n\n**Verifiable.** A language that can be learned, written, debugged and tested by an AI, and whose programs a compiler can check rather than guess at.\n\nMost attempts to make code safe for machines make it duller for people. Declare refuses that tradeoff. Every feature that makes a program checkable — one tree for structure, style and behavior; every dependency visible to the compiler; one decider for each value — is also what makes it short, and readable to the person who has to judge it.\n\nA well-designed experience is a set of decisions — how it should look, how it should move, what should feel inevitable — and those decisions are yours. An AI can produce a standard-looking app easily, and in Declare it can produce one verifiably. What it cannot supply is a custom-crafted design.\n\nThat is why layout, motion, states, theming and drawing are part of the language itself rather than libraries: a `Spring` on an attribute, a layout as a value a view holds, a mode as a state you are in or not. The continuous version of an interface is often less code than the discrete one. And because a Declare program is one complete description — no separate stylesheet, no framework lifecycle, no build of a dozen files — the design you meant is written plainly in the code, where you, a colleague or an AI can read it back and see that it is still what you meant.\n\nWhat an AI gets from a mainstream stack is corpus leverage: fluency by imitation — broad, shallow, self-contradictory, unverifiable. The other kind is comprehension leverage: a language small enough to hand to a model whole, regular enough that its programs can be analyzed rather than pattern-matched, and backed by a compiler that turns each mistake into a precise correction. Corpus leverage arrives free with popularity. Comprehension leverage has to be designed in, and it is the only kind a new language can compete on.\n\nIt is a measured bet: a small language handed to a model in context has beaten the same model writing Python ([study →](https://arxiv.org/abs/2512.23214)), and a compiler that explains its errors measurably improves a model’s repairs ([study →](https://arxiv.org/abs/2504.06939)).\n\nDeclare was built the same way it is meant to be used: eval by eval. An agent that had never seen the language was given a written application spec and the Declare download, and built the app while I watched — how long it took, what it tripped on, what it found missing, how well its code read, how well the app worked. Another agent built the same spec in React. Over a hundred runs, what improved was not the model but the language: the same ticket-buying app went from 48 minutes to 24, compiler errors per build from 32 to 6. In the latest pair the Declare app was 1,279 lines to React’s 2,666, and its first build that ran passed all eleven hidden checks; React’s passed six. Single runs, not yet a benchmark. [The runs, in full →](https://github.com/davidtemkin/declarelang/tree/main/evals/reports)\n\nThe most prized quality of a great interface — the continuity you feel in the best native apps — has always been bespoke: specialist craft, one interaction at a time, locked to a platform, and wrong in ways nothing catches. Declare makes that continuity the grain of the language, and puts it where a compiler can check it. The calendar is the proof: four views as one zooming surface, about 600 lines, human-designed and directed, and built with AI.\n\nThere is another generation of experiences beyond today’s hand-crafted best — built on a foundation with continuity at its core, deployed as widely as a URL, and shaped by people with an idea of how software should feel, working with an AI at their side. Declare is built to find out what they make.\n\n*Further: [the FAQ](#faq) · [how it works](#architecture) · [the whole language, in one file](#language)*\n\nWHERE THIS CAME FROM\n\nI co-founded Laszlo Systems and led the team behind OpenLaszlo — a declarative UI language, first shipped in 2002, that pushed right to the edge of what that era’s web browsers could handle.\n\nWhat brought me back to UI development was [Mesa](https://davidtemkin.com/about-mesa/), a zoomable canvas app I built without using a browser framework, toolkit, or higher-level language. Mesa renders a thousand live objects at a 60fps floor, even on a phone. It’s been positively amazing to see how fast today’s browsers have become — and how powerful and flexible today’s web platform is.\n\nAnd yet the web as it actually stands is still, mostly, slow and clunky. Even brand-new sites. How can that be?\n\nIt turns out the browser isn’t what makes the web feel worse than a good native app. It’s what we’ve built on top of it. A lot of accumulated code — and a lot of accumulated habits — take their toll, and the interfaces that do escape them are hand-crafted, one at a time, by specialists.\n\nIn June I handed the original OpenLaszlo compiler to an LLM and got back a modern port that compiles any OpenLaszlo program perfectly, byte-for-byte.\n\nSeeing those programs again through fresh eyes — and seeing how small and how fast the sites built with them are — I decided the language deserved to be modernized. Declare is what came out of that: a direct descendant of OpenLaszlo, with the core ideas intact, built on an entirely new foundation, and shaped to be written with an LLM.\n\nEnjoy!\n\n— David Temkin\n\nTHE LANGUAGE\n\n*Declare is a language for building application interfaces. This file is the language: every form the grammar accepts and every rule the compiler enforces. The compiler completes it — every error carries a code, a position, and the rewrite that resolves it (§12), so nothing here needs to enumerate edge cases.*\n\n*Declare is new, and no LLM has been trained on it. It resembles React, CSS, and HTML in places, and this file is where those resemblances stop. Every complete program below is compiled by the test suite, so the examples are current by construction; where this file and the compiler disagree, the compiler is right.*\n\n*The classes and their attributes are in the reference — `npx declare-help <name>` answers any of them by name. How to work with Declare, and where everything else is, starts at [`skill/SKILL.md`](../skill/SKILL.md).*\n\nOne boundary makes the rest of this file readable. **Every capitalized tag is a class** — `View`, `Text`, and `Image`, but equally `Dataset`, `State`, `Spring`, and `KeyListener`. The language is the grammar that declares, instantiates, configures, and relates them, and that grammar is what follows.\n\nA Declare program is a tree of nodes whose attributes are related to each other by standing expressions the runtime keeps true.\n\n**A constraint is a relationship, not a callback.** Read a reactive value inside one and you are subscribed to it; assign to that value and everything that reads it updates. There is no re-render, no diffing, no dependency array, and no hook, because nothing was ever a render.\n\n```\nApp [ width = 400, height = 140, fill = darkslategray, textColor = whitesmoke,\n    count: number = 0,                               // reactive state\n    col: View [ x = center, y = center,\n        layout: SimpleLayout [ axis = y, spacing = 14, align = center ],\n        Button [ label = \"Add one\", primary = true, onClick() { app.count = app.count + 1 } ],\n        Text [ text = { `Clicked ${app.count} times` } ]\n        ]\n    ]\n```\n\nClick the button and the label updates; resize the window and it stays centered. You wrote no update logic for either, and there is nowhere to put any. Every section below is this same idea applied to structure, space, data, style, and time.\n\n`{ }` is TypeScript, and only TypeScript.`width = { 100% }` is a syntax error, and a color inside braces is `\"#4169E1\"` or `0x4169E1`, never bare `#4169E1`. (§2)` count = count + 1` sets `setState`, no `setAttribute`, and no way to change a value without the cascade. (§5)`[ ]` tree never generates children from an expression, so React's `{items.map(…)}` and `{cond && …}` have no equivalent there: a collection comes from `visible`. (Both are ordinary TypeScript inside `createView`, just not in the tree.) (§7)` app.width`. The renderer makes what the browser's own features need (the tree a screen reader reads, the fields autofill fills) from what you declare: a role, a name, a `purpose`. Its elements are not an interface. (§6, §9)` provided(…)` finds the nearest value an ancestor provides (§9), and a key the nearest binding a view declares (§8).`onLoad`, `onArrive`, `afterSettle`). Time is only ever an input — a duration to animate over, a frame step to integrate by. (§5, §10)\nTwo brackets carry the entire syntax. **`[ … ]` holds a node's members** — attributes, declarations, methods, children — and the bracket nesting *is* the tree. **`{ … }` is TypeScript**, type-checked against every class's real API.\n\nAn attribute's value takes four forms, and the spelling tells you which:\n\n| you write | it is | example | \n|---|---|---|\n| a **bare** value | a literal, set once | `width = 100%` ,`fill = navy` | \n| a **bare list** | a literal list, for an array-typed attribute | `listenTo = [\"delta\", \"done\"]` | \n| a **`{ … }`** value | a live expression — a **constraint** | `width = { parent.width - 10 }` | \n| a **`:`-prefixed** path | a read from bound data — a **datapath** | `text = :title` | \n\nA bare literal is the value itself, so a name is *not* one: `fill = accent` fails as a bare value. Reach a named value through braces — `fill = { provided(\"theme\").accent }`.\n\nBare values have a small literal vocabulary the compiler owns: Lengths (`100%`), colors (` navy`, `#336699`), and keywords (` center`, `x`). Inside `{ }` none of it exists. You are in plain TypeScript, an identifier means what TypeScript says it means, and the compiler never reinterprets it.\n\n```\nfill  = cornflowerblue,                           // ✓ bare value, a named color\nfill  = { hovered ? 0x6495ED : 0x4169E1 },        // ✓ in braces, TypeScript number\nfill  = { hovered ? #6495ED : 0x4169E1 },         // ✗ no such syntax in TypeScript: \"#6495ED\"\nwidth = 100%,                                     // ✓ bare value, Length literal\nwidth = { 100% },                                 // ✗ compute it instead:\nwidth = { parent.width - 40 }                    // ✓\n```\n\nA body is TypeScript, written as TypeScript writes it: ternaries, template literals, array chains, closures, casts (`x as T`, `x!`), annotations on locals and parameters, generics, and a method body's own `type`, `interface`, `enum` and `class` declarations. Everything type-level is checked, then stripped; what TypeScript compiles (an enum, a class's parameter properties), the compiler compiles. One limit, a compile error naming the rewrite: **a value body is a single expression** — statements live in methods.\n\n**A `:path` may also appear inside a `{ }` body**, and this is central rather than exotic: it is how anything conditional over replicated data gets written. `text = { :on ? :title : \"—\" }` reads the datapath exactly as the bare form does, then computes with it in TypeScript. Read `{ }` as \"TypeScript, plus datapath reads.\"\n\nTwo lexical notes. A `\"…\"` string ends at its line, in a bare value as in a `{ }` body; a `\"\"\"` block is the form for long text. And a `Dataset`'s literal body is strict JSON (§7) — the one place `{ }` is not TypeScript at all.\n\nEverything inside `[ ]` is a member, in one of five shapes. Two of them look nearly identical and mean different things.\n\n```\nwidth = 100%,                          // SET an attribute that already exists\nx     = { parent.width - 40 },         // SET it live — a constraint\ntext  = :title,                        // SET it from bound data\n\nlabel:    string  = \"\",                // DECLARE a new reactive attribute\nselected: boolean = false,\ntint:     Color   = navy,              //   any value type, bare-literal default\ncount:    number,                      //   no default — undefined until written\nrows:     number[] = [],               //   an array, element-typed\npanel:    Menu?   = null,              //   a class — the attribute holds an instance, or null\n\nselect() { selected = !selected },     // a METHOD\n\nonClick()      { count = count + 1 },  // a HANDLER — `on` + an event this node fires\nonPointerMove(e: PointerEvent) { x = e.x },   // pointer handlers get a typed payload\n\ndraw(d: DrawContext) { d.fillStyle = \"#4169E1\"    // a METHOD the view calls to paint itself — see below\n            d.fillRect(0, 0, 12, 12) },\n\nbg: View [ fill = midnightblue ],      // a CHILD, named — reachable as `bg`\nText [ text = \"OK\" ]                  // a CHILD, anonymous\n```\n\n**Any view can paint itself by defining `draw(d: DrawContext)`** — graphs, gauges, iconography, marks no fill or font gives you. It is an ordinary method: `View` calls it from a constraint of its own (`drawing = { record(draw) }`), so it runs on invalidation and re-runs when what it read changes, never per frame — the same rule as any method a constraint calls. `d` takes the Canvas2D drawing calls (`fillStyle`, `beginPath`, `moveTo`, `stroke`, …); what it records, every renderer paints.\n\n**`name = value` sets an attribute that exists; `name: Type = value` declares a new one.** Declaring is how reactive state enters a program; setting is how it is wired. A declaration's type is a TypeScript type — `number`, `string[]`, `\"idle\" | \"busy\"`, `Map<string, Row>`, `{ x: number; y: number }`, `[number, number]`, `(id: string) => void`, `Row | null` — naming TypeScript's built-ins, Declare's own (`Color`, `Length`, …), your classes, your schemas (§7), or a type a `script` block declares; `object` / `array` stand for a record or list of no declared shape, in a cast too. `T?` is Declare's shorthand for `T | null`, and takes `?.`'s `undefined` as `null`. A type that a declaration cannot hold in place (a conditional or template-literal type) is named once in a `script` block and used by name. The one place a type meets the member syntax is a `[` after it: glued and empty it is an array (`w: Window[]`); after a space it opens a named child (` w: Window [ … ]`).\n\n**A method's signature is typed, name-first**: `select() { … }`, `commit(v: boolean) { … }`, `quant(v: number) -> number { … }`. Every parameter carries a written type — any type a declaration takes, an event payload among them (`onPointerUp(e: PointerUpEvent)`); `c?: Menu`, or Declare's `c: Menu?`, says the value may be absent, and the body must check. The return is written `-> Ret` or TypeScript's `: Ret` — a type's **name** (`-> Week`, `-> Session[]`), not a record written out in place: give a returned record a `schema` and return that. Omit it for a method that returns nothing. A computed *value* is still not a method but an attribute with a `{ }` default, `segIndex: number = { … }` — an attribute stays reactively true; a method runs when called. A subclass's method, handlers included, **replaces** the base's of the same name, a built-in's own runtime methods (`fetch`, `start`, `scrollTo`) among them; `super.name(args)` calls the replaced one, wherever in the body it is written, or never.\n\n**Events from outside the tree come through a member you declare.** `KeyListener [ onKeyUp(e: KeyEvent) { … } ]` hears the raw keyboard regardless of focus. There is no subscription syntax and nothing to unregister: the source is a child, so it lives and dies with the node that declares it.\n\n**Members are separated by commas**; a trailing one before a closing `]` is legal.\n\n**A bare name resolves outward through the enclosing brackets, innermost first** — the brackets are the scope exactly as they are the tree. Each `[ ]` you are nested inside is a level whose surface is that node's whole member set, and the nearest level owning the name wins, at compile time. One consequence to hold on to: every view carries the built-in attributes, so a bare `width` always means *this* node's `width` — built-ins never resolve outward.\n\nThree reserved words say it explicitly, and nothing else may take their names: **`this`** (the node the code is written on), **` parent`**, and **` app`** (the running application, from any depth — the home of the few values the whole app shares). Bare `App` is the class; `app` is the instance. A fourth, `classroot`, belongs to authoring a class and arrives in §4.\n\n**Every name the platform adds is capitalized**: a class, a type with its builders (`Stroke(1, red)`, `Color.mix(a, b, 0.5)`), a service (` Focus`), or a theme preset. A lowercase name is yours, the node's or JavaScript's, besides `provided`, `measureText` and `escapeHtml`.\n\n**A member is a property of its view**, reached as JavaScript reaches one: `toolbar.share`, or by a name computed at run time, `toolbar[name]`; the two chain freely. Each bracket steps one level and names one member, else `undefined`. A literal name is checked like a path; one known only at run time cannot be.\n\nInstantiate a class by naming it with a `[ ]` body; define one with `class Name [ … ]`. A class with no base is a **view**; any other base is named — `extends Node` for a class with no view, `extends Dataset` for a class with no view that holds data (a `Dataset` is a `Node`), `extends Control` or any class of yours or the library's.\n\n```\nclass Chip [ height = 30, cornerRadius = 10, fill = darkslategray,\n    label: string = \"\",\n    width = { this.t.width + 20 },\n    t: Text [ x = 10, y = 5, fontSize = 12, text = { label } ]\n    ]\n\nApp [ width = 400, height = 100, fill = black,\n    layout: SimpleLayout [ axis = x, spacing = 10 ],\n    Chip [ label = \"one\" ],\n    Chip [ label = \"two\" ]\n    ]\n```\n\n**`App` is the one root**, one per program; with `width` and `height` unset it fills its host. **Any instance may declare its own members** — state, methods, handlers — with no class at all, because the compiler synthesizes an anonymous subclass, and the instance remains a subtype of its base. Promote a one-off to a named `class` when you instantiate it twice, or when pulling it out keeps its parent readable. The same holds for what has no view: state and logic can live on the App, and when a group of it becomes a thing in its own right — the rules of one dataset's records, a service, a piece of machinery — it moves into a class of its own that extends `Node`, or `Dataset` when it is those records' own logic.\n\n**A subclass adds children; `defaultPlacement` says where they go.** A subclass's children (and a use site's) are appended to the instance, after the base class's own. A class that is a frame around content names the child the content belongs in — ```\nclass Sheet [\ndefaultPlacement = body, body: View [ … ] ]\n```\n — and every subclass's and use site's children go into `body`, in order, and a `layout:` written with them goes too, arranging them there; the base's children keep its layout. **A child can exist conditionally:** `exists = { … }` builds it while true and discards it while false, in its place (`visible` keeps a hidden view built — a focus sink, a definition read by its parent).\n\nBesides `class`, the top level holds `script`, `include`, `use`, `theme`, `style`, `schema`, `ship`, `defaultFlags` and `declareVersion` — the complete set, **in any order**, before or after the root instance; `extends` may name a class declared later in the file. **`script { … }`** holds free TypeScript — helpers, parsers, whole libraries — and may **`import`** ES modules, bundled at compile; **` script [ \"file.ts\" ]`** is the same block loaded from a file. A program's script blocks share **one scope, in source order**, and a constraint may call into script, opaquely (§5). A script runs on every host, so it uses only what all of them provide; one written for some hosts says so — **`script [ host = browser ] { … }`** — and the compiler refuses an unmarked script's host-only names ([Structure](declare-docs:guide:structure)). **```\ninclude\n[ \"path.declare\" ]\n```**\n merges another file's top-level declarations, once. **`use [ Name ]`** keeps a class the build would otherwise drop, for code that constructs it by name (`createView`, §7). **` ship [ … ]`** says what a self-contained package must carry beyond what its source names ([Packaging](declare-docs:guide:packaging)); **`defaultFlags [ … ]`** gives the program's own defaults for the platform's flags, such as `render = canvas` ([defaultFlags](declare-docs:language:defaultFlags)); **`declareVersion [ \"0.6.0\" ]`** says which release a file was written for, and no program needs it. **`theme Name [ … ]`** and **` style Name [ … ]`** are named records of literal values — a token record, and the style of a run of text with no view (§9).\n\n`classroot`\n**`classroot` is legal only inside the body of a `class` you are defining, and nowhere else** — if you are not writing `class Name extends Base [ … ]`, you do not want it. It names **the instance itself**, from any depth inside the class: the reach for a handler or a deep subview acting on the instance, and the explicit spelling when a nearer child shadows a bare name.\n\n```\nclass WeatherTab [ selected: boolean = false,\n    label: string = \"\",\n    select() { selected = !selected },\n    header: View [\n        onClick() { classroot.select() },              // `this` here is the header, not the tab\n        caption: Text [ text = { classroot.label } ]  // reaches the tab from a leaf\n        ]\n    ]\n```\n\nA **direct** child of the class body can reach the same instance as `parent`, and that is legal — `parent` is the enclosing view, which for a direct child is the instance itself. The difference shows up later: nest that child one level deeper and `parent` now means the new wrapper, while `classroot` still means the instance. Reach for `classroot` when you mean the instance, and keep `parent` for when you mean *whatever encloses me*.\n\nA `{ }` as an attribute's value is a **constraint**: re-evaluated when, and only when, its inputs change.\n\n```\nx    = { parent.width - width - 20 },               // stays 20 from the right edge\nfill = { selected ? 0x4169E1 : 0x191970 },           // royalblue / midnightblue\ntext = { data.failed ? \"Couldn’t load\" : \"Loading…\" }\n```\n\n**Dependencies are extracted by the compiler.** It reads your expression, reads *through* what it calls, and wires what it can name once. A read it can see but not name — through a closure's parameter, a local alias, or a value a method hands back — keeps that constraint on runtime tracking, where each read is observed as it runs. What it cannot follow at all is a compile error (below).\n\n**A constraint stays live through everything Declare it reaches.** Call your own methods, chain array operations, read through a closure — every read inside all of it is a wired dependency, rebased onto what you passed, so `{ this.price(app.cart) }` depends on whatever the `price` *method* reads of the cart. The analysis collects *potential* reads, not observed ones: `{ a ? b : c }` depends on all three. A `script { }` function is the one opaque call: script is outside the reactive system, so `{ fmt(app.total) }` depends on `app.total` — the values you pass — and never on what `fmt` does inside. Pass values, not nodes (a node reference never changes, so a node-typed argument is refused); a helper that should be *analyzed* is a method.\n\nReads are symmetric — a bare read **is** the tracked read. **Only a change notifies:** a write, or a constraint re-deriving, that lands on the value already there (the same number, string or boolean, the same object) wakes nothing. A new array or record is a change, even with the same contents.\n\nA handler's writes do not take effect one at a time. When it returns, everything it changed is applied **together** — constraints re-derive, views appear and retire where data now says so, layout places, sizes update — one indivisible step, run to completion, called the **settle**. Nothing paints in the middle of one, and no time passes inside one: a fetch or a glide cannot be *in* a settle, only cause the next. This is why the world is never half-updated, and why history can count \"one entry per settle\" (§7). Animation is a user of it, not an exception: a Spring writes its attribute once per frame, and each frame's writes get a settle of their own — motion is many small settles, never one long one.\n\nInside a handler, the world you read is the world *before* your writes land: an attribute you wrote reads back as written, but nothing derived from it has moved yet. Almost always the right response is no response: state what should be true with a constraint, and it is true after this settle and every one after it. But some work is irreducibly a *reading* of the new geometry — aiming a camera at a view your write just caused to exist, measuring where something landed. For that, leave one named step on the far side:\n\n```\naddItem() {\n    app.d.set([\"items\", 0], { label: \"new\" })\n    afterSettle(app.showNewest)                   // runs once, when THIS settle's constraints rest\n    },\nshowNewest() { app.frameOn(app.list.first) }      // the new row is real, placed, sized\n```\n\nThe step runs exactly once, when the constraints your handler moved have come to rest, before anything presents. What it assigns is settled in a further **round** of the same settle, as is what an `onChange` assigns; the settle ends when a round assigns nothing, and 100 rounds stop it with an error naming what kept it going. Constraint first, `afterSettle` second, and never for waiting — anything later is a value changing, which is what constraints are for.\n\nBoot is the one settle with no handler inside it, so its close is **delivered** instead: `onReady()` fires once, on the App only, when the first settle has completed — tree standing, geometry computed, before anything presents, so what it does is in the first frame the user sees. Readiness is usually a value; keep `onReady` for the genuinely once-and-imperative: seed the camera, open the socket.\n\nA `{ }` can appear on either member kind from §3 — **setting** an existing attribute, or **declaring** a new one with a computed default — and one difference decides everything: who owns the value.\n\n| you wrote | owned by its constraint? | reading it | assigning to it | reach for it when | \n|---|---|---|---|---|\n| `width = { … }` —**set** an existing attribute | yes | subscribes to it | **refused** at runtime | the value is derived and should stay that way | \n| `segIndex: number = { … }` —**declare** with a default | no | subscribes to it | lands, and the formula is gone | you may want to take the value over later | \n\nEither kind is worked out once and kept, and worked out again only when what it reads changes: reading one, however often, costs nothing. So a value that depends on several conditions names them (`open: boolean = { … }`) and reads the names, rather than nesting `? :`; the compiler warns when choices nest three deep (` DECLARE4025`).\n\nUse both; know which you wrote. One rule covers every case: **derived state is never assigned — change its inputs instead.**\n\nOne mechanism takes over a constraint-owned attribute without assigning to it. An `Animator`, a `Spring`, or a `State` override **suspends** the driver and **resumes it, re-evaluated,** on completion — the sanctioned path, and why a state may override a `{ }`-owned attribute at all.\n\nA constraint reads specific things, and the compiler must be able to follow every one. When it cannot, that is a blocking compile error — `DECLARE7001`, the *residue*, meaning the part of an expression no static reading can name — rather than a silent fallback. The diagnostic names the exact read it could not follow and the rewrite that resolves it. Three instincts account for most of them:\n\n`this.children.map(…)`. The number you want lives in the data, not the views: count the Dataset (§7).`this[k]`. Name the attribute, or move the lookup into a method the compiler reads through.`total = { total + tax }` reads like a harmless adjustment and is a cycle by construction. Derive from a base attribute, not the one you are setting. (A provided value avoids this: `theme = { { ...provided(\"theme\"), accent: red } }` reads the **`script { }` is foreign code — wholly outside the reactive system.** It may hold arbitrary TypeScript: stateful helpers, caches, classes, whole libraries — but not the app's model (a derivation over its data is a method) or its look (a repeated color is a theme token). The compiler type-checks a script body but does not trace its reads: a call depends only on its arguments, and the function's own state is invisible — if a function's answer can change without your inputs changing, hold that state in a node. Two uses stay refused: a constraint reading a script `let`, and any body writing one — state that changes is an attribute. Handler code is under none of the *reactivity* rules above — it is ordinary TypeScript: locals, loops, `switch`. It reaches the world through members, not host globals: a request is a `DataSource`, a repeating call a `Time`, one later call `afterDelay(ms, fn)`. A handler is synchronous (no `async`).\n\nWhich globals a piece of code may name depends on where it is written:\n\n`Math`, `JSON`, `Date`, `Intl`, `Number`, `String`, `Array`, `Object`, `Map`, `Set`, `RegExp`, `Promise`, …), and `URL`, `URLSearchParams`, `console`, `structuredClone`, `encodeURIComponent` and `decodeURIComponent`.` fetch`, the timers (` setTimeout`, `setInterval`, `queueMicrotask`, `requestAnimationFrame`), `performance` and `globalThis`. The compiler refuses each and names the Declare way: `DataSource`, `Time`, `afterDelay`.` script { }` block:`measureText`, the builders and `Color`), except those that answer for the calling node (` provided`, `providedTextStyle`, `script [ host = browser ] { }` block:`window`, `document` and the rest of the browser as well. An unmarked script runs on every host, so the compiler refuses those names there. The views a program draws belong to the runtime: they differ between renderers and don't exist on the Mac, so a script never looks them up or changes them. Whatever you'd reach into the DOM for is already a Declare attribute or class, so ask `declare-help` first.\n**Each of `x`, `y`, `width` and `height` has one decider: the view, its parent's layout, or (a size only) its content.** A size the view does not state is its content's — a `Text`'s run, an image, its visible children's boxes, padding included — inside a layout too: unlike flexbox, nothing stretches without `align = stretch`. A child sized from its parent (` 100%`, or a `{ }` reading the parent's size) is not counted in the parent's size from its content, so a view sized by its children can't size them; they fill it by `align = stretch`.\n\n**A layout is an object** — a library class or your own, with one method — set as the `layout:` member and swapped like any member. It places every child along its flow, across it only with `align`, and sizes the children that ask: a child tells it facts (` flexes` for a share of what is left, `shrinks`, a `minWidth`/` maxWidth` range) and never also states what the layout decides. Along the flow, `100%` is the whole room, not what is left; a hidden child leaves the flow.\n\n```\nlayout: SimpleLayout   [ axis = y, spacing = 10 ],\nlayout: WrappingLayout [ spacing = 20, rowSpacing = 20 ]\n```\n\n`padding` — one number, or `[top, right, bottom, left]` — gives a view a **content box**: `x = 0`, `width = 100%`, `center` and `end` mean that box for every child, laid out or not; `{ parent.width }` still names the whole box, and paint (`fill`, `stroke`, `cornerRadius`) stays on it. `stroke` takes the same one-or-four shape, `null` for a bare side.\n\n**Stacking order is declaration order**; later siblings paint on top. There is no `z-index`, so chrome that must float above everything is declared last (a menu, popover or dialog is a library overlay, which floats on its own).\n\nA view has no `overflow` attribute. Ranges (`minWidth`, `maxHeight`, …) bound what a layout gives; elsewhere `contentWidth` and `contentHeight` say what the content wants, so a clamp is arithmetic.\n\n```\nheight = { Math.min(contentHeight, 480) },    // grow to a cap, then stop\nclip   = true                                // hide whatever passes the cap\n```\n\n**Scrolling is the platform's.** It moves a scroller on its own time — the user's hand, momentum, a glide — and the program never sets where a scroller is. It reads the facts the platform writes (`scrollY`, `userScrolling`) and makes requests the platform carries out when it can (` scrollTo`, `scrollIntoView`): clamped to the content, held until the pane can take them, waiting while the user scrolls.\n\n**Every scroller is a pane, the App included**, and content scrolls only where it outgrows its room, so a layout that fits its window never scrolls. Choosing how an app scrolls is choosing whose content may outgrow its room. The App's pane is the host's own scroll — in a browser, the page — and only it gets what the host does for a page: a phone's bars collapse as it scrolls, and a pinch zooms it. So a column of content scrolls with the App, and a view that must stay on screen opts out with `ignoreScroll` (`y = end` at the foot). A region that scrolls on its own, a list beside a document or a map, is a pane inside it (`scrolls = y`), and **a pane needs room it is given**: one sized by its content just grows, and the page scrolls instead. `scrolls = none` says overflow is cut off (and, for the App, that the page does not bounce). `clip = true` clips children to the box; a child opts out of its parent's regime with `ignoreLayout`, `ignoreClip` or `ignoreScroll`.\n\n**Positions are literals.** `x = center` and `x = end`, and the same on `y`, place a view against its parent — resolved reactively, exactly like `100%`. The closed set is `center` and `end`; the start is `0`. `center` puts a view's center (`centerX`, `centerY`: its box's middle unless it says otherwise) on the parent's middle, as `align = center` does. A label wants its *ink* centered — the cap band, not the font box with its uneven leading — so the library's `TextLabel` is a `Text` whose `centerY` is its capitals' middle.\n\n**The App fills its host by default**, so `App [ … ]` with no size line fills the window and resizes with it, while an explicit size makes a fixed widget. Responsive code reads `app.width`; the App also carries the live host facts — viewport, colour scheme, pointer — as reactive attributes.\n\n`App [ minWidth = 480, minHeight = 420 ]` sets a **size floor**: below it the app holds the floor and the host pans instead.\n\n→ the layouts that ship: `library/` · their attributes: the reference (`npx declare-help <name>`)\n\n**Data is JSON, held in the tree.** A `Dataset` holds data — written inline, derived from other state, or fetched by a `DataSource` — as a named member of the node whose subtree uses it. A view's `datapath` points it at a place in that data, never at a value computed in `{ }` (computed records are a derived `Dataset`). `:path` reads relative to it in the view and every member below, visible or not — a `Spring`'s target, a `Time`'s gate, a `Node` class on a record — and a path matching many records **replicates** its view, one instance per record.\n\n```\nApp [ width = 420, height = 260, fill = midnightblue, textColor = gainsboro,\n\n    people: Dataset {\n        { \"rows\": [ { \"name\": \"Ada\",   \"score\": 90 },\n                    { \"name\": \"Grace\", \"score\": 80 } ] }\n        },\n\n    list: View [ x = 20, y = 20, datapath = { people.value },\n        layout: SimpleLayout [ axis = y, spacing = 10 ],\n        View [ height = 20, datapath = :rows[],                // one instance per record\n            n: Text [ width = 150, text = :name ],\n            s: Text [ x = 150, text = :score ]\n            ]\n        ]\n    ]\n```\n\n**The `[]` suffix is what replicates.** `datapath = :rows[]` says *this path matches many records, so make one instance of this node per record*; without the brackets, `:rows` is an ordinary read of whatever is there, and `[]` may appear only at the end of a path. So an attribute on a replicated node reads that node's own record; a field of the record above reaches it through a member declared where that record is current: `class Team [ team: string = { :name }, Text [ datapath = :members[], text = { :name + \", \" + classroot.team } ] ]`.\n\nBetween those, a path may **select**: `:path` follows JSONPath (RFC 9535) over the shipped subset — `[0]`, `[-1]`, `[1:4]`, `[*]`, `['quoted key']`. So `:rows[*].label` is every row's label, and `:rows[2:8][]` replicates exactly that range, each instance cursored at its real index. `:@` is the record itself, and `[( expr )]` a key computed in TypeScript — `:@[(field)]`.\n\nA `Dataset`'s literal body is **strict JSON** — quoted keys, no trailing commas. The replicated node is anonymous, but names inside it resolve per instance. **Identity is inferred** — a record's `id` field is its identity by convention, so reconciliation reuses instances across sorts, filters and edits with nothing declared; when identity lives under another name, `identityKey = :email` on the replicated node says which. An instance reads its record's index in the array as **`rowIndex`**, a fact, so records carry no position fields.\n\n**Count the data, not the tree.** A Dataset's `.value` is the parsed data, so a count is ordinary TypeScript on it, never a walk of rendered rows.\n\n**A `DataSource` is a remote resource whose lifecycle is reactive state** — `data: DataSource [ url = \"data/events.json\" ]`. **Nothing loads on its own** unless you set `autoFetch = true`; forgetting `.fetch()` is the silent first bug, and `onInit()` is the usual place for it. Screens then derive from the resource (`shown = { data.loaded }`) rather than being toggled. An optional `schema = [ field: type, rows[]: [ … ] ]` declares the response's shape: it validates the payload on receipt — so malformed data yields `.failed` rather than `undefined` three constraints deep — and lets every `:path` be checked against the shape at compile time. Without one, paths are dynamic: an unresolved `:path` yields null and the bound attribute falls back to its default. The request's own parts — method, body, credentials, headers — are ordinary reactive attributes, so a write is a `DataSource` too: `method = \"POST\"`, a `body`, `.fetch()` from the handler, `onLoad()` for what follows the reply, `onError()` for what follows a failure — whose `failure` says why, and so whether a write went through (`rejected`: no; `unreadable`: yes; a `timedOut`, `networkError` or `serverError`: unknown). A request silent for `timeout` seconds is given up.\n\n**A schema is a named type, in the classes' namespace — declared once at top level, used in any type position.** `schema Task [ id: string, done: boolean, status: \"open\" | \"closed\", note?: string ]` is then a type like any other (`sel: Task? = null`, `advance(t: Task) -> Task`, a field of another schema — `owner: Person`) — and there, as for a class or `View`, a trailing `?` is what lets it be empty: `Task?` may be null, `Task` never is, a dataset declares the shape of its data with it (`schema = [ tasks[]: Task ]`, or `schema = Task[]` for a bare-array response), and its `.value` is then *typed* — `nest.value.tasks` is `Task[]` in every `{ }` body, so a misspelled field dies at compile time and the `as` casts go. The runtime enforces the same declaration at every boundary, the mutation verbs included. The schema grammar is the subset of TypeScript that JSON data can carry, so one declaration is checked by the compiler *and* enforced against live data; TypeScript's spellings of a field are the same field (`tags: string[]` is `tags[]: string`, `km: number | null` is `km?: number`). Extra keys always pass: a schema declares what the program relies on.\n\n**Two-way binding is opt-in, with `<->`, on what a class hands back through `commit`** — a control's value, an overlay's `shown`, a `Disclosure`'s `open`. `Checkbox [ checked <-> app.muted ]` is shorthand for `checked = { app.muted }` plus `commit(v) { app.muted = v }`. The place is a datapath (`:title`, against the nearest enclosing `datapath`), `{ :@[(name)] }` for a field chosen by name, or an attribute (`app.muted`, `classroot.size`). The types must match, and the element may not also declare `commit`: a conversion is the pair written out. A constrained value with no `commit` is a compile error, since every change would be refused.\n\n**Datasets are mutable from handlers** — `:done = v` writes the record under the cursor; `d.set(path, v)`, with `insert`, `removeAt` and `move` for collections, writes anywhere. A path is a segments array (`[\"rows\", 0, \"name\"]`) or a JSON Pointer string (RFC 6901 — `\"/rows/0/name\"`, and `\"/rows/-\"` appends). A write wakes exactly the constraints that read the changed region.\n\n**A derived dataset recomputes from its inputs** — `cal: Dataset [ contents = { app.buildModel() } ]`, a method the compiler reads through; with a `schema`, its `.value` is typed. One that selects — filter, sort, group — **holds its source's records**, so a row bound to it writes its record as anywhere; what its code *made* is read-only. To add a computed field to a record, **wrap it, don't copy it**: `{ ev: e, lane: n }` holds the record itself, and a row bound through `:ev` edits the source.\n\n**Records of different kinds are different classes** — `classFor = { :kind == \"heading\" ? Heading : Item }` on the replicated node; what state a row is *in* stays a `State`.\n\n**Large collections virtualize on one word.** `virtualize = true` on a replicated node builds only the rows near the viewport and leaves the rest logical — same records, same paths, same behaviour. It is a boolean, **off by default** — full materialization keeps browser find working over every record. Nothing else to write: no row heights, no scroll wiring, no keys.\n\n**When structure is genuinely imperative**, build it from a handler: `parent.createView(tag, props)` instantiates a class by name into the receiver — a full citizen, and the parent's arrangement and auto-size take it in on arrival. Its pair is `view.discard()`: one verb unlinks the view, retires its whole subtree, and re-packs what it leaves behind. Reach for replication first — it reconciles, keys, and tears down for you — but the imperative door is open (`use [ Name ]`, §4, keeps a string-named class in the build).\n\n**Data that keeps arriving is a stream** — `EventStream` and `Socket`, connected exactly while `active` and a `url` say so, delivering `onMessage` and a reactive `last`. Same lifecycle shape as a `DataSource`, and nothing to unsubscribe.\n\n→ `Dataset` and `DataSource` attributes, `Stream`/` EventStream`/` Socket`, `View.createView`, `View.discard`: the reference (` npx declare-help <name>`) · paths, selection and editing: [the data chapter](declare-docs:guide:data) · virtualization at scale: [collections](declare-docs:guide:collections)\n\nThere is no router. **`location`** is the app's slice of the URL, as one two-way reactive string the host seeds before first settle, mirrors outward, and writes back on back/forward. A view that manifests a location declares it with **`shows`**; a place inside one is named with **` anchor`**; and any view becomes a link with **` link`** — one reference string, the same one an authored Markdown href carries:\n\n```\nhome: View [ shows = \"home\",\n    pill: Text [ text = \"Why\", link = \"#why\" ],           // a destination\n    faq:  Text [ text = \"The note\", link = \"#story\" ],    // an anchor — its location DERIVED\n    repo: Text [ text = \"GitHub\", link = \"https://github.com/example\" ]\n    ],\nwhy: View [ shows = \"why\",\n    note: View [ anchor = \"story\", width = 200, height = 80 ]\n    ]\n```\n\nBecause references are declared rather than assembled, the compiler gains a **registry** and checks every one at build: a typo'd `#stroy` is a compile error naming the real names. A linked view realizes a real `<a href>`, so ⌘-click and copy-link work, and the build's crawler walks the same edges — which is what makes a deep link indexable.\n\nArrival is one operation whatever caused it, so a link, a prose href, a pasted URL and the Back button are the same event, and an app answers it in one place: a hook to transform or veto the reference, and a handler delivered the view it names once that view exists. Undeclared, arriving scrolls; declaring the landing replaces that with your own idea of showing, a camera or a pan.\n\n**Location is the app's shareable coordinates** — what a recipient should see when handed the URL, nothing more; a draft or a session's working values are ordinary attributes. Between those two sits a third kind, state the Back button *should* undo but a stranger should never see, and it has its own attribute: **`waypoint`**, location's twin, carried in the history entry and never in the URL. A history entry is the pair, one per settle in which either changed, and one Back restores both. The dividing test takes five seconds: *would you hand the value to a stranger?* Yes → `location`. No, but Back should undo it → `waypoint`. Neither → an ordinary attribute.\n\n→ `link`/` shows`/` anchor`, arrival and the crawl: the reference (` npx declare-help <name>`) · [the URLs chapter](declare-docs:guide:urls)\n\n**Handlers are methods named with an `on` prefix**, answering this node's own events: `onClick`, the pointer and touch families, `onKeyDown` and `onKeyUp` on the focused view, and `onInit` after construction. **`onChange`** answers the values a node names in `trackChanges = [ … ]`: it fires at the close of each round of a settle in which one of them moved, once — `onChange(e: ChangeEvent)`, `e.changed` one `ValueChange` (`name`, `previousValue`, `currentValue`) each: for a state change the program must act on, never to follow a value (a constraint) or to move one (a Spring).\n\n**A key is looked up outward**, like a provided value: from the focused view through its containers to the App, the nearest `keyBindings` record naming it takes it — `({ key: \"Ctrl+S\", command: \"save\" })` runs that view's method, and a `false` return hands the key on; a menu item's or button's `command` is looked up the same way. `keyBindings` is the one attribute that adds up across class layers instead of replacing — a use site's records come first, its class's still apply — so your bindings never cost a `Button` its Space and Enter. An `onKeyDown` hands the keys it doesn't take, Tab included, to `super.onKeyDown(e)`.\n\n**Pointer input has two layers.** The **raw** layer — `onPointerDown`/` Move`/` Up` (every move, hover too), the multi-finger touch family, and `onWheel` — reports what the pointer physically did. The **resolved** layer — `onClick`, `onDoubleClick`, `onHold`, and `onDragStart`/` onDrag`/` onDragEnd` — reports what the user *meant*, decided by watching the gesture.\n\n*Pointer*, not *mouse*: one handler serves a mouse, a fingertip, and a pen, and it fires at once for each — there is no compatibility event and nothing to fall back to. `onTouch…` is the separate multi-finger stream, for when you need the finger list rather than a point.\n\n`onClick` activates, `onPointerDown` manipulates.\n\nReach for the raw layer to run a command and it misfires on touch, where a finger landing on a button may be starting a scroll. A press is a click or a drag, never both: a view that takes no clicks drags from the press, one that does once the press wanders. A view declaring `onDoubleClick` hears its first click at once, its second as `onDoubleClick`. Every pointer event carries its point both ways: `x`/` y` in the view's own coordinates, and `rootX`/` rootY` in **root space** — the frame a drag reads, because it does not move with the dragged thing — with `deltaX`/` deltaY` the root-space movement since the press.\n\nOne fact a drag handler must not miss: a drag taken back — Escape, a system interruption — ends in `onDragEnd` with **`e.canceled` true**. Commit only when it is false.\n\n**The browser owns every gesture until a view claims one — and declaring the handler *is* the claim**, taking exactly what that handler needs to fire and nothing more: a drag event claims the single-finger drag over its view and subtree while pinch stays the user's, the raw touch family claims every finger (the app then owes its own zoom), `onWheel` claims the wheel stream — trackpad pinch included, arriving with `e.pinch` true — and a scrolling view is the opposite move, delegating its panning to the browser. Claim the least you need, on the smallest view that needs it; claiming at the App is legitimate exactly when the app *is* the surface — a map, a canvas, a game taking **full gesture control**.\n\nA view at `opacity = 0` is invisible but entirely present — it holds its room in the layout and still takes clicks, subtree included, as CSS opacity does: the natural press-catcher, a scrim behind a modal.\n\n`visible = false` is the other tool, and it is the stronger one: it removes the view from input *and* from its parent's layout and auto-extent. So a fade that should end in absence is `visible = { opacity > 0 }`, while flow content that merely fades in should stay visible and let opacity do the work. `pointerEvents = \"none\"` is the third, for a view that should be seen and not touched. **A view takes the pointer when it has declared an interest in it** — a handler, a `link`, a `tooltipLabel`, or a `scrolls` axis, since a scroller answers drags and wheels with scrolling — and content behind such a view is not reachable through it.\n\nEvery view carries two read-only intrinsics. `hovered` is true while the view sits on the live hit chain — the topmost visible view under the pointer, plus its ancestors — so it is occlusion-correct, and it is always false on touch. `pressed` is true from a pointer-down on the chain until release. Read them anywhere a value goes, including as a state's condition (§10):\n\n```\nfill = { hovered ? 0x4169E1 : 0x191970 }   // royalblue when hovered, else midnightblue\n```\n\nOn a view that declares `disabled` (every `Control`), both are false while it is disabled, and `pressed` is also true during a keyboard press — so a control styles from the same pair. Declaring or assigning either is refused, the same guard §5 describes.\n\nHaving no CSS (§1) is also what makes a non-DOM renderer possible. Your CSS *knowledge* transfers: colors, font stacks, and shadows read the same. The names do not. A border is a **stroke**, rounding is **`cornerRadius`** (one number, or `[topLeft, topRight, bottomRight, bottomLeft]` to round only some corners), and `borderWidth`, `boxShadow`, and a box's `outline` do not exist.\n\nWhat replaces the cascade is **provided values**: `provided(\"name\")` reads the value the nearest ancestor makes available under that name, and *providing* is setting a value on a node — no keyword. The text face — `fontFamily`, `fontSize`, `fontWeight`, `textColor`, `letterSpacing` — works this way (each lives on `Text`, defaulting to `provided(…)`, so setting one on a container provides it to the runs below), and so does **`theme`**, a token record every color in an app should name once.\n\nA **typeface is an object in the tree**, like an `Image` — `brand: Font [ FontFace [ … ] ]`, usually on the App — and `fontFamily` takes that object as its value. So a face is a value like any other: choosing one is an assignment, and text, layout and drawings follow a face landing with no code of yours.\n\n```\ntheme = { app.systemDark ? SanFranciscoDark : SanFrancisco },      // on the App: PROVIDE a preset, light or dark\nfill  = { provided(\"theme\").surface },                       // READ it anywhere below\n\npanel: View [                                                // on a DESCENDANT, provide a modified one\n    theme = { { ...provided(\"theme\"), accent: 0xCC3333,      //   every provided(\"theme\") below reads this;\n                accentHovered: 0xB82E2E, accentPressed: 0x9E2828 } }   //   a role changes with the states named from it\n    ]\n```\n\n`provided(…)` is the one new construct — an explicit up-the-tree read, bare in `[ ]` (like `Gradient.linear(…)`) or a call in `{ }`. It is explicit on purpose: it reaches past this node, and a non-local read is worth showing. You rarely write it — `Text` and the library widgets read the face and theme values *for* you; you write it where your own code reads a value from up the tree. A read that finds no provider falls to an optional default (`provided(\"theme\", SanFrancisco)`), else throws, naming the value.\n\nStart from a library preset — each a light record with a `…Dark` companion, in scope by name — and spread to change a token; the standard library reads specific token names (```\nnpx declare-help\n\"theme tokens\"\n```\n lists them), so build from a preset, not an empty record. A token's relatives share its name (`accent`, `accentHovered`, `accentPressed`, `accentTextColor`): change a role, change them with it. Declare your own with `theme Brand [ … ]`, a top-level record like a `style` bundle. The `{ { … } }` is not special syntax: the outer braces open the constraint, the inner ones are a TypeScript object literal. A token read from `provided(\"theme\")` must be one some theme declares — a preset, the library defaults, your own `theme`, or a record your `theme = …` writes — so a misspelled token is a compile error.\n\nA **`style` bundle** is a named record of literal text attributes — the style of a run of text that has no view, which a `<span class>` inside `HTMLText`/` Markdown` wears. Like a theme record it holds literals only: it has no place in the tree, so nothing in it can depend on where it is used, and its name is a value in any `{ }`, typed by the fields it sets. A look that follows the theme is written where it is used. To reuse a look across whole views you **subclass** instead (`class PriceTag [ … ]`).\n\n```\nstyle Keyword [ textColor = #C678DD, fontWeight = bold ]   // a <span class='Keyword'> in prose wears it\n```\n\nRich-text content can also carry **views**: inside `HTMLText`/` Markdown`, a self-closing tag that the inherited `tagViews` map names (`tagViews = { { Chip: Chip } }`, then `<Chip label='docs'/>`) places one real view of that class in the flowing line, its attributes converted by their declared types. With no map, no tag is a view. A `<span class>` remains a style; a tag is never one.\n\nPrecedence is fixed: a value **set locally always outranks a provided one** — a `Text` that sets its own `fontSize` ignores the region's, and a provided value is a default a node overrides, never a rule that fights your code.\n\nBoth halves of this section do the same thing: **declare the destination, not the transition.**\n\nA **state** is a named, reversible bundle of attribute overrides applied while a condition holds.\n\n```\nApp [ width = 360, height = 200, fill = black, textColor = whitesmoke,\n\n    card: View [ x = 30, y = 30, width = 300, height = 70, cornerRadius = 10, fill = midnightblue,\n        Text [ x = 20, y = 20, fontWeight = bold, text = \"Summary\" ],\n        open: State [ applied = { hovered }, height = 140, fill = steelblue,\n            Text [ x = 20, y = 50, width = 260, textColor = gainsboro, wrap = true,\n                text = \"height, color, and this whole line arrive together\" ]\n            ]\n        ]\n    ]\n```\n\nWhile the condition holds, the overrides — and any children declared inside the state — apply; when it lifts, everything reverts. The \"set it on enter, forget to unset it on exit\" bug is unrepresentable, because an attribute's value is a pure function of its base plus the active states. That is what lets states compose and interrupt. When two active states override the same attribute, the later declaration wins.\n\n**A state overrides its own element's attributes only.** It cannot reach into a child — `top.bg.opacity = 0.5` is a compile error, because a member always sets its own element's attributes. Those are the attributes it declares: a value it only provides to its contents (`fontSize` on a View) is not one, so the condition goes in the value, `fontSize = { large ? 20 : 16 }`. To coordinate several views from one condition, declare a state on each of them reading the same flag, or give the child a constraint that reads it:\n\n```\nbg: View [ opacity = { app.open ? 0.5 : 1 } ],                 // the child derives\nbg: View [ dim: State [ applied = { app.open }, opacity = 0.5 ]\n    ]   // or owns a state\n```\n\n**Inside a state, an override is the view's.** Its value is computed on the view it changes, so `this`, a bare name and `parent` mean what they would written on that view: `height = { width / 2 }` is half the card's own width, and `parent` is the card's container. The children declared in a state mount onto the view, and read it the same way. The state's own members — `applied`, anything it declares, `onApply`/` onRemove` — are the state's: there `this` is the state and `parent` the view, so `applied = { parent.expanded }` reads the card's own flag. A method written in a state is a compile error, since a state changes attributes and children, never what a method does.\n\nA state is driven by its condition (`applied = { … }`) or imperatively by the verbs — `apply()`/` remove()`/` toggle()` from a handler. One or the other: the gate owns `applied`, so a gated state changes when what the gate reads changes.\n\nA **`Spring`** drives one attribute toward a reactive target. Declare where the thing belongs and the spring finds the path, so a change of target mid-flight is a new destination and interruption needs no code.\n\n```\nslide: Spring [ attribute = x, to = { on ? 340 : 20 }, stiffness = 170, damping = 20 ]\n```\n\nMotion is the one place time is legitimately an input (§1, *nothing waits*): `Animator` for a value that changes *over* a duration, `Spring` for one that moves *toward* a target — the house idiom — and `Time` for the clock itself — its facts (`now`, `minute`, …) are inputs a constraint derives from, and its `onTick(dt)` at `tick = frame` is the one per-frame handler, there only to **integrate**, the previous value being the input; a per-frame `onTick` that ignores `dt` is polling. A timing rule — a debounce, a delayed dismissal — is `afterDelay(ms, fn)`, owned by its node and cancelled with it; a period is `Time [ tick = 5000 ]`. (Finishing after your own change has landed is neither — that is `afterSettle`, §5.)\n\nBecause states, springs, and layout all sit on one reactive core, *arrangement* animates: spring a few geometry scalars and every constraint derived from them moves in lock-step.\n\n→ `State`, `Spring`, `Animator`, `Time` attributes: the reference (`npx declare-help <name>`) · the idiom at scale: `apps/calendar/calendar.declare`\n\nDeclare ships a standard library of classes in `library/`, written in Declare itself with no privileged API underneath. It **auto-includes by bare tag** — no import, no module ceremony — its classes read the provided `theme`, and focus behavior (Tab traversal, activation, a traveling focus indicator) is provided undeclared. Check there before building a control by hand; one you build **extends `Control`**, which makes it focusable and keyboard-activated, makes its `hovered`/` pressed` respect `disabled`, and routes pointer and keys alike to the `press()` you override.\n\nTwo contracts are worth learning because your own classes should obey them too.\n\n**The value pattern.** A control's value is a plain reactive attribute, in one of two forms: standalone, where the control owns its state and you read it by name; or **owned by your state or your data, deriving down and delivering up** — the pair, or `<->` for it. The pair is the §5 rule at work. A control's default `commit` writes its **own** attribute, so `checked = { app.muted }` with no `commit` override makes the person's change an assignment to a constraint-owned attribute — refused (§5). Override `commit` and the change goes where the value actually lives.\n\n**Editing**, the same for every value control (`ValueControl`): the person's change is put to `admit(v)` before it appears (return what to show, or `null` to refuse), then shown and handed to `commit` — after each change, or once at the end with `commitOn = \"end\"`. **While an edit is open, the control shows the person's change, not your value**, so a `commit` that clamps doesn't fight them; when it ends (they leave, release, press Return; a field's Escape cancels) it shows your value. Any other change to your value ends the edit. `validate` and `required` only judge. A control of your own reports with `edit(v)` and draws from `shown`.\n\n```\nCheckbox [ label = \"Mute\", checked = { app.muted },\n    commit(v: boolean) { app.muted = v }\n    ],\nSlider   [ value = { app.volume },\n    commit(v: number) { app.volume = v },\n    disabled = { app.muted }\n    ]\n```\n\n**What a class arranges, it takes as records.** If the class arranges it — menu items, a dialog's buttons — it takes plain record arrays and hands the choice back through a method. If *you* arrange it, it is not a class's feature at all: it is views, a layout, and replication.\n\n→ what ships and how it is built: `library/` · each class's attributes: the reference (`npx declare-help <name>`)\n\n**Every diagnostic carries a code, a line and column, and the fix.** Apply exactly the named fix, change nothing else, and compile again. All independent errors in a phase are reported together, and typechecking of every `{ }` body is part of every compile.\n\n**The formatter (`npx declare-format`) owns the house style**; run it rather than hand-aligning. What it cannot decide for you is naming — camelCase — and that **a leaf goes on one line**, which most of a UI is.\n\n**A running program answers questions about itself.** A clean compile means the compiler found nothing wrong, not that nothing is wrong: layout, fonts, paint, and input routing do not exist until the program runs. `__declare.explain(path, attr)` answers *why* an attribute holds its value, giving the expression, the read-paths it was wired to, and their live values. (It is development tooling: a production build ships a stub unless you pass `declarec --debug`.)\n\nGET STARTED\n\nOpen Claude Code — or another coding agent — in an empty folder, and tell it what you want, for example:\n\nWrite me a kanban board using Declare, here: https://github.com/davidtemkin/declarelang\n\nWrite me a personal budgeting app using Declare, here: https://github.com/davidtemkin/declarelang\n\nProvide any required permissions.\n\nIn 15–20 minutes you'll have your first Declare app. That's it.\n\nCloning the repository gives you everything: the toolchain you build with, the docs and example apps, and Declare's own source to read. For a project of your own, install Declare as a dependency instead ([Embedding Declare in a project](https://github.com/davidtemkin/declarelang/blob/main/docs/operational/embedding.md)).\n\n```\ngit clone https://github.com/davidtemkin/declarelang.git && cd declarelang\n```\n\nGet the repository.\n\n```\nnpm install\n```\n\nInstall the toolchain's dependencies (TypeScript, esbuild, and the Chrome driver the checking tools run on). The clone ships prebuilt — no build step before first run. pnpm works too — the repo pre-approves esbuild's install script.\n\n```\nnpm start\n```\n\nStart the dev server. It prints its address — http://127.0.0.1:8200/ unless that port is taken, in which case it says so and names the next (`PORT=8201 npm start`). Browse to any .declare file's URL under it and the server compiles and returns the running app.\n\nWrite a program to my-apps/hello.declare and browse to it under the server's address — http://127.0.0.1:8200/my-apps/hello.declare on the default port. The program URL is the app's address.\n\nStart with **[Declare in 10 minutes](https://davidtemkin.github.io/declarelang/apps/model-tour/)**, a twelve-screen tour of how Declare puts things on the screen, with a live stage for each idea.\n\n[**The Declare docs**](https://davidtemkin.github.io/declarelang/apps/docs/) take it from there, in four parts:\n\nFAQ\n\nDeclare is a programming language for user interfaces — a domain-specific language, the way SQL is a domain-specific language for querying data. You describe an interface as a tree of views with attributes; any attribute can be a live expression, and when the things it reads change, everything that depends on it updates. All real logic is ordinary TypeScript. Programs compile in the browser or ahead of time, and one program renders to the DOM, directly to pixels on a canvas, or as a native Mac app.\n\nBecause most of what makes UI code hard isn't your application — it's the plumbing. In Declare there is no render lifecycle to manage, no state synchronization to orchestrate, no CSS cascade to fight, no build pipeline to configure. An application is a readable tree of declarations: the flagship calendar — four views, continuous zoom, drag-to-reschedule — is about 600 lines of code you can read end to end. Given the same brief, an agent's Declare app came out at half the code of its React app. And Declare is built for the era when much code is written by machines: the language is small enough to hand a model in its entirety, and strict enough to verify what comes back.\n\nDeclare is at its best where an interface has to be designed, not just assembled: custom, fluid experiences of the kind you find in the best native apps — calendars, editors, dashboards, product sites — where views become one another and motion carries meaning. Everyday apps come with it: forms, lists, settings screens and admin tools are what the library's controls are for, and content-heavy apps work well (Markdown rendering is built in). Everything on this site is a Declare program: the homepage, the documentation, the calendar, the desktop.\n\nAn AI can produce a standard-looking app easily, and in Declare it can produce one verifiably. A custom experience is a set of decisions — how it should look, how it should move, what should happen when — and those come from human judgment and direction. What Declare changes is how directly those decisions can be expressed in code: layout, motion, states and theming are the language itself, so what you meant stays legible in the code, and the AI that writes it, the compiler that checks it and the colleague who reads it later are all looking at the same design.\n\nYes, with effort. Windows that drag, resize and layer; minimizing into live thumbnails; a magnifying dock; menus that follow focus; other programs running inside windows — in a mainstream web stack each of those is usually its own library or its own project, and keeping them coherent (focus, stacking, hit-testing, animation that can be interrupted) is where the effort goes. In Declare they are the language and its library, and the [desktop](https://github.com/davidtemkin/declarelang/blob/main/apps/desktop/desktop.declare) is one program of 2,011 lines of code. That is why it makes a good acid test for any UI toolkit.\n\nTime and change live in the language instead of being bolted on:\n\n`Control` and yours takes clicks, taps, focus and keys exactly as theirs do, so there is no cliff between using a component and building one.`draw()`, clipping to any shape, filters and backdrop blur are attributes of a view, alongside its layout and motion, not a separate canvas or effects layer.`datapath`), and two-way binding connects editable fields to the data they edit.\nIt's a language, not a framework inside JavaScript. In React and its relatives, the UI is a function you re-run — the framework diffs the output and patches the page, and you manage the machinery (hooks, memoization, effects) that keeps re-running affordable. In Declare, the UI is a *standing structure*: values flow through it when things change, and nothing re-renders because nothing was ever a render. There is also no HTML/CSS/JS trinity — structure, style, and behavior are one tree in one language. Its nearest relatives are declarative-tree systems like SwiftUI and QML, but Declare is web-native, compiled, renderer-independent, and uses TypeScript — not a new scripting dialect — for logic.\n\nThe compiler parses the declarations, statically extracts every constraint's dependencies, type-checks every `{ }` body as real TypeScript against every class's typed API, resolves the components you use (the standard library auto-includes by name), and emits a self-contained program. The benefits: errors surface before the program runs, with messages that name the fix; reactivity is *derived by the compiler*, not guessed at runtime, so behavior is predictable and analyzable by tools; production output is small; and programs are data — the same compiler powers the documentation system, static extraction for crawlers, and live editing. The compiler itself runs anywhere — in Node, or in the browser.\n\nThe `[ ]` structure is Declare; everything inside `{ }` — expressions, event handlers, methods — is ordinary TypeScript, type-checked with full knowledge of every class's attributes. There is no new expression language to learn. The declarative layer contributes structure and reactivity; TypeScript contributes logic — and everything you (or your model) already know about it carries over.\n\nA reusable view is a class: `class PriceTag [ … ]`. Its attributes are its public interface, and it reports back through events it declares. Composition is just nesting: your classes are used exactly like built-ins, including replication over data.\n\nNo — and that's a feature. Styling is part of the language: paint attributes on views (`fill`, `cornerRadius`, `stroke`, `shadow`, text styles), theme records that reskin an entire subtree from one place, and named style bundles a subtree can switch between at runtime. Your CSS *knowledge* transfers — colors (named or hex), font stacks, shadows all read the same — but there is no cascade, no specificity, no selector debugging. This is also what makes renderer independence possible: the canvas renderer couldn't consult a stylesheet the browser owns.\n\nSide by side, yes; interleaved, no. A Declare app embeds in any page — including a React page. And inside a Declare program, the `DOMIsland` view hosts foreign content — a video player, a code editor, a React widget — in a box the Declare tree sizes and positions. What you can't do is put a React component *inside* the Declare tree as if it were a Declare view, or vice versa. The boundary is always an island, which is what keeps both sides comprehensible.\n\nNo router is needed: the URL is just an attribute. Declare `location` on your app and it follows the address bar. Setting it navigates, Back restores it, and a deep link is simply its starting value; the rest of the app derives from it like any other value. In the docs on this site, `#guide/14-data` opens that chapter directly. Deep-linked pages are crawlable too.\n\nAt build time, the compiler runs the app headlessly and bakes its content into the page as plain HTML: real headings, paragraphs and links. Crawlers and AI readers get that; people get the live app. No server needed: this site runs on GitHub Pages.\n\nBecause the compiler runs in the page, the page can edit and re-run itself: every sample on this site is live-editable — change the source and the app re-renders as you type. It restores view-source culture: \"View and edit source\" on any app here opens the viewer — a highlighted reader, the verbatim source, and a live-edit tab (`?viewer=edit` on the program's URL). And it means development needs no build step — the dev server and the browser use the *same* compiler with byte-identical output. For production you don't ship the compiler: the `declarec` build precompiles everything into a small artifact, no compiler aboard.\n\nOne program renders through managed DOM elements, directly to a single canvas, or in a native Mac host — same tree, same layout, same input handling, the three held to each other by a conformance suite (append `?render=canvas` to any app URL to see it). The Mac host is a native macOS application, AppKit layers in place of DOM nodes, with the runtime's kernel linked in natively; you build it from the repository with one command (`npm run build:mac`). What this buys: the language owns its semantics — no DOM assumptions leak into your program; the canvas path suits environments where a DOM isn't available or isn't fast enough; and future renderers can be added without rewriting applications. Programs also run headlessly — no screen, no renderer at all — which is what powers static extraction and testing.\n\nConcretely, measured from the deployed production artifacts:\n\n`declare-profile`, or the Inspector while you use the app) says which of Live numbers are on the homepage, measured from the deployed artifacts themselves.\n\nWhen machines write the code, the properties that matter change. Familiarity matters less; *verifiability* matters more. Declare's bet: give the model a small, closed, regular language, and give the toolchain the strictness to catch what the model gets wrong. Every compile type-checks every expression — a hallucinated attribute or misused API is an error with a message that names the fix, so the model's write-check-revise loop converges fast. And because an entire application is a few hundred lines of declarations, what the model produced can actually be audited — by a person or by another model. The calendar on this site reports its own number: zero lines written by hand.\n\nHuman-designed and directed, built with AI. The calendar was built by describing what was wanted and letting an LLM write the Declare — every line — with the compiler in the loop: each attempt was compiled and type-checked, the diagnostics steered the next revision, and the running app was the judge. The person's work was product design work — deciding what the calendar should be, reviewing behavior, and pushing back — not typing code. That's the workflow the language is designed around: the human owns intent, the model owns the text, and the toolchain keeps the text honest.\n\nTwo ways. First, the language is small enough that its *entire definition* fits in a model's context window — one file, [docs/declare.md](https://github.com/davidtemkin/declarelang/blob/main/docs/declare.md), about 21,000 tokens: a small fraction of a modern context window. A model doesn't need to have trained on a language it can hold the complete spec of while writing; recent research (cited in the essay on this site) shows models write never-before-seen languages competently from a spec in context. Second, most of what an LLM writes in a Declare program *is* covered by billions of lines of training data — the logic is ordinary TypeScript. Only the small declarative shell is new, and it's regular enough to learn from the spec. For agent workflows, the repository ships the same knowledge as an installable agent skill ([skill/](https://github.com/davidtemkin/declarelang/tree/main/skill) — auto-discovered by Claude Code, usable as plain instructions by any coding agent).\n\n`verify` command compiles, type-checks, boots the program in a real browser at laptop and phone sizes, and drives it with real input, so an agent can prove its output works before handing it back.\nStarting cold from the repository, agents have built complete apps and passed hidden acceptance checks they never saw:\n\nThey are single runs, not yet a benchmark, and [every one is published in full](https://github.com/davidtemkin/declarelang/tree/main/evals/reports), the agent's own account included.\n\nIt's tested, not assumed. Agents are given a brief for a complete app and the repository, cold, and build it start to finish. Hidden acceptance checks they never see then drive the result through its controls' accessible names, both as delivered and at the first build that ran. The same brief goes to React, and to more than one vendor's model, and each run is published in full with the agent's own account of it, word for word. Failures feed back into the language, the diagnostics, and the documentation — several language changes exist specifically because evals showed models tripping. The documentation is written to double as training material: plain declarative prose, and every code fence in the teaching docs is compiled by the test suite, so nothing a model reads is stale or wrong. The result is a feedback loop — spec, diagnostics, evals — rather than a hope.\n\nDeclare is a from-the-ground-up modern successor to OpenLaszlo, the open-source rich-internet-application platform first released in 2002. OpenLaszlo had the core ideas remarkably early: interfaces declared as trees, attributes connected by live constraints, declarative data binding, compiled applications running in the browser — a decade before today's declarative frameworks. Declare keeps those convictions — the declarative tree, constraint-based reactivity, a real compiler — while rebuilding everything else for the modern era: a clean keyword-free syntax, TypeScript for logic, DOM and canvas renderers, in-browser compilation, and a design shaped from day one for the LLM era.\n\nDavid Temkin, who co-founded Laszlo Systems and led the team behind OpenLaszlo. He writes about [what led from one to the other](#story) at the end of the \"Why Declare\" essay.\n\nYes. Every sample on this site is live-editable in your browser — open one, change the source, and watch it re-render. The whole-page editor will even let you edit the homepage you're standing on. Nothing to install; the compiler is already in the page.\n\nNode.js and git. Then:\n\n```\ngit clone https://github.com/davidtemkin/declarelang.git && cd declarelang\nnpm install\nnpm start\n```\n\nThat starts the dev server; write a program to `my-apps/hello.declare` and browse to its URL — on the dev server, the program's URL is the app's address. The repository ships prebuilt, so there's no build step before first run. (On a plain static host, the entry point is a page — `index.html`, or a production build's — rather than the bare `.declare` file; the site's service worker upgrades program URLs after a first visit.)\n\nYes. Declare installs into your project as an ordinary dependency, fetched from GitHub rather than the npm registry: `npm install github:davidtemkin/declarelang` (with pnpm, approve esbuild's install script when it asks). Your app lives in your own repository, next to the back end it talks to. The dev server serves your project at `/` and the platform at `/declare/`, `declarec` builds it, and the version is pinned in your lockfile, so you upgrade when you choose. [Embedding Declare in a project](https://github.com/davidtemkin/declarelang/blob/main/docs/operational/embedding.md) has the whole setup. What you *ship* is fully standalone: a production build is a small set of static files you can host anywhere, with no trace of the toolchain. Cloning the repository, as above, is still the quickest way to try it, with your first programs in `my-apps/`.\n\nNot yet as a standalone extension. The first-class editing surface today is the toolchain's own: every program URL opens a highlighted reader and a live editor in the browser, and the compiler — with its mandatory type-checking and fix-naming diagnostics — is the authority an editor plugin would defer to anyway. The language's surface is small enough that most editors' TypeScript support already helps inside `{ }` bodies. A dedicated editor extension is an obvious gap, honestly labeled.\n\nYour live edits belong to the session — copy the source out to keep it (it's one file). There's no playground permalink service yet: this site runs on a static host with no server to store shared snippets. The durable path is the ordinary one — save the `.declare` file, serve it from the dev server or any static host, and the program's URL is shareable from there.\n\nWith `verify`, which climbs six rungs, cheapest first, and stops at the first failure. The first three read the program: structure, names, types. The fourth boots it in Chrome, at a laptop's size and a phone's, and notes what it can see wrong in the layout — a control clipped out of reach, a child spilling out of its box, text running past its edge, a phone target smaller than 44 × 44. The fifth drives the app with real input from a script and checks what happens; the sixth compares screenshots against baselines. It suits CI and an agent's loop alike. Because programs settle deterministically, you can also drive one headlessly and assert on the resulting tree — that's how Declare's own test suite works. And a Declare app is a web page, so standard end-to-end tooling (Playwright, Puppeteer) applies unchanged. The platform itself is held to a stricter bar: a conformance suite holds the DOM, canvas and Mac renderers to the same answers.\n\nYes. The library's controls tell a screen reader what they are, what they are called and what state they are in, and keep it current; dialogs, sheets and menus hold and return the focus as their kind should; text fields are native, and say what they hold so autofill works. A control you draw yourself is given a role, and the compiler holds it to that role, as it does the library's. This is on the DOM renderer, the default; the canvas renderer does not yet carry it. The guide's Accessibility chapter has the detail.\n\nThe shape of the language: `[ ]` declares structure, `{ }` holds TypeScript, attributes can be constraints, events get handlers. Then about twenty built-in classes and a standard library of controls. Start with [Declare in 10 minutes](https://davidtemkin.github.io/declarelang/apps/model-tour/), a twelve-screen tour of the model. Then the guide, in [the docs](https://davidtemkin.github.io/declarelang/apps/docs/), walks you through building real apps; if you know TypeScript, you'll be productive in an afternoon. The entire language reference is one readable file. Working with an LLM, you hand it that file (or install the packaged agent skill) and describe what you want — the compiler's diagnostics keep the loop honest either way.\n\nDeclaratively, like everything else. A `Dataset` holds inline or computed data; a `DataSource` fetches JSON. UI binds to data with a cursor — set `datapath` on a view and its descendants read relative to it; bind it to an array and the view replicates per element. Two-way binding connects a text field to the data it edits. When data changes, everything bound to it updates — the same reactivity as the rest of the language.\n\nLarge collections virtualize on one word. `virtualize = true` on a replicated node builds only the rows near the viewport and leaves the rest logical — same records, same paths, same behaviour, reconstructed indistinguishably as you scroll. There is nothing else to write: no row heights, no scroll wiring, no windowing library. It is a boolean and it is **off by default**, so that full replication keeps browser find-in-page working over every record — and like any other boolean it takes a `{ }` constraint, engaging and disengaging as the answer changes. The tracker on this site is a million issues on that one word.\n\nDeclare is young and moving quickly. The language surface is deliberately small and increasingly settled; the toolchain — compiler, type-checker, dev server, production builds, docs, evals — is real and tested (this entire site ships on it). Expect evolution, and expect the repository to be the source of truth. If you're evaluating it for production, the honest advice is: try it on something real but bounded — and [open an issue on GitHub](https://github.com/davidtemkin/declarelang/issues) with what you find; at this stage, that conversation shapes the language.\n\nModern browsers. Input is a unified pointer model, so touch works alongside mouse and keyboard; layouts are constraint-driven, so apps adapt to the window they're given. The DOM renderer produces real elements — native text selection, native form fields, built-in keyboard focus and tab navigation.\n\nMIT. The complete source — compiler, runtime, standard library, documentation, and this site — is at [github.com/davidtemkin/declarelang](https://github.com/davidtemkin/declarelang).\n\nDeclare · runtime architecture\n\nA Declare front end is one self-contained artifact — small enough to hold in your head, strict enough for a machine to verify, rich enough for an ambitious application. This is what Declare’s runtime does to make that true.\n\nDeclare asks you to believe something unusual about an application’s front end: that it is complete. Everything the interface does — where each box goes, how a paragraph wraps, what a click landed on, how a view becomes the next one — is written in the one program, as relationships rather than steps, so a machine can verify it and a person can read it. That puts a demand on what runs underneath: if the browser decided the layout, or the DOM routed the click, the program would not be complete. So the runtime makes those decisions itself, once, and hands the browser what it does best.\n\nWhat it looks like\n\nWhat it is\n\nYour .declare file\n\nApp program\n\nthe part you write\n\ncompiled: resolved, typed, dependencies extracted\n\nA framework\n\nLibrary — written in Declare\n\ncomponents, a store, re-rendering\n\nButton, Slider, SimpleLayout: the same kind of code as yours\n\nRuntime\n\ndecides everything below: ~137 KB gz\n\nKernel — C, as WebAssembly or linked natively\n\nthe settle and the geometry rules: 12 KB gzipped, as shipped\n\nrender seam · one interface, 71 methods\n\nThe browser\n\nHost\n\ndoes the real work\n\nDOM\n\na <div> per view, geometry as inline style\n\nCanvas\n\none <canvas>, its own compositor\n\nMac\n\na CALayer tree in a 7.8 MB app\n\nLayout\n\nStyling\n\nHit-testing\n\nHover & press\n\nClick vs. drag\n\nGesture claims\n\nFocus & Tab order\n\nText measurement\n\nApp\n\nLibrary\n\nKernel\n\nThe compiler is where completeness is enforced. It parses the brackets into a tree, resolves every name to an explicit path, extracts what every `{ }` body reads, and type-checks each body as TypeScript against the real interface of every class — so an attribute that doesn’t exist, or a relationship that reads something it can’t, is an error before anything runs. What it emits is not code that builds a UI but a description of one: the tree, a graph of which value reads which, and, for every body that is plain arithmetic, bytecode for a small stack machine. One line of the homepage’s bouncing-ball demo, compiled:\n\nYou wrote\n\nto = { on ? lane.width - ball.width : 0 }\n\nResolved\n\nto = { this.root.on ? parent.parent.parent.lane.width - parent.parent.ball.width : 0 }\n\nRead-paths\n\n0 this.root.on\n\n1 parent.parent.parent.lane.width\n\n2 parent.parent.ball.width\n\nKernel code\n\n\"=EL0 L1 L2 - K0 ?\" — load 0, 1, 2 · subtract · push 0 · select\n\nBecause the program is data, it can be questioned as data. The Inspector on any page here — ⌥⌘D — reads this same graph: click a value and it shows the body that produced it, everything that body read, and their live values. The same completeness is what lets an AI’s work be checked: the compiler, the Inspector and verify all read one description of the whole interface, not a guess pieced together from files.\n\nWhen a handler writes an attribute, nothing updates yet. When the handler returns, the runtime performs one update — a **settle**: everything that read what changed is recomputed, and whatever that changes in turn, until nothing more does; only then is the host told what moved. If you know React, it is the nearest thing to a commit, except that nothing was rendered to compare against. The meter below is live: raise its level, then step through what your click set in motion.\n\nlive · click it\n\nRaise the level\n\nYour code\n\nPointer arrives\n\nHit walk\n\nIt was a click\n\n4\n\nonClick()\n\n5\n\nSettle opens\n\n6\n\nbar.width\n\n7\n\nlabel.text\n\n8\n\nSurface calls\n\n9\n\nPixels\n\nWhich view is under the pointer, and whether this was a click or the start of a drag, are the runtime’s answers, not the browser’s — one implementation under a finger or a pointer, on every renderer. And the settle itself runs in a kernel: one C file of about 1,400 lines that holds the graph’s tables and evaluates the compiled arithmetic, shipped as WebAssembly (10 KB gzipped) and linked natively on the Mac. A frame that only moves geometry never enters JavaScript.\n\n03\n\nA `Spring` is an attribute with a target; each frame it writes its next value, and that write is a settle like any other. Nothing about animation is special-cased, so a new target mid-flight is simply the next write: the spring retargets from wherever it is, and everything that read it follows. Interruptibility isn’t a feature of an animation system; it is what a reactive graph does when you write to it.\n\nEvery box is decided before the host hears of it — by arithmetic over attributes, by a layout (a class with one method, `place()`), or by the content’s own size. Text is the one place the host contributes a number, the width of a glyph; wrapping and height are the runtime’s, so a paragraph breaks into the same lines on every renderer. Because the runtime placed every box, it also answers the inverse question — what is under this point — and that one answer decides hover, press, and where a drag lands.\n\n04\n\nBecause the compiler hands over the whole graph up front, the runtime doesn’t have to discover anything as it runs. Its reactive core (the graph, the settle, and the arithmetic of layout, springs and visibility) is a small C kernel: WebAssembly in the browser, linked natively on the Mac. Bodies that are plain arithmetic arrive as bytecode the kernel evaluates itself, without returning to JavaScript.\n\nMoving the core there cut update time by 42–53% on every platform measured (Chrome, iOS Safari and the Mac host), and a window drag’s by 81–93%. The rules evaluated didn’t change; each one simply costs less.\n\n05\n\nEverything above happens on one side of a single interface, `Surface` — 71 methods such as `setX`, `setFill` and `setText` that the runtime calls and a backend implements. The DOM backend keeps an element per view and hands the browser what it does best: real text, the page’s own scroll, links, native fields. The canvas backend draws the tree directly to pixels. The Mac host is a Swift application with no web engine in it, applying each settle to Core Animation layers. Drawing (`draw(d)`) records rather than paints, so each host replays the same recording its own way.\n\nBelow, the calendar’s build drawn to scale by gzipped bytes: switch hosts and one block is exchanged while everything else holds still. Beneath it, the same desktop program on each host.\n\nMac host\n\nYour program\n\n13.1 KB\n\nLibrary classes it uses\n\n14.4 KB\n\nReactive core, instantiation & data\n\n46.8 KB\n\nDOM backend\n\n16.4 KB\n\nView\n\n13.5 KB\n\nInput, focus, gestures, scrolling\n\n22.5 KB\n\nDraw & compositing\n\n17.3 KB\n\nSprings & animators\n\n3.2 KB\n\nText & fonts\n\n5.1 KB\n\nBoot\n\n5.9 KB\n\nAccessibility\n\n3.9 KB\n\nKernel — WebAssembly + loader\n\n12.3 KB\n\n137.3 KB\n\nBrowser · DOM\n\nBrowser · drawn to pixels (?render=canvas)\n\nMac host · no browser in the process\n\n06\n\nA web page embeds a Declare app with one attribute on a sized element; inside a Declare program, a `DOMIsland` gives a video player, an editor or a React widget a box of its own, and an `AppIsland` hosts another Declare program — this article is one, inside the homepage. In every direction the contract is the same: values provided, values exposed, and messages posted both ways.\n\n07\n\nIn a browser a Declare app is a web page, not an imitation of one: text selects and finds, fields are native, scroll is the page’s own, links ⌘-click and Back tells the truth, and a crawler reads a static extraction from a plain host. What keeps the runtime honest is the second rendering: the DOM and the pixel renderer are held to the same picture on every change.\n\nReopen this page on the canvas renderer →\n\nRead this page’s source →\n\nThis page is a Declare program; every figure on it is made of views. Sizes are measured from declarec production builds, gzipped at the default level, each time the site is built.", "url": "https://wpnews.pro/news/declare-is-a-ui-language-for-you-and-your-ai", "canonical_source": "https://davidtemkin.github.io/declarelang/", "published_at": "2026-11-24 02:36:56+00:00", "updated_at": "2026-11-24 02:42:04.468365+00:00", "lang": "en", "topics": ["developer-tools", "ai-agents", "ai-tools", "generative-ai"], "entities": ["Declare", "David Temkin", "React", "GitHub"], "also_reported_by": [], "takeaway": "Declare is an MIT-licensed UI DSL whose compiler-checked six-rung ladder from parse to pixels lets an agent verify each step; in one single-run test its ticket-buying app took 1,279 lines versus React's 2,666 and passed all eleven hidden checks versus six.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/declare-is-a-ui-language-for-you-and-your-ai", "markdown": "https://wpnews.pro/news/declare-is-a-ui-language-for-you-and-your-ai.md", "text": "https://wpnews.pro/news/declare-is-a-ui-language-for-you-and-your-ai.txt", "jsonld": "https://wpnews.pro/news/declare-is-a-ui-language-for-you-and-your-ai.jsonld"}}