Facet 8 · Declarative vs Imperative

Being and Doing

The oldest philosophical divide in human thought — expressed in code, in language, in law, and in the two great traditions of East Asian philosophy
Facet 8PhilosophyLanguage Design

Introduction

Every programming language, every human language, every system of law, every philosophy of governance, and every theory of physics must answer a fundamental question: do you describe what is, or do you describe what to do? This is the divide between the declarative and the imperative — between being and doing, state and process, existence and procedure.

Prospectus Celestial is a declarative language. A PCML file does not say "now create an image, then position it, then set its opacity." It says: "there is an image; it exists at this position; its opacity is this value." The engine figures out how to make it so. This is not a minor technical choice — it is a profound philosophical stance that has been argued over for three thousand years.

"The Tao that can be told is not the eternal Tao. The name that can be named is not the eternal name." — Laozi, Tao Te Ching, ~6th century BCE

What is Declarative? What is Imperative?

Declarative
You describe what you want. The system decides how to achieve it. State over sequence. Existence over procedure. "There is a circle, red, 100px."
Imperative
You describe how to get what you want. Step by step. Action over state. Sequence over existence. "Create a canvas. Draw circle. Set fill red. Set radius 100."
-- DECLARATIVE (PCML): describes what exists
@circle id="sun" x=400 y=300 radius=100 fill=#ffcc00 {
  @animate property=radius from=90 to=110 duration=2.0 loop=true { }
}

// IMPERATIVE (C#): describes what to do
var canvas = new CanvasDrawingSession();
var circle = new Ellipse();
circle.CenterX = 400; circle.CenterY = 300;
circle.RadiusX = 100; circle.RadiusY = 100;
circle.Fill = new SolidColorBrush(Colors.Gold);
animationTimer.Elapsed += (s,e) => { /* animate radius */ };

Taoist and Confucian Thought: The Ancient Divide

The oldest clear statement of the declarative philosophy is Taoism (道家), founded by Laozi (~6th century BCE). The central concept is wu wei (無為) — "non-action" or "effortless action." The sage does not command; the sage creates conditions in which the right outcome emerges naturally. The Tao (道, "the Way") is not a sequence of steps — it is the underlying nature of things, from which all process flows. This is the declarative philosophy: describe the nature of reality, and action follows naturally.

Confucianism (儒家), founded by Confucius (~551–479 BCE), takes the imperative view. The central concept is li (禮) — ritual, propriety, procedure. The Confucian sage governs by prescribing exactly the right action in every situation: at this ceremony, bow this way; when greeting an elder, say these words; when administering justice, follow these steps. The social order is maintained by the correctness of procedure, not the cultivation of inner nature. This is the imperative philosophy.

The tension between these traditions governed East Asian political thought for 2,500 years. The Han Dynasty synthesis (202 BCE) used Confucian procedure for government administration (imperative), while adopting Taoist flexibility in economic policy (declarative). The Song Dynasty Neo-Confucians attempted to reconcile the two traditions — much as modern software attempts to combine declarative UI frameworks with imperative business logic.

Metaphor
"A declarative PCML scene is the Tao: you describe the world, and the engine moves through it. An imperative program is the Confucian bureaucracy: every step is prescribed, every ritual performed in sequence. Both build civilizations. Only one grows naturally."

SQL: The Triumph of Declarative Data

The most successful declarative language in computing history is SQL (Structured Query Language), developed at IBM by Donald Chamberlin and Raymond Boyce in 1974, standardized in 1986, and still ubiquitous in 2026. SQL does not say "go to this row, check this column, if the value is greater than this, add it to a list." SQL says: "give me all rows where the salary is greater than 50000, sorted by department." The how — whether to use an index scan, a table scan, a hash join, or a merge join — is entirely the database engine's problem.

The consequence: a single SQL query that takes a programmer five minutes to write may trigger a query optimizer that has been refined over forty years of engineering, producing an execution plan that would take a procedural programmer weeks to write manually. The declarative model leverages accumulated system intelligence, freeing the programmer to think about what they need, not how to get it. As of 2024, SQL is used in over 80% of enterprise data systems, from SQLite (running on essentially every smartphone and desktop computer) to Oracle, PostgreSQL, and Snowflake managing petabytes of data.

HTML and CSS: Declarative Presentation

HTML (HyperText Markup Language, Tim Berners-Lee, 1991) is declarative: <h1>Hello</h1> does not say "set the font size to 32px, make it bold, add 21px of margin below." It says: "this is a first-level heading." The browser decides how to render it. CSS (Cascading Style Sheets, Hakon Wium Lie, 1996) extended this: color: red does not say "set pixel values in the framebuffer." It declares a property.

PCML follows this exact tradition. A @image tag in PCML is as declarative as <img> in HTML — you describe what exists, and the PCEngine determines how to render it efficiently on the Win2D GPU surface. The developer works at the level of meaning; the engine works at the level of mechanism.

Architecture vs Management: Building vs Running

A building is declarative. A floor plan states: "here is a wall; here is a window; here is a door." It does not say "send the workers to location X, have them carry bricks, place the bricks." The floor plan declares the intended state of a space that does not yet exist. The construction crew (the engine) interprets the declaration and produces the result.

Management is imperative. A manager issues commands: "go here, do this, then do that, then report back." The outcome depends on the exact sequence and correctness of each instruction. If step 3 fails, steps 4 through 10 may be meaningless. Imperative systems are fragile at sequence boundaries; declarative systems define a target state and let the engine find any valid path to it.

Physics: State Space vs Trajectory

Classical mechanics (Newton, 1687) is imperative: given initial conditions and forces, compute the trajectory step by step. Lagrangian mechanics (Lagrange, 1788) is declarative: declare the system's energy landscape (kinetic and potential energy as functions of position), and the equations of motion emerge from the principle of least action — the system finds its own path through the landscape without being told each step. Quantum mechanics (Schrödinger, 1926) is even more declarative: the wave function declares a probability distribution over all possible states, and measurement collapses it to a specific outcome.

The history of physics is a movement from imperative (Newtonian trajectories) to declarative (Lagrangian energy landscapes, quantum states, relativistic spacetime geometry). Each step upward in abstraction corresponds to the declarative insight: describe what is true, and let the math find what must follow.

PCML as Declarative Language: The Design Principle

Every tag in PCML — @image, @text, @audio, @scene, @fragment — declares the existence of a thing and its properties. The PCEngine translates this declaration into Win2D draw calls, WASAPI audio buffers, and input event registrations. The programmer never calls CanvasDrawingSession.DrawEllipse() directly — they declare @circle and let the Renderer handle the rest.

This design allows the engine to optimize freely: batch draw calls, cache unchanged nodes, defer off-screen rendering, and schedule GPU operations without the programmer needing to know that any of this is happening. The declarative contract is a gift to both sides: the programmer gets clarity; the engine gets freedom.

DomainDeclarative ExampleImperative Example
DatabaseSQL: SELECT * WHERE salary > 50000Iterate rows, check each, accumulate list
UIHTML/PCML: describe structure and stateDirectX/Win32: explicit draw calls in order
PhysicsLagrangian: declare energy, derive motionNewtonian: compute each force, each step
GovernmentConstitution: declare rights, structure followsDecree: issue specific commands for each situation
PhilosophyTaoism: cultivate nature, action emergesConfucianism: prescribe action for every situation
Metaphor
"A PCML scene is a map, not a driving direction. The map declares the world. The engine navigates it. You do not tell the river how to flow to the sea — you carve the channel, declare the gradient, and let gravity be your renderer."