B programming language
Encyclopedia
B is a programming language that was developed at Bell Labs
Bell Labs
Bell Laboratories is the research and development subsidiary of the French-owned Alcatel-Lucent and previously of the American Telephone & Telegraph Company , half-owned through its Western Electric manufacturing subsidiary.Bell Laboratories operates its...

. It is almost extinct, as it was replaced with the C language
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

. It was mostly the work of Ken Thompson, with contributions from Dennis Ritchie
Dennis Ritchie
Dennis MacAlistair Ritchie , was an American computer scientist who "helped shape the digital era." He created the C programming language and, with long-time colleague Ken Thompson, the UNIX operating system...

, and first appeared circa 1969.

History

Ken Thompson wrote B basing it mainly on the BCPL
BCPL
BCPL is a procedural, imperative, and structured computer programming language designed by Martin Richards of the University of Cambridge in 1966.- Design :...

 language he had used to write Unix
Unix
Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna...

 while in the Multics
Multics
Multics was an influential early time-sharing operating system. The project was started in 1964 in Cambridge, Massachusetts...

 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).

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
Reference (computer science)
In computer science, a reference is a value that enables a program to indirectly access a particular data item, such as a variable or a record, in the computer's memory or in some other storage device. The reference is said to refer to the data item, and accessing those data is called...

. 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
Digital Equipment Corporation
Digital Equipment Corporation was a major American company in the computer industry and a leading vendor of computer systems, software and peripherals from the 1960s to the 1990s...

 PDP-7
PDP-7
The DEC PDP-7 is a minicomputer produced by Digital Equipment Corporation. Introduced in 1965, it was the first to use their Flip-Chip technology. With a cost of only $72,000 USD, it was cheap but powerful by the standards of the time. The PDP-7 was the third of Digital's 18-bit machines, with...

 and PDP-11
PDP-11
The PDP-11 was a series of 16-bit minicomputers sold by Digital Equipment Corporation from 1970 into the 1990s, one of a succession of products in the PDP series. The PDP-11 replaced the PDP-8 in many real-time applications, although both product lines lived in parallel for more than 10 years...

 minicomputers using early Unix
Unix
Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna...

, and Honeywell
Honeywell
Honeywell International, Inc. is a major conglomerate company that produces a variety of consumer products, engineering services, and aerospace systems for a wide variety of customers, from private consumers to major corporations and governments....

 36-bit mainframes running the operating system GCOS
General Comprehensive Operating System
General Comprehensive Operating System is a family of operating systems oriented toward mainframe computers.The original version of GCOS was developed by General Electric from 1962; originally called GECOS...

. The earliest PDP-7 implementations compiled to threaded code
Threaded code
In computer science, the term threaded code refers to a compiler implementation technique where the generated code has a form that essentially consists entirely of calls to subroutines...

, and then Ritchie wrote a compiler using TMG which produced machine code. In 1970 a PDP-11
PDP-11
The PDP-11 was a series of 16-bit minicomputers sold by Digital Equipment Corporation from 1970 into the 1990s, one of a succession of products in the PDP series. The PDP-11 replaced the PDP-8 in many real-time applications, although both product lines lived in parallel for more than 10 years...

 was acquired and threaded code was used for the port. The first version of yacc
Yacc
The computer program yacc is a parser generator developed by Stephen C. Johnson at AT&T for the Unix operating system. The name is an acronym for "Yet Another Compiler Compiler." It generates a parser based on an analytic grammar written in a notation similar to BNF.Yacc used to be available as...

 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
Preprocessor
In computer science, a preprocessor is a program that processes its input data to produce output that is used as input to another program. The output is said to be a preprocessed form of the input data, which is often used by some subsequent programs like compilers...

 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
Mike Lesk
Michael E. Lesk is a computer programmer.In the 1960s, Michael Lesk worked for the SMART Information Retrieval System project, wrote much of its retrieval code and did many of the retrieval experiments, as well as obtaining a PhD in Chemical Physics....

 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
AberMUD
AberMUD, pronounced , was the first popular open source MUD, named after the town in which it was written, Aberystwyth. The first version was written in B by Alan Cox, Richard Acott, Jim Finnis, and Leon Thrane based at University of Wales, Aberystwyth for an old Honeywell mainframe and opened in...

 was originally written in B.

B was greatly influenced by BCPL, and its name is most likely to be a contraction of BCPL. However 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
Multics
Multics was an influential early time-sharing operating system. The project was started in 1964 in Cambridge, Massachusetts...

.

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) {
extern putchar;
auto a;

if(a=n/b) /* assignment, not test for equality */
printn(a, b); /* recursive */
putchar(n%b + '0');
}

External links

  • Manual page for b(1) from Unix First Edition
  • The Development of the C Language, Dennis M. Ritchie
    Dennis Ritchie
    Dennis MacAlistair Ritchie , was an American computer scientist who "helped shape the digital era." He created the C programming language and, with long-time colleague Ken Thompson, the UNIX operating system...

    . Puts B in the context of BCPL
    BCPL
    BCPL is a procedural, imperative, and structured computer programming language designed by Martin Richards of the University of Cambridge in 1966.- Design :...

     and C
    C (programming language)
    C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

    .
  • Users' Reference to B, Ken Thompson. Describes the PDP-11
    PDP-11
    The PDP-11 was a series of 16-bit minicomputers sold by Digital Equipment Corporation from 1970 into the 1990s, one of a succession of products in the PDP series. The PDP-11 replaced the PDP-8 in many real-time applications, although both product lines lived in parallel for more than 10 years...

     version.
  • The Programming Language B, S. C. Johnson & B. W. Kernighan, Technical Report CS TR 8, Bell Labs
    Bell Labs
    Bell Laboratories is the research and development subsidiary of the French-owned Alcatel-Lucent and previously of the American Telephone & Telegraph Company , half-owned through its Western Electric manufacturing subsidiary.Bell Laboratories operates its...

     (January 1973). The GCOS
    General Comprehensive Operating System
    General Comprehensive Operating System is a family of operating systems oriented toward mainframe computers.The original version of GCOS was developed by General Electric from 1962; originally called GECOS...

     version on Honeywell
    Honeywell
    Honeywell International, Inc. is a major conglomerate company that produces a variety of consumer products, engineering services, and aerospace systems for a wide variety of customers, from private consumers to major corporations and governments....

    equipment.
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK