All Topics  
BCPL

 

   Email Print
   Bookmark   Link






 

BCPL



 
 
BCPL (Basic Combined Programming Language) is a computer
Computer

A computer is a machine that manipulates Data according to a list of Code .The first devices that resemble modern computers date to the mid-20th century , although the computer concept and various machines similar to computers existed earlier....
 programming language
Programming language

A programming language is a machine-readable artificial language designed to express computations that can be performed by a machine, particularly a computer....
 designed by Martin Richards
Martin Richards

Martin Richards is a British computer scientist, best known for his development of the BCPL programming language, which is both the earliest major development in portability software and the ancestor of the widely used C ....
 of the University of Cambridge
University of Cambridge

The University of Cambridge , located in Cambridge, England, is the List of oldest universities in continuous operation university in the Anglosphere....
 in 1966.

Design
Originally intended for writing compiler
Compiler

A compiler is a computer program that transforms source code written in a programming language into another computer language . The most common reason for wanting to transform source code is to create an executable program....
s for other languages, BCPL is no longer in common use. However, its influence is still felt because the language B, upon which the C programming language
C (programming language)

C is a general-purpose computer programming language originally developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories to implement the Unix operating system....
 was based, was a stripped down and syntactically changed version of BCPL. BCPL was the first curly bracket programming language
Curly bracket programming language

Curly brace or bracket programming languages are those which use balanced brackets to make block s in their syntax or formal grammar, mainly due to being C -influenced....
, and the curly brackets survived the syntactical changes and have become a common means of denoting program source code statements.






Discussion
Ask a question about 'BCPL'
Start a new discussion about 'BCPL'
Answer questions from other users
Full Discussion Forum



Encyclopedia


BCPL (Basic Combined Programming Language) is a computer
Computer

A computer is a machine that manipulates Data according to a list of Code .The first devices that resemble modern computers date to the mid-20th century , although the computer concept and various machines similar to computers existed earlier....
 programming language
Programming language

A programming language is a machine-readable artificial language designed to express computations that can be performed by a machine, particularly a computer....
 designed by Martin Richards
Martin Richards

Martin Richards is a British computer scientist, best known for his development of the BCPL programming language, which is both the earliest major development in portability software and the ancestor of the widely used C ....
 of the University of Cambridge
University of Cambridge

The University of Cambridge , located in Cambridge, England, is the List of oldest universities in continuous operation university in the Anglosphere....
 in 1966.

Design


Originally intended for writing compiler
Compiler

A compiler is a computer program that transforms source code written in a programming language into another computer language . The most common reason for wanting to transform source code is to create an executable program....
s for other languages, BCPL is no longer in common use. However, its influence is still felt because the language B, upon which the C programming language
C (programming language)

C is a general-purpose computer programming language originally developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories to implement the Unix operating system....
 was based, was a stripped down and syntactically changed version of BCPL. BCPL was the first curly bracket programming language
Curly bracket programming language

Curly brace or bracket programming languages are those which use balanced brackets to make block s in their syntax or formal grammar, mainly due to being C -influenced....
, 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 programming language. It is regarded as a middle-level language, as it comprises a combination of both high-level programming language and low-level programming language language features....
, and later in C99
C99

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

BCPL was a response to difficulties with its predecessor CPL
Combined Programming Language

The Combined Programming Language was a computer programming language developed jointly between the Mathematical Laboratory at the University of Cambridge and the University of London Computer Unit during the 1960s....
, 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 MAC at MIT
Massachusetts Institute of Technology

The Massachusetts Institute of Technology is a private university research university located in Cambridge, Massachusetts, Massachusetts, United States....
 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 kilobyte
Kilobyte

Kilobyte is a unit of Computer data storage equal to either 1,024 bytes or 1,000 bytes , depending on context.It is abbreviated in a number of ways: KB, kB, K and Kbyte....
s. In addition, the Richards compiler, itself written in BCPL, was easily portable. BCPL was therefore a popular choice for bootstrapping
Bootstrapping (compilers)

Bootstrapping is a term used in computer science to describe the techniques involved in writing a compiler in the target programming language which it is intended to compile....
 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-code
O-code machine

The O-code machine is a virtual machine that was developed by Martin Richards in the late 1960s to give machine independence to BCPL, the low-level forerunner to C and C++....
 for a virtual machine
Virtual machine

In computer science, a virtual machine is a software implementation of a machine that executes programs like a real machine.Definitions...
, 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. Pascal
Pascal (programming language)

Pascal is an influential imperative programming and Procedural programming programming language, designed in 1968/9 and published in 1970 by Niklaus Wirth as a small and efficient language intended to encourage good programming practices using structured programming and data structure....
 or Java
Java (Sun)

Java refers to a number of computer software products and specifications from Sun Microsystems that together provide a system for developing application software and deploying it in a cross-platform environment....
, 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 type
Data type

A data type in programming languages is an attribute of a data which tells the computer something about the kind of data it is. This involves setting constraints on the datum, such as what values it can take and what operations may be performed upon it....
: a word
Word (computer science)

In computing, "word" is a term for the natural unit of data used by a particular computer design. A word is simply a fixed-sized group of bits that are handled together by the machine....
, 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 byte
Byte

A byte is a basic unit of measurement of Computer storage in computer science. In many computer architectures it is a Byte addressing memory address space....
 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 integer
Integer

The integers are natural numbers including 0 and their negative and non-negative numberss . They are numbers that can be written without a fractional or decimal component, and fall within the set ....
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 Notation
Hungarian notation

