BCPL
This article needs additional citations for verification. (May 2010) |
Paradigm | procedural, imperative, structured |
---|---|
Designed by | Martin Richards |
First appeared | 1967[1] |
Typing discipline | typeless (everything is a word) |
Influenced by | |
CPL | |
Influenced | |
B, C, Go[2] |
BCPL ("Basic Combined Programming Language") is a
Design
This section needs additional citations for verification. (January 2017) |
BCPL was designed so that small and simple compilers could be written for it; reputedly some compilers could be run in 16
).The language is unusual in having only one data type: a word, 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 or on machines with larger word sizes such as 32-bit or 64-bit.[citation needed]
The interpretation of any value was determined by the operators used to process the values. (For example, +
added two values together, treating them as
The mismatch between BCPL's word orientation and byte-oriented hardware was addressed in several ways. One was by providing standard library routines for packing and unpacking words into byte strings. Later, two language features were added: the bit-field selection operator and the infix byte indirection operator (denoted by %
).[4]
BCPL handles bindings spanning separate
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.[citation needed]
BCPL was the first
$(
and $)
in place of the symbols {
and }
. The single-line //
comments of BCPL, which were not adopted by C, reappeared in C++ and later in C99The book BCPL: The language and its compiler describes the philosophy of BCPL as follows:
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.[5]
History
BCPL was first implemented by
BCPL has been rumored to have originally stood for "Bootstrap Cambridge Programming Language", but CPL was never created since development stopped at BCPL, and the acronym was later reinterpreted for the BCPL book.[clarification needed][citation needed]
BCPL is the language in which the original
).Several
was written in BCPL.An early compiler, bootstrapped in 1969, by starting with a paper tape of the O-code of Richards's Atlas 2 compiler, targeted the ICT 1900 series. The two machines had different word-lengths (48 vs 24 bits), different character encodings, and different packed string representations—and the successful bootstrapping increased confidence in the practicality of the method.
By late 1970, implementations existed for the
There was also a version produced for the BBC Micro in the mid-1980s, by Richards Computer Products, a company started by John Richards, the brother of Martin Richards.[7] The BBC Domesday Project made use of the language. Versions of BCPL for the Amstrad CPC and Amstrad PCW computers were also released in 1986 by UK software house Arnor Ltd. MacBCPL was released for the Apple Macintosh in 1985 by Topexpress Ltd, of Kensington, England.
Both the design and philosophy of BCPL strongly influenced
programming language also exists.In 1979, implementations of BCPL existed for at least 25 architectures; the language gradually fell out of favour as C became popular on non-Unix systems.
Martin Richards maintains a modern version of BCPL on his website, last updated in 2018. This can be set up to run on various systems including Linux, FreeBSD, and Mac OS X. The latest distribution includes graphics and sound libraries, and there is a comprehensive manual. He continues to program in it, including for his research on musical automated score following.
A common informal MIME type for BCPL is text/x-bcpl.
Examples
Hello world
Richards and Whitby-Strevens[10] provide an example of the "Hello, World!" program for BCPL using a standard system header, 'LIBHDR':
GET "LIBHDR" LET START() BE WRITES("Hello, World")
Further examples
This section possibly contains original research. (August 2019) |
If these programs are run using Richards' current version of Cintsys (December 2018), LIBHDR, START and WRITEF must be changed to lower case to avoid errors.
Print factorials:
GET "LIBHDR" LET START() = VALOF $( FOR I = 1 TO 5 DO WRITEF("%N! = %I4*N", I, FACT(I)) RESULTIS 0 $) AND FACT(N) = N = 0 -> 1, N * FACT(N - 1)
Count 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("%I2-QUEENS PROBLEM HAS %I5 SOLUTIONS*N", I, COUNT) ALL := 2 * ALL + 1 $) RESULTIS 0 $)
References
- ^ a b c "Martin Richards (2003 Computer Pioneer Award)". IEEE Computer Society. Archived from the original on 24 November 2017. Retrieved 24 November 2017.
- ^ Pike, Rob (24 April 2014). "Hello Gophers". Retrieved 11 March 2016.
- ^ https://www.cl.cam.ac.uk/~mr10/bcplman.pdf The BCPL Cintsys and Cintpos User Guide, 2.1.4 Section brackets
- ^ "Clive Feather on CPL and BCPL". www.lysator.liu.se. Retrieved 1 March 2024.
- ISBN 978-0521785433.
- ^ BCPL, Jargon File
- ^ "Reuters technical development: Glossary - THE BARON". www.thebaron.info.
- ISBN 0-13-110163-3.
- ^ History of C++ Retrieved 12 December 2017
- ISBN 978-0521785433.
Further reading
- Martin Richards, The BCPL Reference Manual (Memorandum M-352, Project MAC, Cambridge, MA, USA, 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, MA, USA, 1974)
- Martin Richards, Colin Whitby-Strevens, BCPL, the language and its compiler (Cambridge University Press, 1980) ISBN 0-521-28681-6
External links
- Martin Richards' BCPL distribution
- Martin Richards' BCPL Reference Manual, 1967 by Dennis M. Ritchie
- BCPL entry in the Jargon File
- Nordier & Associates' x86 port
- ArnorBCPL manual (1986, Amstrad PCW/CPC)
- How BCPL evolved from CPL, Martin Richards [1]
- Ritchie's The Development of the C Language has commentary about BCPL's influence on C
- The BCPL Cintsys and Cintpos User Guide