This is the genealogy of the programming language BCPL:

BCPL is a child of CPL.
BCPL was first known as BCPL around year 1967.
Then it begat B around year 1969.

This genealogy is brought to you by the Programming Languages Genealogy Project. Please send comments to thbz.

BBS = B = beam

BCPL // n.

[abbreviation, `Basic Combined Programming Language') A programming language developed by Martin Richards in Cambridge in 1967. It is remarkable for its rich syntax, small size of compiler (it can be run in 16k) and extreme portability. It reached break-even point at a very early stage, and was the language in which the original hello world program was written. It has been ported to so many different systems that its creator confesses to having lost count. It has only one data type (a machine word) which can be used as an integer, a character, a floating point number, a pointer, or almost anything else, depending on context. BCPL was a precursor of C, which inherited some of its features.

--The Jargon File version 4.3.1, ed. ESR, autonoded by rescdsk.

BCPL is an abandoned fossil of a language; if it is known at all today it is usually for being the grandfather of C. Certainly the most striking aspect of BCPL from a modern perspective is its loose typing, which is certainly an understatement. Whereas in C there is as little typechecking as possible, in BCPL there is none at all, because there is only one type, usually simply referred to as a "value." String literals are accomodated in an implementation-dependent manner--usually a string is packed into an array. The holy writ of BCPL is the book BCPL: The Language and its Compiler by Martin Richards and Colin Whitby-Strevens. BCPL was intended as a sort of general-purpose systems programming language, designed by taking the general syntax and features of CPL and stripping out the datatypes and sophistication. In the first chapter, the author explains:

The philosophy of BCPL is not one of a tyrant who thinks he knows best and lays down the law on what is and what is not allowed; rather, BCPL acts more as a servant offering his services to the best of his ability without complaint, even when confronted with apparent nonsense. The programmer is always assumed to know what he is doing and is not hemmed in by petty restrictions.

This is similar to many of the arguments used in defense of C, but even stronger. It is perhaps not hard to see why BCPL was ultimately abandoned--though the language is tiny and easy to build, it provides very little assistance to the programmer. C provides an even more elegant syntax, all of the features of BCPL and many more useful ones without much added baggage. Ultimately, "the philosophy of BCPL" is a failure in large systems, since in the philosophy of modern languages and large systems some "petty restrictions" are necessities. The portability of BCPL comes from both its extreme simplicity and the fact that compilers typically produce an intermediate code for a virtual machine, known as OCODE. This is easily interpreted but is typically compiled by a back-end to the target architecture.

Without further ado, here is the first "Hello World" program ever written:
GET "LIBHDR"
LET START() BE WRITES("Hello, World")
Every "sentence" in BCPL is a command (statement) or an expression, and similar to Pascal, in BCPL there is a distinction in the definition of routines (procedures) which have no return value and functions which do. Unlike Pascal, however, the body of a function is simply an expression whose value is returned when the function is called. A routine is declared with
LET FOO1(ARG1, ARG2) BE WRITED(ARG1 + ARG2)
and a function is declared with
LET FOO2(ARG1, ARG2) = ARG1 + ARG2

As in C, multiple commands can be blocked. In BCPL this is done by starting the block with

$(
and ending it with
$)
Blocking can be done in a number of other contexts--for instance, a command block may return a value by saying RESULTIS FOO, in which case the block must be preceded by VALOF to indicate that the block is an expression. Multiple commands must be separated by either a newline or a semicolon.

LET FOO1(ARG1, ARG2) BE
$(
    LET BAR = 0
    BAR = ARG1 + ARG2
    WRITED(BAR, 0)
$)

LET FOO2(ARG1, ARG2) =
VALOF $(
    LET BAR = 0

    ARG1 = ARG1 + 1
    ARG3 = ARG1 + ARG2
    RESULTIS ARG3
$)

Vectors (arrays) are declared by LET FOO = VEC 10, which declares (unintuitively enough) a vector of eleven elements, addressed from FOO!0 to FOO!10, and places a pointer to this vector in FOO. Should you wish to learn all the details of this language, the best reference is the aforementioned out-of-print book by Richards. But be warned, if C "combines all the elegance and power of assembly language with all the readability and maintainability of assembly language," then it must be said that BCPL combines all the elegance and power of C with all the readability and maintainability of COBOL.

Log in or register to write something here or to contact authors.