v0.5 — sites with islands · forms · Node, Bun, Deno and Workers

Virtual DOM.
Every piece of data
already knows its node.

React ships 45 kB to the browser to work out, on every render, what changed. Ascua works it out earlier, at compile time: the template becomes the DOM operations it stands for, and what travels is 4.01 kB of runtime with no dependencies. The compiler is one 109 KB .wasm —one, not a dozen binaries per platform— and it downloads nothing in postinstall.

This page is static HTML. The three demos below are Ascua islands compiled with that same .wasm, and they weigh 3.5 kB together.

4.22 kB
a whole app, gzip
4.01 kB
the runtime alone
109 KB
the compiler, in wasm
0
dependencies
615
tests

01 · the diff you do not need

Rebuilding the tree to find out what changed

With a Virtual DOM, changing a number rebuilds a representation of the tree and compares it with the previous one. The work depends on the size of the tree, not on the change.

Ascua ties each piece of data to its node once, at compile time. Changing it runs the write that belongs to it. Nothing to work out, because nothing was forgotten.

Press and watch the log: every click is one setText on the same node, which is never replaced.

02 · the core

signal, effect, memo

A signal holds a value. An effect runs code and notes which signals it read; if one changes, it runs again. A memo keeps its result and stays quiet if it did not change.

const count = signal(0);
const double = memo(() => count() * 2);

effect(() => console.log("double =", double()));

count.set(21);   // prints "double = 42"
count.set(21);   // silence: the memo did not change

Nobody declares dependencies. They are found by reading.

Writing to a signal runs nothing: it marks. Effects are queued and run once the mark has finished spreading, so a diamond-shaped graph never shows half-updated values and a branch that did not change does not recompute.

03 · templates

A closure is reactive; nothing else is

The template is HTML: class and onclick, not className or onClick. You can copy and paste it from anywhere.

you write

view`
  <button
    onclick=${() => count.update(c => c + 1)}
  >
    Clicks: ${() => count()}
  </button>`

out comes

// at the top, once: what does not change
const _$t0 = _$tpl(
  ["button", 0, ["Clicks: ", ""]], …);

const [_n0, _n1] = _$clone(_$t0);
_$on(_n0, "click",
  () => count.update(c => c + 1));
_$bindtxt(_n1, () => count());

The fixed part is cloned in one go. The effect has _n1 captured: it already knows which node to write to.

${count()} puts the value in and forgets it. ${() => count()} creates an effect. The difference is syntactic: you see it in the template, without looking at types.

04 · composition

Components and control flow

Lowercase is HTML, uppercase is a component. A component takes props and returns a node: <Card title=${t}/> compiles to Card({ title: t }), which you can write by hand. No base class, no lifecycle.

view`
  <main>
    <Show when=${() => session() !== null}>
      <Card title=${() => session()!.name}>
        <ul>
          <For each=${() => tasks()}
               key=${(t) => t.id}
               render=${(t) => view`<li>${t.title}</li>`}/>
        </ul>
      </Card>
      <Else><Login onlogin=${logIn}/></Else>
    </Show>
  </main>`

Children are a recipe the parent receives, not nodes already made.

Each branch of <Show> is built inside its own function, so the one you do not see does not exist yet. When the condition changes, the whole scope of the previous one is released: effects, memos, listeners and onCleanup.

Log in, check a task, add another and log out. The counter below keeps track: one build per key, and all of them released on log out. Checking does not rebuild the row; it writes an attribute and a text.

The field uses prop:value. The value attribute of an <input> only sets the initial value and stops counting as soon as someone types; the property always counts. Clearing a form from code depends on it.

05 · lists

The only reconciliation left

For text and attributes there is nothing to compare. For a list there is: you need to know what happened to each item. Ascua compares keys, not trees, and only when the list changes.

Each item gets its color when it is built. Rotate or reverse: the colors travel with their items because they are the same nodes, moved. That is what keeps focus, scroll and anything half typed.

06 · styles

CSS stays in the compiler

A <style> inside a template leaves nothing at runtime: no injected tag, no insertRule. At compile time an id is derived from the content and every selector is rewritten.

in the template

<style>
  .box { border: 1px solid; }
  p:hover { opacity: .5; }
</style>

in the build's .css

.box[data-ascua-98909ba2] {
  border: 1px solid;
}
p[data-ascua-98909ba2]:hover {
  opacity: .5;
}

The attribute goes before the pseudo-class, not at the end.

The scope is per template. A component's CSS does not leak into the components it uses, which is exactly what you expect from a scope, and that is why each one carries its own styles.

07 · webassembly

One artifact, not twenty

01

109 KB for everything

The same .wasm in Node, Bun, Deno and the browser. SWC publishes a dozen binaries per platform; esbuild, twenty.

02

No postinstall

Nothing to download on install, which is the hole stil exists to close. One artifact to audit, not ten.

03

Runs in your tab

The playground is the whole compiler, with no server behind it. Type and see what comes out.

04

And it stays out of the client

In the browser the DOM lives in JavaScript: crossing the boundary costs more than the operation. That is why the runtime is 4.01 kB of JS.

08 · against the usual ones

Where Ascua stands

AscuaReactSvelteSolid
Updates the DOMdirectlydiffdirectlydirectly
Virtual DOMnoyesnono
Runtime, gzip4.01 kB~45 kB~10 kB~7 kB
Compilerwasm—jsjs
Binaries per platform0—00
Scoped CSSat compile timenoat compile timeno
Control flow<Show> <For>jsblocks<Show> <For>
Router, gzip1.03 kB~10 kBseparate~4 kB
Runtime deps0several00
Time × vanilla ↗1.101.851.131.07

The column that really matters is not in the table: whether you can read the whole mechanism in an afternoon and fix it without waiting for anyone. The browser runtime is 1,100 lines, comments included; the compiler, 1,900 without its tests.

09 · getting started

One command for a site, two for the runtime

npm create ascua@latest my-site

or stil dlx create-ascua, bun create ascua, deno run -A npm:create-ascua.

It leaves a site with one page per file in src/routes/ and islands for the interactive parts. With --template server, also form actions and middleware, on a server that runs on Node, Bun, Deno or Cloudflare Workers. Coming from Fresh? The model is the same.

npm install ascua
npm install -D vite-plugin-ascua

The runtime by hand, for a single-page app. Also with stil add.

// vite.config.ts
import ascua from "vite-plugin-ascua";

export default { plugins: [ascua()] };

The compiler comes inside the plugin. No binary to install.

From there it is Vite. Out come a .js and a .css you can publish on any static host — this site, for one.

In the editor, colors and type errors inside templates: VS Code extension (76 kB), or the TypeScript plugin for Zed and the rest.