B (programming language)

From Wikipedia for FEVERv2
Jump to navigation Jump to search

This article is about a language developed at Bell Labs. B (programming language)_sentence_0

For "b" language of Meertens and Pemberton, see ABC (programming language). B (programming language)_sentence_1

For other uses, see B (disambiguation). B (programming language)_sentence_2

B (programming language)_table_infobox_0

BB (programming language)_table_caption_0
Designed byB (programming language)_header_cell_0_0_0 Ken ThompsonB (programming language)_cell_0_0_1
DeveloperB (programming language)_header_cell_0_1_0 Ken Thompson, Dennis RitchieB (programming language)_cell_0_1_1
First appearedB (programming language)_header_cell_0_2_0 1969; 51 years ago (1969)B (programming language)_cell_0_2_1
Typing disciplineB (programming language)_header_cell_0_3_0 typeless (everything is a word)B (programming language)_cell_0_3_1
B (programming language)_header_cell_0_4_0 .bB (programming language)_cell_0_4_1
Influenced byB (programming language)_header_cell_0_5_0
InfluencedB (programming language)_header_cell_0_6_0

B is a programming language developed at Bell Labs circa 1969. B (programming language)_sentence_3

It is the work of Ken Thompson with Dennis Ritchie. B (programming language)_sentence_4

B was derived from BCPL, and its name may be a contraction of BCPL. B (programming language)_sentence_5

Thompson's coworker Dennis Ritchie speculated that the name might be based on Bon, an earlier, but unrelated, programming language that Thompson designed for use on Multics. B (programming language)_sentence_6

B was designed for recursive, non-numeric, machine-independent applications, such as system and language software. B (programming language)_sentence_7

It was a typeless language, with the only data type being the underlying machine's natural memory word format, whatever that might be. B (programming language)_sentence_8

Depending on the context, the word was treated either as an integer or a memory address. B (programming language)_sentence_9

As machines with ASCII processing became common, notably the DEC PDP-11 that arrived at Bell, support for character data stuffed in memory words became important. B (programming language)_sentence_10

The typeless nature of the language was seen as a disadvantage, which led Thompson and Ritchie to develop an expanded version of the language supporting new internal and user-defined types, which became the C programming language. B (programming language)_sentence_11

History B (programming language)_section_0

Circa 1969, Ken Thompson and later Dennis Ritchie developed B basing it mainly on the BCPL language Thompson used in the Multics project. B (programming language)_sentence_12

B was essentially the BCPL system stripped of any component Thompson felt he could do without in order to make it fit within the memory capacity of the minicomputers of the time. B (programming language)_sentence_13

The BCPL to B transition also included changes made to suit Thompson's preferences (mostly along the lines of reducing the number of non-whitespace characters in a typical program). B (programming language)_sentence_14

Much of the typical ALGOL-like syntax of BCPL was rather heavily changed in this process. B (programming language)_sentence_15

The assignment operator := changed to = and the equality operator = was replaced by ==. B (programming language)_sentence_16

Thompson added "two-address assignment operators" using x =+ y syntax to add y to x (in C the operator is written +=). B (programming language)_sentence_17

This syntax came from Douglas McIlroy's implementation of TMG, in which B's compiler was first implemented (and it came to TMG from ALGOL 68's x +:= y syntax). B (programming language)_sentence_18

Thompson went further by inventing the increment and decrement operators (++ and --). B (programming language)_sentence_19

Their prefix or postfix position determines whether the value is taken before or after alteration of the operand. B (programming language)_sentence_20

This innovation was not in the earliest versions of B. B (programming language)_sentence_21

According to Dennis Ritchie, people often assumed that they were created for the auto-increment and auto-decrement address modes of the DEC PDP-11, but this is historically impossible as the machine didn't exist when B was first developed. B (programming language)_sentence_22

The semicolon version of the for loop was borrowed by Ken Thompson from the work of Stephen Johnson. B (programming language)_sentence_23

B is typeless, or more precisely has one data type: the computer word. B (programming language)_sentence_24

Most operators (e.g. +, -, *, /) treated this as an integer, but others treated it as a memory address to be dereferenced. B (programming language)_sentence_25

In many other ways it looked a lot like an early version of C. There are a few library functions, including some that vaguely resemble functions from the standard I/O library in C. In Thompson's words: "B and the old old C were very very similar languages except for all the types [in C]". B (programming language)_sentence_26

Early implementations were for the DEC PDP-7 and PDP-11 minicomputers using early Unix, and Honeywell GE 645 36-bit mainframes running the operating system GCOS. B (programming language)_sentence_27

The earliest PDP-7 implementations compiled to threaded code, and Ritchie wrote a compiler using TMG which produced machine code. B (programming language)_sentence_28

In 1970 a PDP-11 was acquired and threaded code was used for the port; an assembler, dc, and the B language itself were written in B to bootstrap the computer. B (programming language)_sentence_29

An early version of yacc was produced with this PDP-11 configuration. B (programming language)_sentence_30

Ritchie took over maintenance during this period. B (programming language)_sentence_31

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. B (programming language)_sentence_32

Starting in 1971 Ritchie made changes to the language while converting its compiler to produce machine code, most notably adding data typing for variables. B (programming language)_sentence_33

During 1971 and 1972 B evolved into "New B" (NB) and then C. B (programming language)_sentence_34

B is almost extinct, having been superseded by the C language. B (programming language)_sentence_35

However, it continues to see use on GCOS mainframes (as of 2014) and on certain embedded systems (as of 2000) for a variety of reasons: limited hardware in small systems, extensive libraries, tooling, licensing cost issues, and simply being good enough for the job. B (programming language)_sentence_36

The highly influential AberMUD was originally written in B. B (programming language)_sentence_37

Examples B (programming language)_section_1

The following examples are from the Users' Reference to B by Ken Thompson: B (programming language)_sentence_38

See also B (programming language)_section_2

Computer programming portal B (programming language)_sentence_39


Credits to the contents of this page go to the authors of the corresponding Wikipedia page: en.wikipedia.org/wiki/B (programming language).