All Topics  
BCPL

 

   Email Print
   Bookmark   Link

 

BCPL


 
 

BCPL (Basic Combined Programming Language) is a computerComputer

A computer is a machine for manipulating data according to a list of instructions known as a program....
 programming languageFacts About Programming language

A programming language is an artificial language that can be used to control the behavior of a machine, particularly a compu...
 designed by Martin RichardsMartin Richards

Martin Richards is a British computer scientist, best known for his development of the BCPL programming language, which is b...
 of the University of CambridgeUniversity of Cambridge

name = University of Cambridge|latin_name = Universitas Cantabrigiensis...
 in 1966.

Originally intended for writing compilerCompiler

A compiler is a computer program that translates text written in a computer language into another computer language ....
s for other languages, BCPL is no longer in common use. However, its influence is still felt because the language BB programming language Summary

B was the name of a programming language developed at Bell Labs....
, upon which the C programming languageC (programming language)

The C programming language is a general-purpose, procedural, imperative computer programming language developed in the earl...
 was based, was a stripped down and syntactically changed version of BCPL. BCPL was the first curly bracket programming languageCurly bracket programming language

Curly brace or bracket programming languages are those which use balanced brackets to make blocks in their syntax or f...
, and the curly brackets survived the syntactical changes and have become a common means of denoting program source code statements. In practice, on limited keyboards of the day, source programs often used the sequences $( and $) in place of the symbols .
The single-line '//' comments of BCPL, which were not taken up in C, reappeared in C++C++

C++ is a general-purpose, high-level programming language with low-level facilities....
, and later in C99C99

C99 is a modern dialect of the C programming language. ...
.

BCPL was a response to difficulties with its predecessor CPLCombined Programming Language

The Combined Programming Language was a computer programming language developed jointly between the Mathematical Laboratory ...
, created during the early 1960s; Richards created BCPL by "removing those features of the full language which make compilation difficult". The first compiler implementation, for the IBM 7094 under CTSS, was written while Richards was visiting Project MACProject MAC

Project MAC, later the MIT Laboratory for Computer Science, was a research laboratory at MIT....
 at MITMassachusetts Institute of Technology

The Massachusetts Institute of Technology, or MIT, is a private world-leading research university in Cambridge, Massac...
 in the spring of 1967. The language was first described in a paper presented to the 1969 Spring Joint Computer Conference.

The language is clean, powerful, and portable. It therefore proved possible to write small and simple compilers for it; reputedly some compilers could be run in 16 kilobyteKilobyte

A kilobyte is a unit of information or computer storage equal to either 1024 or 1000 bytes....
s. In addition, the Richards compiler, itself written in BCPL, was easily portable. BCPL was therefore a popular choice for bootstrappingBootstrapping (compilers)

Bootstrapping is a term used in computer science to describe the techniques involved in writing a compiler in the target pro...
 a system.

A major reason for the compiler's portability lay in its structure. It was split into two parts: the front end parsed the source and generated O-codeO-code machine

The O-code machine is a virtual machine that was developed by Martin Richards in the late 1960s to give machine independence...
 for a virtual machineVirtual machine

In computer science, a virtual machine is software that creates a virtualized environment between the computer platform so t...
, and the back end took the O-code and translated it into the code for the target machine. Only 1/5th of the compiler's code needed to be rewritten to support a new machine, a task that usually took between 2 and 5 man-months. Soon afterwards this structure became fairly common practice, cf. PascalPascal (programming language)

Pascal is an imperative computer programming language, developed in 1970 by Niklaus Wirth as a language particularly suitabl...
 or JavaJava (Sun)

Java refers to a number of computer software products and specifications from Sun Microsystems that together provide a syste...
, but the Richards BCPL compiler was the first to define a virtual machine for this purpose.

The language is unusual in having only one data typeData type

Data type is a type of data in a type system in computer programming....
: a wordWord (computer science)

In computing, "word" is a term for the natural unit of data used by a particular computer design....
, a fixed number of bits, usually chosen to align with the architecture's machine word and of adequate capacity to represent any valid storage address. For many machines of the time, this data type was a 16-bit word. This choice later proved to be a significant problem when BCPL was used on machines in which the smallest addressable item was not a word, but a byteByte

A byte is commonly used as a unit of storage measurement in computers, regardless of the type of data being stored....
 or on machines with larger word sizes: 32-bit and 64-bit words, which allowed them to manage large address spaces.

The interpretation of any value was determined by the operators used to process the values. (For example, + added two values together treating them as integerInteger

The integers consist of the positive natural numbers , their negatives and the number zero....
s; ! indirected through a value, effectively treating it as a pointer.) In order for this to work, the implementation provided no type checking. The Hungarian NotationHungarian notation

