BCPL (Basic Combined Programming Language) was designed by Martin Richards of the University of Cambridge and first implemented in 1967 while he was visiting MIT. It is a small, typeless language for writing compilers and operating systems, and it is remembered today mostly as a grandparent: Ken Thompson's B was a stripped-down BCPL, and Dennis Ritchie's C grew out of B. Following how BCPL led to the B and C languages is one of the clearest lineages in programming history.

Origins: from CPL to BCPL

BCPL's parent was CPL, the Combined Programming Language, designed in the early 1960s by a team from the Cambridge Mathematical Laboratory and the University of London, with Christopher Strachey as a leading figure. CPL was elegant and very ambitious, and a full compiler proved hard to finish.

Richards took a practical route. He kept CPL's syntax and structure but threw out almost everything that made it hard to compile, especially its type system. The result was a language whose compiler was small enough to move between machines. The first BCPL compiler ran on the CTSS time-sharing system on an IBM 7094 at MIT's Project MAC in 1967.

Design and key features

  • One data type: the word. Every value is a machine word. Whether it is an integer, a character, a pointer or a truth value depends only on the operator applied to it.
  • Pointers and vectors. The ! operator dereferences an address, and v!i indexes a vector. This address arithmetic is the direct ancestor of C's pointers and arrays.
  • Section brackets. Blocks were written with $( and $), later versions also accepting braces, the forerunner of C's curly-brace blocks.
  • A portable compiler. The front end produced O-code, an intermediate code for an abstract machine. Porting BCPL meant writing a relatively small O-code translator for each new computer.
  • Global vector. Separately compiled parts of a program shared data through a numbered global vector, a simple linking scheme.

A short BCPL example

GET "LIBHDR"

LET START() BE
$( LET SUM = 0
   FOR I = 1 TO 10 DO SUM := SUM + I
   WRITEF("SUM = %N*N", SUM)
$)

START is the entry point, WRITEF is a formatted print routine, and *N is a newline. The * escape character later became the backslash in C.

How BCPL led to the B and C languages

Bell Labs was one of the partners in Multics, and BCPL was among the languages Bell Labs staff used on that project. Ken Thompson and Dennis Ritchie knew it well. When Bell Labs withdrew from Multics in 1969 and Thompson started work on what became Unix on a small DEC PDP-7, he wanted a high-level language for it.

The PDP-7 had very little memory, so Thompson cut BCPL down to fit, changed its syntax to be more terse and named the result B. B kept BCPL's single word type and pointer arithmetic. When the team moved to the byte-addressed PDP-11, the lack of types became a real problem, so Ritchie added types such as char and int, producing first "New B" and then C around 1972.

LanguageYear (approx.)Key change
CPL1963Rich, typed, hard to implement
BCPL1967Typeless, portable, small compiler
B1969Terser syntax, fit into a PDP-7
C1972Added types and structures for the PDP-11

Notable software written in BCPL

BCPL was not only an ancestor; it did serious work of its own:

  • At Xerox PARC, much of the software for the Alto personal computer, including its operating system, was written in BCPL.
  • Richards and colleagues at Cambridge wrote the TRIPOS portable operating system in BCPL in the 1970s.
  • TRIPOS became the basis of AmigaDOS, the file and disk part of the Commodore Amiga operating system, which is why early Amiga programmers had to deal with BCPL pointers and strings.
  • Acornsoft sold a BCPL system for the BBC Micro, used in some UK schools and companies.

Is BCPL still used today?

Hardly anyone writes production code in BCPL now, and it counts as a historical language. Martin Richards has continued to maintain a free BCPL distribution, including a Cintcode interpreter that runs on modern systems, and it is useful for anyone studying compilers. Its lasting value is in how BCPL led to the B and C languages: the word-oriented memory model, the pointer arithmetic and the compact syntax all passed down the line to modern C.

Frequently asked questions

What does BCPL stand for?

BCPL stands for Basic Combined Programming Language. "Combined Programming Language" was CPL, its larger predecessor from Cambridge and London. BCPL kept the core of CPL that could be compiled efficiently.

Why was BCPL typeless?

Removing types made the compiler much smaller and easier to port, and on the word-addressed machines of the 1960s, almost everything fit naturally in a single word. The programmer decided what each value meant. This worked well until byte-addressed machines like the PDP-11 became common.

Did BCPL use curly braces like C?

Original BCPL used $( and $) as section brackets because many keyboards lacked braces. Later implementations accepted { and } as alternatives. B and C adopted braces as the standard block delimiters.