Telecommunication Engineering    
   
Table of contents
(Prev) Axon Idea ProcessorBack end of line (Next)

B (programming language)

B
Appeared in1969
Designed byKen Thompson
DeveloperKen Thompson, Dennis Ritchie
Typing disciplinetypeless (everything is a word)
Influenced byBCPL, PL/I
InfluencedC
Usual filename extensions.b

B is a programming language that was developed at Bell Labs. It is extinct, having been superseded by the C language. It was mostly the work of Ken Thompson, with contributions from Dennis Ritchie, and first appeared circa 1969.

Contents

History

Ken Thompson wrote B basing it mainly on the BCPL language he had used in the Multics project. B was essentially the BCPL system stripped of any component that Thompson felt he could do without, in order to make it fit within the memory capacity of the minicomputers of the time. The language also included some changes made to suit Thompson's preferences (mostly along the lines of reducing the number of non-whitespace characters in a typical program).[citation needed]

Like BCPL and FORTH, B had only one datatype: the computer word. Most operators (e.g., +, -, *, /) treated this as an integer, but others treated it as a memory address to be dereferenced. In many 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 I/O library in C.

Early implementations were for the DEC PDP-7 and PDP-11 minicomputers using early Unix, and Honeywell GE 645[1] 36-bit mainframes running the operating system GCOS. The earliest PDP-7 implementations compiled to threaded code, and then Ritchie wrote a compiler using TMG which produced machine code.[2][3] In 1970 a PDP-11 was acquired and threaded code was used for the port. An early 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 Mike 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 originally written in B.

B was greatly influenced by BCPL, and its name is most likely to be a contraction of BCPL. It is possible that its name may be based on Bon, an earlier but unrelated, and rather different, programming language that Thompson designed for use on Multics.[4]

Example

The following example is from the Users' Reference to B by Ken Thompson:

/* The following function will print a non-negative number, n, to  the base b, where 2<=b<=10,  This routine uses the fact that  in the ASCII character set, the digits 0 to 9 have sequential  code values.  */ printn(n,b) { extrn putchar; auto a; if(a=n/b) /* assignment, not test for equality */ printn(a, b); /* recursive */ putchar(n%b + '0');}

Notes

  1. ^ bell-labs.com - Early Unix history and evolution, 2004-04-09
  2. ^ "TMG". multicians.org. http://www.multicians.org/tmg.html.
  3. ^ Ritchie, Dennis M.. "The Development of the C Language". Bell Labs/Lucent Technologies. http://cm.bell-labs.com/cm/cs/who/dmr /chist.html.
  4. ^ Ritchie, Dennis M. (March 1993). "The Development of the C Language". ACM SIGPLAN Notices 28 (3): 201–208. doi:10.1145/155360.155580. http://cm.bell-labs.com/cm/cs/who/dmr /chist.html. "Its name most probably represents a contraction of BCPL, though an alternate theory holds that it derives from Bon [Thompson 69], an unrelated language created by Thompson during the Multics days. Bon in turn was named either after his wife Bonnie, or (according to an encyclopedia quotation in its manual), after a religion whose rituals involve the murmuring of magic formulas."

External links

(Prev) Axon Idea ProcessorBack end of line (Next)