Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
BCPL
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Multi-paradigm computer programming language}} {{Distinguish|text = [[BASIC]]}} {{About|the programming language|the library system|Baltimore County Public Library}} {{Use dmy dates|date=April 2022}} {{Infobox programming language | name = BCPL | logo = | paradigm = [[procedural programming|procedural]], [[imperative programming|imperative]], [[structured programming|structured]] | year = {{start date and age|1967}}<ref name="IEEE_CPA_MRichards"/> | designer = [[Martin Richards (computer scientist)|Martin Richards]] | developer = | latest_release_version = | latest_release_date = | latest_test_version = | latest_test_date = | typing = typeless (everything is a [[Word (computer architecture)|word]]) | implementations = | dialects = | influenced_by = [[CPL (programming language)|CPL]] | influenced = [[B (programming language)|B]], [[C (programming language)|C]], [[Go (programming language)|Go]]<ref name="hgophers">{{cite web |url=https://talks.golang.org/2014/hellogophers.slide#21 |title=Hello Gophers |last=Pike |first=Rob |date=2014-04-24 |access-date=2016-03-11 }}</ref> | operating_system = | license = | website = }} '''BCPL''' ("'''Basic Combined Programming Language'''") is a [[procedural programming|procedural]], [[imperative programming|imperative]], and [[structured programming|structured]] [[programming language]]. Originally intended for writing [[compiler]]s for other languages, BCPL is no longer in common use. However, its influence is still felt because a stripped down and syntactically changed version of BCPL, called [[B (programming language)|B]], was the language on which the [[C (programming language)|C programming language]] was based. BCPL introduced several features of many modern programming languages, including using [[brace programming language|curly braces]] to delimit code blocks.<ref>https://www.cl.cam.ac.uk/~mr10/bcplman.pdf The BCPL Cintsys and Cintpos User Guide, 2.1.4 Section brackets</ref> BCPL was first implemented by [[Martin Richards (computer scientist)|Martin Richards]] of the [[University of Cambridge]] in 1967.<ref name="IEEE_CPA_MRichards">{{cite web |url=https://www.computer.org/web/awards/pioneer-martin-richards |title=Martin Richards (2003 Computer Pioneer Award) |author=<!--Not stated--> |publisher=IEEE Computer Society |date=<!--Not stated--> |access-date=2017-11-24 |archive-url=https://archive.today/20171124083723/https://www.computer.org/web/awards/pioneer-martin-richards |archive-date=2017-11-24 |url-status = dead}}</ref> ==Design== {{More citations needed section|date=January 2017}} BCPL was designed so that small and simple compilers could be written for it; reputedly some compilers could be run in 16 [[kilobyte]]s. Furthermore, the original compiler, itself written in BCPL, was easily portable. BCPL was thus a popular choice for [[bootstrapping (compilers)|bootstrapping]] a system.{{Citation needed|date=January 2017}} 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, an [[intermediate language]]. The back end took the O-code and translated it into the machine code for the target machine. Only {{frac|5}} of the compiler's code needed to be rewritten to support a new machine, a task that usually took between 2 and 5 [[man-month|person-month]]s. This approach became common practice later (e.g. [[Pascal (programming language)|Pascal]], [[Java (programming language)|Java]]). The language is unusual in having only one [[data type]]: a [[Word (computer architecture)|word]], a fixed number of bits, usually chosen to align with the same platform 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|date=January 2017}} The interpretation of any value was determined by the operators used to process the values. (For example, <code>+</code> added two values together, treating them as [[integer]]s; <code>!</code> indirected through a value, effectively treating it as a pointer.) In order for this to work, the implementation provided no [[type checking]]. The mismatch between BCPL's word orientation and [[Byte addressing|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 <code>%</code>).<ref>{{Cite web |title=Clive Feather on CPL and BCPL |url=https://www.lysator.liu.se/c/clive-on-history.html |access-date=2024-03-01 |website=www.lysator.liu.se}}</ref> BCPL handles bindings spanning separate [[compilation unit]]s in a unique way. There are no user-declarable global variables; instead, there is a global vector, similar to "blank common" in [[Fortran]]. 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 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.{{Citation needed|date=January 2017}} 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|date=January 2017}} BCPL was the first [[brace programming language]] and the braces 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 <code>$(</code> and <code>$)</code> or <code>[</code> and <code>]</code> in place of the symbols <code>{</code> and <code>}</code>. The single-line <code>//</code> [[comment (computer programming)|comment]]s of BCPL, which were not adopted by [[C (programming language)|C]], reappeared in [[C++]] and later in [[C99]]. The book ''BCPL: The language and its compiler'' describes the philosophy of BCPL as follows: {{Blockquote|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.<ref>{{Cite book|title=BCPL: The Language and its Compiler|last1=Richards|first1=Martin|last2=Whitby-Strevens|first2=Colin|publisher=Cambridge University Press|year=1980|isbn=978-0521785433|pages=5}}</ref>}} ==History== BCPL was first implemented by [[Martin Richards (computer scientist)|Martin Richards]] of the [[University of Cambridge]] in 1967.<ref name="IEEE_CPA_MRichards">{{cite web |url=https://www.computer.org/web/awards/pioneer-martin-richards |title=Martin Richards (2003 Computer Pioneer Award) |author=<!--Not stated--> |publisher=IEEE Computer Society |date=<!--Not stated--> |access-date=2017-11-24 |archive-url=https://archive.today/20171124083723/https://www.computer.org/web/awards/pioneer-martin-richards |archive-date=2017-11-24 |url-status = dead}}</ref> BCPL was a response to difficulties with its predecessor, Cambridge Programming Language, later renamed [[Combined Programming Language]] (CPL), which was designed 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 [[Compatible Time-Sharing System]], was written while Richards was visiting [[Project MAC]] at the [[Massachusetts Institute of Technology]] in the spring of 1967. The language was first described in a paper presented to the 1969 Spring [[Joint Computer Conference]].{{Citation needed|date=January 2017}} 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.{{Clarify|date=January 2017}}{{Citation needed|date=January 2017}} BCPL is the language in which the original [[hello world program|"Hello, World!" program]] was written.<ref>[http://www.catb.org/jargon/html/B/BCPL.html BCPL], ''[[Jargon File]]''</ref> The first [[Multi-user dungeon|MUD]] was also written in BCPL (''[[MUD1]]''). Several [[operating system]]s were written partially or wholly in BCPL (for example, [[TRIPOS]] and the earliest versions of [[AmigaDOS]]). BCPL was also the initial language used in the [[Xerox PARC]] [[Alto (computer)|Alto]] project. Among other projects, the [[Bravo (software)|Bravo]] [[Word processor|document preparation system]] was written in BCPL. An early compiler, bootstrapped in 1969, by starting with a paper tape of the O-code of Richards's [[Titan (1963 computer)|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 [[GE-600 series|Honeywell 635 and Honeywell 645]], [[IBM 360]], [[PDP-10]], [[TX-2]], [[CDC 6400]], [[UNIVAC 1108]], [[PDP-9]], [[KDF 9]] and Atlas 2. In 1974 a dialect of BCPL was implemented at [[BBN Technologies|BBN]] without using the intermediate O-code. The initial implementation was a [[cross-compiler]] hosted on BBN's [[TENEX (operating system)|TENEX]] [[PDP-10]]s, and directly targeted the [[PDP-11]]s used in BBN's implementation of the second generation [[Interface Message Processor|IMPs]] used in the [[ARPANET]]. 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.<ref>{{cite web|url=http://www.thebaron.info/archives/technology/reuters-technical-development-glossary|title=Reuters technical development: Glossary - THE BARON|website=www.thebaron.info}}</ref> 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 [[B (programming language)|B]], which in turn influenced [[C (programming language)|C]].<ref name="C_Prog_Lang_KR">{{cite book |url=https://archive.org/details/cprogramminglang00bria |title=The C Programming Language |date=1978 |publisher=Bell Telephone Laboratories |isbn=0-13-110163-3 |pages=2 |author1=Kernighan, Brian W. |author2=Dennis M. Ritchie }}</ref> Programmers at the time debated whether an eventual successor to C would be called "D", the next letter in the alphabet, or "P", the next letter in the parent language name. The language most accepted as being C's successor is [[C++]] (with <code>++</code> being C's [[increment operator]]),<ref>[http://www.cplusplus.com/info/history/ History of C++] Retrieved 12 December 2017</ref> although meanwhile, a [[D (programming language)|D]] 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 2023.<ref>{{cite web |url=https://www.cl.cam.ac.uk/~mr10/BCPL/README |title=BCPL/README (BCPL Cintcode distribution) |author=Martin Richards}}</ref> 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 [[Media type|MIME type]] for BCPL is {{mono|text/x-bcpl}}. ==Examples== === Hello world === Richards and Whitby-Strevens<ref>{{Cite book|title=BCPL: The Language and its Compiler|last1=Richards|first1=Martin|last2=Whitby-Strevens|first2=Colin|publisher=Cambridge University Press|year=1980|isbn=978-0521785433|pages=8}}</ref> provide an example of the [["Hello, World!" program]] for BCPL using a standard system header, 'LIBHDR': <pre> GET "LIBHDR" LET START() BE WRITES("Hello, World") </pre> === Further examples === {{original research|section|date=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: <pre> 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) </pre> Count solutions to the [[Eight queens puzzle|N queens problem]]: <pre> 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 $) </pre> ==References== {{Reflist}} ==Further reading== * Martin Richards, ''[https://www.bell-labs.com/usr/dmr/www/bcpl.html The BCPL Reference Manual]'' (Memorandum M-352, [[Project MAC]], Cambridge, MA, USA, July, 1967) <!-- temporary copy: http://www.fh-jena.de/~kleine/history/languages/Richards-BCPL-ReferenceManual.pdf --> * 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, ''[https://web.archive.org/web/20160305034639/http://publications.csail.mit.edu/lcs/specpub.php?id=709 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== * [http://www.cl.cam.ac.uk/users/mr/BCPL.html Martin Richards' BCPL distribution] * [https://www.bell-labs.com/usr/dmr/www/bcpl.html Martin Richards' BCPL Reference Manual, 1967] by [[Dennis M. Ritchie]] * [http://www.catb.org/~esr/jargon/html/B/BCPL.html BCPL entry] in the [[Jargon File]] * Nordier & Associates' [[x86]] [https://web.archive.org/web/20200715142010/http://www.nordier.com/software/bcpl.html port] * [http://cpcwiki.eu/imgs/3/3a/ArnorBCPL.pdf ArnorBCPL manual] (1986, [[Amstrad PCW]]/[[Amstrad CPC|CPC]]) * How BCPL evolved from CPL, Martin Richards [https://www.cl.cam.ac.uk/~mr10/cpl2bcpl.pdf] * [https://www.bell-labs.com/usr/dmr/www/chist.html Ritchie's ''The Development of the C Language''] has commentary about BCPL's influence on C * [https://www.cl.cam.ac.uk/~mr10/bcplman.pdf The BCPL Cintsys and Cintpos User Guide] * [http://www.bitsavers.org/pdf/xerox/alto/bcpl/BCPL_Reference_Manual_Sep75.pdf BCPL Reference Manual, 1975 Xerox Palo Alto Research Center] {{Authority control}} {{DEFAULTSORT:Bcpl}} [[Category:History of computing in the United Kingdom]] [[Category:Procedural programming languages]] [[Category:Programming languages created in 1967]] [[Category:Structured programming languages]] [[Category:Systems programming languages]] [[Category:University of Cambridge Computer Laboratory]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:About
(
edit
)
Template:Ambox
(
edit
)
Template:Authority control
(
edit
)
Template:Blockquote
(
edit
)
Template:Citation needed
(
edit
)
Template:Cite book
(
edit
)
Template:Cite web
(
edit
)
Template:Clarify
(
edit
)
Template:Comma separated entries
(
edit
)
Template:Distinguish
(
edit
)
Template:Frac
(
edit
)
Template:ISBN
(
edit
)
Template:Infobox programming language
(
edit
)
Template:Main other
(
edit
)
Template:Mono
(
edit
)
Template:More citations needed section
(
edit
)
Template:Original research
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)
Template:Use dmy dates
(
edit
)