Concepts of Programming Languages

(Sean Pound) #1
{ Compute the average }
average := sum / listlen;
{ Count the number of input values that are > average }
for counter := 1 to listlen do
if (intlist[counter] > average) then
result := result + 1;
{ Print the result }
writeln ('The number of values > average is:',
result)
end { of the then clause of if (( listlen > 0 ... }
else
writeln ('Error—input list length is not legal')
end.

2.12.2 A Portable Systems Language: C


Like Pascal, C contributed little to the previously known collection of language
features, but it has been widely used over a long period of time. Although origi-
nally designed for systems programming, C is well suited for a wide variety of
applications.

2.12.2.1 Historical Background
C’s ancestors include CPL, BCPL, B, and ALGOL 68. CPL was developed at
Cambridge University in the early 1960s. BCPL is a simple systems language,
also developed at Cambridge, this time by Martin Richards in 1967 (Richards,
1969).
The first work on the UNIX operating system was done in the late 1960s by
Ken Thompson at Bell Laboratories. The first version was written in assembly
language. The first high-level language implemented under UNIX was B, which
was based on BCPL. B was designed and implemented by Thompson in 1970.
Neither BCPL nor B is a typed language, which is an oddity among
high-level languages, although both are much lower-level than a language
such as Java. Being untyped means that all data are considered machine
words, which, although simple, leads to many complications and insecuri-
ties. For example, there is the problem of specifying floating-point rather
than integer arithmetic in an expression. In one implementation of BCPL,
the variable operands of a floating-point operation were preceded by peri-
ods. Variable operands not preceded by periods were considered to be inte-
gers. An alternative to this would have been to use different symbols for the
floating-point operators.
This problem, along with several others, led to the development of a
new typed language based on B. Originally called NB but later named C,
it was designed and implemented by Dennis Ritchie at Bell Laboratories in
1972 (Kernighan and Ritchie, 1978). In some cases through BCPL, and in
other cases directly, C was influenced by ALGOL 68. This is seen in its for

2.12 Some Early Descendants of the ALGOLs 77
Free download pdf