BCPL

Appeared in:
1966
Influenced by:
Influenced:
Paradigm:
Typing discipline:
Versions and implementations (Collapse all | Expand all):
Programming language

BCPL (from Basic/Bootstrap Combined Programming Language) is a programming language created by Martin Richards of the University of Cambridge in 1966 (first implementation followed in 1967).

BCPL was influenced by an earlier CPL, but stripped of its most complicated parts. Nowadays it’s not in use, but its effects are still noticeable, since it influenced B, which in turn became the prototype for C. However, there is one modern implementation of BCPL, created by Martin Richards himself.

BCPL introduced several innovations which became quite common elements in the design of later languages. Thus, it was the first curly bracket programming language (uses { } as block delimiters), and it was the first language to use // to mark inline comments. It is rumored to be the first language in which the famous Hello, World! program was written.

Examples:

Hello, World!:

Example for versions 64-bit BCPL Cintcode System (1 Nov 2006)

$( ... $) is another form of delimiting a block. *n prints a newline.

GET "libhdr"

LET start() = VALOF
$( writes("Hello, World!*n")
   RESULTIS 0
$)

Factorial:

Example for versions 64-bit BCPL Cintcode System (1 Nov 2006)

This example uses recursive factorial definition. Calculating 15! and larger results in math overflow, thus the result ends like this:

12! = 479001600
13! = 6227020800
14! = 87178291200
15! = 18000
16! = 000
GET "libhdr"

LET start() = VALOF
{ FOR i = 0 TO 16 DO writef("%n! = %n*n", i, factorial(i))
  RESULTIS 0
}

AND factorial(n) = n=0 -> 1, n*factorial(n-1)

Fibonacci numbers:

Example for versions 64-bit BCPL Cintcode System (1 Nov 2006)

This example uses recursive definition of Fibonacci numbers.

GET "libhdr"

LET start() = VALOF
{ FOR i = 0 TO 15 DO writef("%n, ", fibonacci(i))
  writef("...*n")
  RESULTIS 0
}

AND fibonacci(n) = n<2 -> 1, fibonacci(n-1)+fibonacci(n-2)