Yin.VM
Yin.VM is what happens when Clojure and Smalltalk got together and had a baby. It is a continuation virtual machine where the universal, map-based AST stays canonical, eval is the machine, and persistent data structures keep continuations fast, mobile, and immutable.
Together with the Yang compiler, Yin.VM forms a dual system: Yang generates and emits continuations from Clojure code, while Yin receives, introspects, and executes them.
Main ideas
- Universal AST — designed as a compiler target, these immutable maps capture syntax, semantics, and metadata across languages.
- Persistent CESK — control, environment, store, and continuation reuse structure for speed.
- First-class continuations — computation pauses, migrates, and resumes anywhere, even across network boundaries.
- Unified call constructs — functions, closures, and continuations are the same reified execution context.
- Eval as VM — stepping eval drives the machine with no hidden interpreter.
- Runtime macros & distribution — ASTs transform themselves locally or across nodes.
Universal map-based AST
Every program Yin.VM runs is first expressed as the Universal AST: a language-agnostic, map-based structure that records syntax, semantics, and metadata in immutable data. Python, JavaScript, Java, and Clojure can all compile into this canonical form via the Yang compiler (launching with Clojure support first).
Once a program is a Universal AST, Yin.VM can transform, optimize, or execute it uniformly. The AST persists—bytecode, continuations, and runtime state derive from it, and it is never discarded. Every transformation therefore preserves reversibility, provenance, and rich introspection.
CESK machine with persistent data structures
Yin.VM implements the CESK model (Control, Environment, Store, Continuation) with persistent data structures. Structural sharing replaces wholesale copying, so each step produces tiny deltas rather than cloning entire environments.
- Control — current AST node or continuation frame
- Environment — persistent lexical scope map
- Store — immutable memory graph
- Continuation — reified, persistent control context
The result is fast snapshots, near-instant rollbacks, and execution that parallelizes cleanly while remaining fully immutable.
Continuations as portable computation
Continuations are first-class values that encapsulate the entire computational state. The feature set exists so agents—implemented as these continuations—can move safely across network boundaries, running on embedded devices, edge racks, or supercomputers without changing shape. They can be paused, serialized, migrated, and resumed—turning mobile agents into continuations by design.
Functions, closures and continuations are a unified concept. With this unification, metaprogramming, reflection, and code mobility stop being special cases—they are native behaviors.
Eval is the virtual machine
There is no hidden interpreter. Invoking eval
steps the CESK machine directly, executing the AST as data. Because the AST remains canonical and persistent, macros exist at runtime as well as compile time— code can generate, transform, or extend itself dynamically using the same structures the VM executes.
ASTs are pure data, so transformation work can be distributed across nodes. Subtrees evaluate or rewrite independently, append results to datom streams, and integrate back into the canonical representation— enabling distributed compilation and collaborative code evolution.
In summary
Yin.VM turns code into data and data into computation. The Universal AST anchors every stage, persistent data structures makes CESK state efficient and immutable, and first-class continuations make agents mobile by design. Eval is the machine, runtime macros stay reversible, and distributed AST transformation keeps teams iterating together.
Ready to emit new continuations? Explore the Yang compiler to see how Clojure code becomes Universal ASTs and enters the Yin.VM runtime.