Main Page | See live article | Alphabetical index

B programming language

The best-known programming language named B is now obsolete, and is principally significant because it was a transitional phase between BCPL and C. It was mostly the work of Ken Thompson, and first appeared in 1969 or thereabouts.

It was essentially BCPL stripped of anything Thompson felt he could do without, in order to fit it on very small computers, and with some changes to suit Thomson's tastes (mostly along the lines of reducing the number of non-whitespace characters in a typical program).

Like BCPL and FORTH, B had only one datatype, the computer word. Most operators treated this as an integer (ie, +, -, *, /) but others treated it as a memory address to be dereferenced. In most other ways it looked a lot like an early version of C. A few library functions existed, including some that vaguely resemble functions from the standard IO library in C.

Early implementations were for the DEC PDP-7 and PDP-11 minicomputers running early Unix, and Honeywell 36 bit mainframes running GCOS. The earliest PDP-7 implementations compiled to threaded code, then Ritchie wrote a compiler which produced machine code. In 1970 a PDP-11 was acquired and threaded code was used for the port. The first version of yacc was produced with this PDP-11 configuration. Ritchie took over maintenance during this period.

The typeless nature of B made sense on the Honeywell, PDP-7 and many older computers, but was a problem on the PDP-11 because it was difficult to elegantly access the character data type that the PDP-11 and most modern computers fully support. Starting in 1971 Ritchie made changes to the language while converting its compiler to produce machine code, most notably adding data typing for variables. During 1971 and 1972 B evolved into "New B" and then C, with the preprocessor being added in 1972 and early 1973 at the urging of Alan Snyder. The effort was sufficiently complete that during the summer of 1973 the Unix kernel for the PDP-11 was rewritten in C. During the 1972-73 period there was a need to port to Honeywell 635 and IBM 360/370 machines, so Lesk wrote the "portable I/O package" which would become the C "standard I/O" routines.

B continued to see use as late as the 1990s on Honeywell mainframes, and on certain embedded systems for a variety of reasons, including limited hardware in the small systems; extensive libraries, tools, licensing cost issues; and simply being good enough for the job on others. The highly influential AberMUD was written in B.

According to Ken, B was greatly influenced by BCPL, but the name B had nothing to do with BCPL. B was in fact a revision of an earlier language, bon, named after Ken Thompson's wife, Bonnie.

See also

2. Another language, also called B, was a simple interactive programming language by Lambert Meertens and Steven Pemberton. This B was the predecessor of ABC.

["Draft Proposal for the B Language", Lambert Meertens, CWI, Amsterdam, 1981].

3. See also the B specification language

Part of this article was originally based on material from FOLDOC, used with permission. Update as needed.