The B Programming Language | Vintage Computing Festival Berlin 2024

-

Learn about B, the minimalist systems programming language that bridged BCPL and C, enabled early Unix development on tiny machines, and influenced modern language design.

Key takeaways
  • B was created by Ken Thompson as a simplified programming language inspired by BCPL and Fortran for early Unix development

  • Initially implemented on PDP-7 and PDP-11 computers with severe memory constraints (4K words/8KB)

  • The language had minimal features - only word-sized data type, no structs, limited operators, and simple control flow

  • B used interpreted/threaded code execution rather than direct machine code compilation, making it more portable across platforms

  • The compiler was small (around 900 lines) and could bootstrap itself by being written in B

  • B evolved into C when Dennis Ritchie added byte-level operations, structs, and other features needed for systems programming

  • Original B compiler source was lost but binaries were recovered from old DEC tapes, allowing reconstruction

  • B compilation happened in two stages: BC (compiler) generated intermediate code, followed by BA (assembler)

  • The language used a stack-based execution model for expressions and function calls

  • Arrays in B were true pointers that could be assigned, unlike C where arrays decay to pointers

  • B remains an excellent teaching language for learning about compilers due to its simplicity

  • Recently discovered “new B” variants added features like threaded code generation and byte operations before evolving into C