Structure of Programming Languages / Chapter 00
Before building Vertex, decide what kind of thing a language is and what it takes to make one run.
Gregory S. DeLozier, PhD
01 / Shared rules
A light, gesture, word, or keyword becomes part of a language when it stands for something beyond itself.
Traffic lights and referee signals are familiar languages: shared forms, shared meanings, real consequences.
Which programs are well-formed?
x = 1 + 2;
print x;
What do those programs do?
1 + 2 -> 3
x -> 3
print x -> None
Side effect: print x writes 3.
03 / A program changes form
Each stage solves a different problem. A flaw in one stage can make the whole language behave strangely in its own special way.
04 / Structure records precedence
x = 1 + 2 * 3;
- + |- number: 1- * |- number: 2
`- number: 3
05 / Realizing meaning
Walk the AST and produce behavior now.
What happens when this node runs?
Translate the AST into another form for later execution.
How can this meaning be expressed elsewhere?
JIT compilation and transpilation are variations on the same theme: preserve meaning while changing when or where a program runs.
06 / Programs remember
x = 10;
y = x + 5;
07 / Tests make promises
assert 2 + 3 * 4 == 14;
The implementation produces the expected result.
Multiplication binds more tightly than addition in Vertex.
08 / The course method
Each new feature changes more than syntax. It creates new structural and semantic work in the implementation.
Chapter 00
2 + 3 * 4 the right structure and meaning.