B (programming language)
B
B is the language between BCPL and C — the single-letter bridge without which there is no Unix. Ken Thompson wrote it at Bell Labs in 1969, during the first months of the Unix project, by squeezing BCPL down until it fit into the 8K words of a PDP-7. The result was a language stripped to exactly one data type — the machine word — and it is, by any honest accounting, the first Unix systems language.[1]
The name itself is a historical shrug. Ritchie's account offers two candidates and chooses neither firmly: B may be a contraction of BCPL, or it may descend from Bon, an unrelated language Thompson had written during the Multics era and named for his wife. The language that started the C lineage may not even have a definitive etymology — fitting for something that lasted barely three years in the wild.[2]
One type, zero mercy
B is typeless — or, in Ritchie's phrasing, it has a single data type: the computer word. A value is a word; whether you use it as a number, a pointer, or a character is your problem. Arithmetic and pointer operations are the same operations. There is no char, no int — only cells, and operators +, -, *, /, %, &, |, plus the ++ and -- operators that B invented and that C inherited unchanged. The PDP-7 couldn't hold anything more elaborate, so nothing more elaborate was provided.++/--">[3]
The implementation was itself interesting: B on the PDP-7 (and initially on the PDP-11) compiled to threaded code — a sequence of subroutine calls interpreted at runtime — rather than native machine code, because the compiler could not afford a real code generator. The whole language ran on a machine smaller than this article's source text.[4]
The typelessness solved the PDP-7's problems and immediately created the PDP-11's. When Unix moved to the byte-addressable PDP-11 in 1970, B's word-only model became a liability — extracting characters from packed words through library calls like char() was clumsy, and the machine's byte pointers demanded real types. Dennis Ritchie's answer was "New B" — NB — which added types and a native compiler, and which by 1972–73 had become C. The missing letter of the alphabet turns out to be the most consequential one.[5]
A language with no programs left
B's peculiar fate: it was important enough to name the lineage of the most influential language ever written, and disposable enough that almost no B source code survives. It existed for a handful of years on a handful of machines, served a handful of early Unix utilities, and was deliberately replaced — a scaffolding language, removed once the real building stood. What remains is the documentary record: Ritchie's retrospective, the surviving B reference manual preserved by TUHS, and its fingerprints all over C — the ++, the // comments, the switch statement, the vector indexing, the entire vocabulary of the next fifty years.[6]
Where it sits
B belongs in the lineage section, not the esolang wing — it is a real, dead, historically load-bearing language. Read it as the missing middle chapter between BCPL's elegance and C's precision: proof that the most important languages are sometimes the ones that exist only long enough to make the next one possible.
Check your understanding
- What was B's only data type, and why?
- Which two operators did B invent that C still uses?
- What implementation technique did the PDP-7 version use, and why?
- What did Ritchie add to B that turned it into C?
Show answers
1 — the machine word — B is typeless; a value is a word, and whether it is a number or a pointer is the programmer's business. 2 — ++ and -- — Thompson's increment/decrement operators, carried into C unchanged. 3 — threaded code — an interpreted sequence of subroutine calls, because an 8K machine couldn't host a real code generator. 4 — types — Ritchie's "New B" added char/int and a native compiler, and NB became C by 1972–73.
Footnotes
- ↑ Ritchie, D.M., "The Development of the C Language" (1993, HOPL-II) — the primary source: B's PDP-7 origin, the 8K-word constraint, and the typeless design
- ↑ Ritchie 1993 — the BCPL-versus-Bon naming ambiguity, stated plainly in the primary source
- ↑ Ritchie 1993 — B's typeless word model, the operator set, and the origin of
++/-- - ↑ Ritchie 1993 — B's threaded-code implementation on the PDP-7 and early PDP-11
- ↑ Ritchie 1993 — the PDP-11's byte-addressing pressure, NB, and the transition to C
- ↑ B programming language) and the TUHS archives — the surviving manual and the absence of surviving programs