Hungarian notation is a naming convention in computer programming, in which the name of an object indicates its type or inte...
 was developed to help programmers avoid inadvertent type errors.

The mismatch between BCPL's word orientation and byte-oriented hardware was addressed in a number of ways. One was the provision of standard library routines for packing and unpacking words into byte strings. Later, two language features—the bit-field selection operator and the infix byte indirection operator (denoted by the '%' character) – were added.

BCPL handles bindings spanning separate compilation units in a unique way. There are no user-declarable global variables; instead there is a global vector, which is similar to "blank common" in FortranFortran

FORTRAN is a general-purpose, procedural, imperative programming language that is especially suited to numeric computation a...
. All data shared between different compilation units comprises scalars and pointers to vectors stored in a pre-arranged place in the global vector. Thus the header files (files included during compilation using the "GET" directive) become the primary means of synchronizing global data between compilation units, containing "GLOBAL" directives that present lists of symbolic names, each paired with a number that associates the name with the corresponding numerically addressed word in the global vector. As well as variables, the global vector also contains bindings for external procedures. This makes dynamic loading of compilation units very simple to achieve. Instead of relying on the link loader of the underlying implementation, effectively BCPL gives the programmer control of the linking process.

BCPL is reputedly the language in which the original hello world programHello world program

A "hello world" program is a software program that prints out "Hello world!" on a display device....
 was written. The first MUDMUD

In computer gaming, a MUD is a multi-player computer game that combines elements of role-playing games, hack and slash styl...
 was also written in BCPL .

Several operating systems were written partially or wholly in BCPL (for example, TRIPOSTRIPOS

TRIPOS is a computer operating system....
 and significant parts of AmigaOSAmigaOS

AmigaOS is the default native operating system of the Amiga personal computer....
, including Kickstart and the earliest versions of AmigaDOS). BCPL was also the initial language used in the seminal Xerox PARCXerox PARC

Xerox Palo Alto Research Center was a flagship research division of the Xerox Corporation, based in Palo Alto, California, ...
 Alto project, the first modern personal computerPersonal computer

A personal computer is usually a microcomputer whose price, size, and capabilities make it suitable for personal usage....
; among many other influential projects, the ground-breaking BravoBravo (software)

Bravo was the first WYSIWYG document preparation program....
 document preparation system was written in BCPL.

By 1970, implementations existed for the Honeywell 635 and 645, the IBM 360, the TX-2TX-2

The MIT Lincoln Laboratory TX-2 computer was the successor to the Lincoln TX-0 and was known for its role in advancing both ...
, the CDC 6400CDC 6400

The CDC 6400, a member of the CDC 6000 series, was a mainframe computer made by Control Data Corporation in the 1960s....
, the Univac 1108UNIVAC 1108

The UNIVAC 1108 was the second member of Sperry Rand's UNIVAC 1100 series of computers, introduced in 1964....
, the PDP-9Programmed Data Processor

Programmed Data Processor was the name of a series of computers, several of them ground-breaking and very influential, mad...
, the KDF 9 and the Atlas 2. In 1979 implementations existed for at least 25 architectures; in 2001 it sees little use.

The philosophy of BCPL can be summarised by quoting from the book BCPL, the language and its compiler:
The philosophy of BCPL is not one of the 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.


The design, and philosophy, of BCPL strongly influenced B, which in turn influenced CC (programming language)

The C programming language is a general-purpose, procedural, imperative computer programming language developed in the earl...
.

Examples

These complete and compilable examples are from Martin Richards' BCPL distribution.

Printing factorials:

GET "libhdr"

LET start = VALOF

AND fact(n) = n=0 -> 1, n*fact(n-1)


Counting solutions to the N queens problem:

GET "libhdr"

GLOBAL

LET try(ld, row, rd) BE TEST row=all

THEN count := count + 1

ELSE

LET start = VALOF


Sources

  • Martin Richards, (Memorandum M-352, Project MAC, Cambridge, July, 1967)
  • Martin Richards, BCPL - a tool for compiler writing and systems programming (Proceedings of the Spring Joint Computer Conference, Vol 34, pp 557-566, 1969)
  • Martin Richards, Arthur Evans, Robert F. Mabee, The BCPL Reference Manual (MAC TR-141, Project MAC, Cambridge, 1974)
  • Martin Richards, C. Whitby-Strevens, BCPL, the language and its compiler (Cambridge University Press, 1980) ISBN 0-521-28681-6

External links

  • by Dennis M. Ritchie also includes some fascinating commentary from him about BCPL's influence on C
  • in the Jargon FileJargon File Summary

    The Jargon File is a glossary of hacker slang....