Sunday, December 12, 2010

www.worldcomputereducation.com                                   Development of C
Ritchie

By 1971, our miniature computer center was beginning to have users. We all wanted to create
interesting software more easily. Using assembler was dreary enough that B, despite its performance
problems, had been supplemented by a small library of useful service routines and was
being used for more and more new programs. Among the more notable results of this period was
Steve Johnson’s first version of the
[Johnson 79a].
yacc parsergenerator
The Problems of B
The machines on which we first used BCPL and then B were wordaddressed,
and these languages’
single data type, the ‘cell,’ comfortably equated with the hardware machine word. The
advent of the PDP11
exposed several inadequacies of B’s semantic model. First, its characterhandling
mechanisms, inherited with few changes from BCPL, were clumsy: using library procedures
to spread packed strings into individual cells and then repack, or to access and replace individual
characters, began to feel awkward, even silly, on a byteoriented
machine.
Second, although the original PDP11
did not provide for floatingpoint
arithmetic, the
manufacturer promised that it would soon be available. Floatingpoint
operations had been added
to BCPL in our Multics and GCOS compilers by defining special operators, but the mechanism
was possible only because on the relevant machines, a single word was large enough to contain a
floatingpoint
number; this was not true on the 16bit
PDP11.
Finally, the B and BCPL model implied overhead in dealing with pointers: the language
rules, by defining a pointer as an index in an array of words, forced pointers to be represented as
word indices. Each pointer reference generated a runtime
scale conversion from the pointer to
the byte address expected by the hardware.
For all these reasons, it seemed that a typing scheme was necessary to cope with characters
and byte addressing, and to prepare for the coming floatingpoint
hardware. Other issues, particularly
type safety and interface checking, did not seem as important then as they became later.
Aside from the problems with the language itself, the B compiler’s threadedcode
technique
yielded programs so much slower than their assemblylanguage
counterparts that we discounted
the possibility of recoding the operating system or its central utilities in B.
In 1971 I began to extend the B language by adding a character type and also rewrote its
compiler to generate PDP11
machine instructions instead of threaded code. Thus the transition
from B to C was contemporaneous with the creation of a compiler capable of producing programs
fast and small enough to compete with assembly language. I called the slightlyextended
language
NB, for ‘new B.’
Embryonic C
NB existed so briefly that no full description of it was written. It supplied the types
int
and
char, arrays of them, and pointers to them, declared in a style typified by
int i, j;
char c, d;
int iarray[10];
int ipointer[];
char carray[10];
char cpointer[];
The semantics of arrays remained exactly as in B and BCPL: the declarations of
iarray and
carray
integers and characters respectively. The declarations for
size, to assert that no storage should be allocated automatically. Within procedures, the
language’s interpretation of the pointers was identical to that of the array variables: a pointer declaration
created a cell differing from an array declaration only in that the programmer was
expected to assign a referent, instead of letting the compiler allocate the space and initialize the
cell.
Values stored in the cells bound to array and pointer names were the machine addresses,
create cells dynamically initialized with a value pointing to the first of a sequence of 10ipointer and cpointer omit the

No comments:

Post a Comment

THE WORLD NEW TECHNOLOGY