ArticleslgStudy

science

B (programming language)

B (programming language) is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand B (programming language) rather than just read about it. In short: B is a programming language developed at Bell Labs circa 1969 by Ken Thompson and Dennis Ritchie. B was designed for recursive, non-numeric, machine-independent applications, such as system and language software.

Key takeaways

  • B (programming language) belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect B (programming language) to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of B (programming language) from memory before moving on to harder problems.

Reference excerpt

B is a programming language developed at Bell Labs circa 1969 by Ken Thompson and Dennis Ritchie. B was designed for recursive, non-numeric, machine-independent applications, such as system and language software. It was a typeless language, with the only data type being the underlying machine's natural memory word format, whatever that might be. Depending on the context, the word was treated either as an integer or a memory address. As machines with ASCII processing became common, notably the DEC PDP-11 that arrived at Bell Labs, support for character data stuffed in memory words became important. 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 ubiquitous C programming language.

History

Ken Thompson began developing B as a Fortran compiler for the PDP-7, but found that his initial implementation far exceeded available memory. Through several iterations of simplifying the compiler and adapting the language to his own tastes that were influenced by BCPL, he arrived at a language that expressed a subset of BCPL semantics in a distinct syntax. Thompson named the language B, which has been variously explained as an abbreviation of BCPL or Bon, another language he had developed, although he confirmed neither explanation. Thompson added "two-address assignment operators" using x =+ y syntax to add y to x (in C the operator is written +=). 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). Thompson went further by inventing the increment and decrement operators (++ and --). Their prefix or postfix position determines whether the value is taken before or after alteration of the operand. This innovation was not in the earliest versions of B. 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 is typeless, or more precisely has one data type: 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. It included a generalized for loop as later appeared in C, which Thompson adapted from earlier work by Stephen Johnson. 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]". 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. The earliest PDP-7 implementations compiled to threaded code, and Ritchie wrote a compiler using TMG which produced machine code. 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. 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" (NB) and then C. B is almost extinct, having been superseded by the C language. 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. The highly influential AberMUD was originally written in B.

Examples The following examples are from the Users' Reference to B by Ken Thompson:

References

External links Manual page for b(1) from Unix First Edition The Development of the C Language, Dennis M. Ritchie. Puts B in the context of BCPL and C. Users' Reference to B, Ken Thompson. Describes the PDP-11 version. The Programming Language B, S. C. Johnson & B. W. Kernighan, Technical Report CS TR 8, Bell Labs (January 1973). The GCOS version on Honeywell equipment. B Language Reference Manual, Thinkage Ltd. The production version of the language as used on GCOS, including language and runtime library.

Worked examples

Example 1 — a first encounter with B (programming language)

Start with the simplest possible case. Write down what B (programming language) claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to B (programming language) before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about B (programming language) ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of B (programming language)

In research
B (programming language) appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses B (programming language) in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
B (programming language) is common in secondary-school and first-year university syllabi. It links to neighbouring topics Procedural programming languages, Programming languages, Programming languages created in 1969, so understanding it makes those chapters shorter.
In everyday life
Look for B (programming language) outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “B (programming language)” →

How to study B (programming language) in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what B (programming language) means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain B (programming language) out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is B (programming language) in simple terms?

B is a programming language developed at Bell Labs circa 1969 by Ken Thompson and Dennis Ritchie. B was designed for recursive, non-numeric, machine-independent applications, such as system and language software.

Why does B (programming language) matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study B (programming language)?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on B (programming language).

Tags

  • Procedural programming languages
  • Programming languages
  • Programming languages created in 1969

Keep exploring