BosatsuUI

A UI library that uses compile-time static analysis of TypedExpr to generate targeted DOM updates without virtual DOM diffing.

No Virtual DOM

The Key Insight

When state changes, instead of re-rendering and diffing:

  1. Static analysis extracts statePath -> DOMProperty bindings at compile time
  2. Runtime looks up bindings for the changed path - O(1) map lookup
  3. Direct element.property = value updates - no diffing!
  4. NEW: Pattern matching on variants enables conditional visibility toggling

Interactive UI Demos

Simulation Demos

Generated from .bosatsu source files using the simulation CLI. Features "Why?" buttons for derivation tracking and "What if?" toggles.

Performance Benchmarks

How It Works

// Compile time: UIAnalyzer extracts bindings from TypedExpr
const bindings = {
"count": [{ elementId: "counter", property: "textContent" }],
// Conditional bindings with 'when' clauses for pattern matching
"status": [
{ elementId: "loading", property: "textContent",
when: { discriminant: ["status"], tag: "Loading", isTotal: false } },
{ elementId: "error", property: "textContent",
when: { discriminant: ["status"], tag: "Error", isTotal: false } },
],
};

// Runtime: O(1) lookup, visibility toggling, direct DOM update
for
(
const
b
of
bindings) {
if (b.when && state[b.when.discriminant].tag !== b.when.tag) {
element.style.display = 'none'; // Hide non-matching variants
} else {
element.style.display = '';
element[b.property] = value; // Direct DOM update
}
}