Skip to main content

Week 1: Why SNOBOL

Bell Labs, 1962 — where SNOBOL came from, why this course builds SNOBOL4 specifically, and why OCaml is the implementation language

22 February 2027

Open the slides

Outline

Bell Labs, 1962

SNOBOL was built at Bell Telephone Laboratories in Holmdel, New Jersey, starting in 1962, by David J. Farber, Ralph E. Griswold, and Ivan P. Polonsky, in a department working on high-level, nonnumerical computation. The language was not commissioned as a product; the three of them needed a better tool for manipulating symbolic expressions in their own research and built one rather than waiting for one to exist.

What the course calls “SNOBOL4” is the fourth, and by far the largest, redesign in that line. Griswold’s own later account is explicit that SNOBOL, SNOBOL2, and SNOBOL3 are “more properly considered separate languages than versions of one language,” and that SNOBOL4 — designed from 1966, running by 1967 — was a near-total rewrite: unlimited-length strings, pattern matching promoted to a first-class data type, arrays, tables, and a portable implementation strategy (SIL, a hypothetical assembly language for an abstract machine) that let SNOBOL4 reach roughly fifty machines and operating systems by the late 1970s. That portability trick — write the interpreter against a small virtual instruction set rather than any one machine’s assembler — is the same idea this course will reach for if its own compiler ever targets a bytecode VM instead of native code.

The naming story is worth one honest aside, because the two most-repeated tellings of it do not agree, and neither can be fully verified against the other from the sources this course has read. Griswold’s own first-person account says he personally coined “SNOBOL” and only afterward reverse-engineered “StriNg Oriented symBOlic Language” as a joke and a lampoon of the era’s fondness for cute language names. A separately circulated account, from Farber, has the name arriving in a “snowball’s chance in hell” moment over coffee. Both are first- or second-hand from people who were there; they disagree on the mechanism, not just the color. This course takes no side on which is correct — it is a small, concrete example of why oral history and primary documents can diverge on the same three-week episode, which matters more to how you should read sources than the specific fact does.

One thing every account agrees on: SNOBOL is not related to COBOL. The resemblance is deliberate wordplay by its own designers, “though the two languages have no other connection or similarities.”

Why build SNOBOL4 specifically

This course is a compiler-construction studio, and SNOBOL4 was picked for a structural reason, not sentiment: its distinguishing feature — pattern matching as a first-class, backtracking data type, not syntax bolted onto a regular-expression engine — is genuinely different from what a “build a compiler for a C-like language” course teaches, and it changes where a course built around it has to spend its time. Movements I and II (weeks 1–6) get you to a working calculator-and-statement interpreter; Movement III (weeks 7–9) is where the actual pattern engine — concatenation and alternation of patterns, BAL, ARB, full backtracking including recursive patterns — gets built. Everything before that point in the semester is preparation for it, which is also why weeks 1–4 already produce something you can run: a course that only starts paying off in week 7 is a course designed to be abandoned in week 6.

Why OCaml

The implementation language was chosen because the fit is conceptual, not just a matter of available tooling. SNOBOL4 has two structural properties that map directly onto features OCaml has as a language, rather than onto library support it happens to ship:

If none of let rec, pattern matching, or variant types are familiar yet, the OCaml crash course covers exactly these three things — and only these — against real code from this course’s own interpreter, before you meet them here for real.

This is not a novel pairing. Andrew Appel’s Modern Compiler Implementation in ML structures an entire course this way — build a complete compiler in an ML-family language, using its pattern matching and datatypes throughout — and this course borrows that structure wholesale, swapping Appel’s toy source language for a real, historically significant one. The toolchain departs from Appel’s own in one place: rather than a generator like ocamllex (in the style of lex), this course’s lexer is hand-rolled throughout, because SNOBOL4’s arithmetic operators are blank-sensitive — the same character can be a binary operator, a unary operator, or a concatenation boundary, decided by what’s adjacent to it — which is far more direct to express as an explicit character-by-character scan than as a generated automaton’s regex-driven rules. The parser, by contrast, is built by hand or with a generator such as menhir, whichever a given week’s grammar actually calls for.

Further reading

Teaching team