Prolog is the logic programming language where you do not tell the computer what to do. You tell the computer what is true. The computer derives the consequences. Unification, backtracking, resolution — the runtime searches for proofs the way a mathematician searches for proofs, except faster and without the coffee.
Prolog was fun in university. Prolog has never been used since. Prolog is a fond memory.
“The language that proved programming could be something other than instructions. The fact that instructions won does not diminish the proof.”
— The Lizard, who respects a beautiful idea even when it loses
The Beautiful Idea
You write: parent(tom, bob). — Tom is Bob’s parent. You write: ancestor(X, Y) :- parent(X, Y). — X is an ancestor of Y if X is a parent of Y. You write: ancestor(X, Y) :- parent(X, Z), ancestor(Z, Y). — X is an ancestor of Y if X is a parent of Z and Z is an ancestor of Y.
You ask: ?- ancestor(tom, Who). — Who are Tom’s ancestors?
The runtime figures it out. You did not write a loop. You did not write a recursive function (though the definition is recursive). You did not manage state. You described relationships and asked a question, and the computer — through unification of variables, through backtracking when a path fails, through systematic exploration of the search space — derived the answer.
This was the revelation: programming does not have to be a sequence of commands. Programming can be a description of the world, and the computer can navigate it. This idea is beautiful. This idea is, for most real-world software, impractical. But the beauty does not require practicality to justify itself, and the memory of watching Prolog derive conclusions that you never explicitly coded does not fade.
After University
Nobody uses Prolog after university. This is not quite true — Prolog has niches in expert systems, natural language processing, and specific AI applications — but for the overwhelming majority of developers who encountered Prolog in a university course, the encounter was brief, beautiful, and terminal.
riclib never used Prolog again. But Prolog taught something that the imperative languages — BASIC, assembly, Pascal, C — had not: there is more than one way to think about computation. The imperative way (do this, then this, then this) is one model. The functional way (Lisp — apply this function to this data) is another. The logic way (this is true, what follows?) is a third. Knowing that the third exists, even if you never use it again, changes how you think about the other two.
Measured Characteristics
- Designer: Alain Colmerauer (Marseille, 1972)
- Paradigm: logic programming (tell the computer what is true, not what to do)
- Key mechanisms: unification, backtracking, resolution
- riclib’s engagement: university course (fun)
- Times used after university: 0
- Times remembered fondly: many
- The beautiful idea: the computer derives the how from the what
- The practical outcome: instructions won
- Legacy: proof that programming has more than one shape
See Also
- Lisp — The other university language that rewired thinking. Lisp and Prolog together taught that computation is not one thing.
- Pascal — The university language that was too easy. Prolog was the university language that was exactly surprising.
- Go — Imperative, practical, ships. The opposite of Prolog in every way except the respect riclib has for both.
