Languages & Paradigms

Code as data

Also: data as code

The Lisp insight that programs and the data they manipulate can be the very same kind of thing.

In 1960 John McCarthy published "Recursive Functions of Symbolic Expressions and Their Computation by Machine," introducing Lisp and with it a quiet revolution: a program is just a symbolic expression — a list — and lists are exactly what the language is built to manipulate. Code and data are made of the same stuff.

This collapses a wall that most languages keep firmly in place. When code is data, you can write programs that write programs, treat functions as values, and build an interpreter for the language inside the language. McCarthy's eval function — a definition of Lisp in Lisp — is the original metacircular evaluator, and Alan Kay called seeing it "the Maxwell's equations of software."

Read Lisp and the Idea of Code as Data.