Hungarian notation is a identifier naming convention in computer programming, in which the name of a variable indicates its data type or intended use....
 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 Fortran
Fortran

Fortran is a general-purpose programming language, procedural programming language, imperative programming language programming language that is especially suited to numerical analysis and scientific computing....
. 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.

The global vector also made it very simple to replace or augment standard library routines. A program could save the pointer from the global vector to the original routine and replace it with a pointer to an alternative version. The alternative might call the original as part of its processing. This could be used as a quick ad-hoc debugging aid.

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

A "Hello World" program is a computer program that prints out "Hello world!" on a display device. It is used in many introductory tutorials for teaching a programming language....
 was written. The first MUD
MUD

In Online game, a MUD , pronounced /m?d/, is a multi-user real-time virtual world described entirely in text. It combines elements of role-playing games, hack and slash, interactive fiction, and online chat....
 was also written in BCPL .

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

TRIPOS is a computer operating system. Development started in 1976 at the Computer Laboratory of University of Cambridge and it was headed by Dr....
 and significant parts of AmigaOS
AmigaOS

AmigaOS is the default native operating system of the Amiga personal computer. It was developed first by Commodore International, and initially introduced in 1985 with the Amiga 1000....
, including Kickstart and the earliest versions of AmigaDOS). BCPL was also the initial language used in the seminal Xerox PARC
Xerox PARC

PARC , formerly Xerox PARC, is a research and development company in Palo Alto, California with a distinguished reputation for its contributions to information technology....
 Alto project, the first modern personal computer
Personal computer

A personal computer is any general-purpose computer whose original sales price, size, and capabilities make it useful for individuals, and which is intended to be operated directly by an end user, with no intervening computer operator....
; among many other influential projects, the ground-breaking Bravo
Bravo (software)

Bravo was the first WYSIWYG document preparation computer program. It provided typeface capability using the bitmap computer display on the Xerox Alto personal computer....
 document preparation system was written in BCPL.

By 1970, implementations existed for the Honeywell 635 and 645, the IBM 360, the TX-2
TX-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 artificial intelligence and human-computer interaction....
, the CDC 6400
CDC 6400

The CDC 6400, a member of the CDC 6000 series, was a Mainframe computer computer made by Control Data Corporation in the 1960s. The central processing unit was architecturally compatible with the CDC 6600....
, the Univac 1108
UNIVAC 1108

The UNIVAC 1108 was the second member of UNIVAC's UNIVAC 1100/2200 series of computers, introduced in 1964. Integrated circuits replaced the thin film memory that the UNIVAC 1107 used for Processor register....
, the PDP-9
Programmed Data Processor

Programmed Data Processor was the name of a series of minicomputers made by Digital Equipment Corporation. The name 'PDP' intentionally avoided the use of the term 'computer' because at the time of the first PDPs, computers had a reputation of being large, complicated, and expensive machines, and the venture capitalists behind Digital would...
, the KDF 9 and the Atlas 2. There was also a version produced for the BBC Micro
BBC Micro

The BBC Microcomputer System, or BBC Micro, was a series of microcomputers and associated peripherals designed and built by Acorn Computers for the BBC Computer Literacy Project, operated by the British Broadcasting Corporation....
 in the mid 1980s by a Richards Computer Products, a company run mainly by the brother of Dr. Martin Richards. Versions of BCPL for the Amstrad CPC
Amstrad CPC

The Amstrad CPC is a series of 8-bit home computers produced by Amstrad during the 1980s and early 1990s. "CPC" stands for 'Colour Personal Computer', although it was possible to purchase a CPC with a Green screen display as well as with the standard colour screen ....
 and Amstrad PCW
Amstrad PCW

The Amstrad PCW series was United Kingdom company Amstrad's versatile line of home/personal microcomputers pitched as a complete, integrated home/office solution....
 computers were also released in 1986 by UK software house Arnor Ltd.

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 C
C (programming language)

C is a general-purpose computer programming language originally developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories to implement the Unix operating system....
.

Examples

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

Printing factorials:
GET "libhdr"

LET start = VALOF $( FOR i = 1 TO 5 DO writef("fact(%n) = %i4*n", i, fact(i)) RESULTIS 0 $)

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


Counting solutions to the N queens problem:
GET "libhdr"

GLOBAL $( count:200; all:201 $)

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

THEN count := count + 1

ELSE $( LET poss = all & ~(ld | row | rd) UNTIL poss=0 DO $( LET p = poss & -poss poss := poss - p try(ld+p << 1, row+p, rd+p >> 1) $) $)

LET start = VALOF $( all := 1

FOR i = 1 TO 12 DO $( count := 0 try(0, 0, 0) writef("Number of solutions to %i2-queens is %i5*n", i, count) all := 2*all + 1 $)

RESULTIS 0 $)


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 File
    Jargon File

    The Jargon File is a glossary of hacker slang. The original Jargon File was a collection of hacker slang from technical cultures such as the MIT Artificial Intelligence Laboratory, the Stanford AI Lab , and others of the old ARPANET Artificial Intelligence/Lisp programming language/PDP-10 communities, including Bolt, Beranek and Newman, Carn...
  • Nordier & Associates' port
    Port

    ||-||-|-||-||-||-||-||-||-|}A port is a facility for receiving ships and transferring cargo. They are usually found at the edge of an ocean, sea, river, or lake....
     of BCPL to x86: http://www.nordier.com/software/bcpl.html