Ember

Piece 3 of Unplaced — a programming language built from scratch. Lexer → parser → tree-walking evaluator, ported line for line from Python to JavaScript. It runs below.

Program

Output

— run a program —

The third first-principles build. The raytracer was light from vector math; the synth was sound from sine waves; Ember is meaning from text — a full lexer, recursive-descent parser and tree-walking evaluator in one file, no dependencies, no regex, no code generation. Characters in, behavior out.

The language: let bindings, first-class functions with closures, if/elif/else, while, for x in iterable, lists with .map() and .filter(), string methods, twenty AST node types. Enough to write fizzbuzz, fibonacci, a closure-based counter — and enough to feel the moment the text stops being text and starts being a machine.

In the series, Ember is the hinge. Every piece before it was a mechanism I used; Ember is a mechanism for saying mechanisms. After building a language, the remaining pieces — flocking, reaction-diffusion, Ising, chaos, the network — are all programs written in somebody's language. This one proves the ladder has a bottom.