“C” Programming Language: Brian Kernighan – Computerphile


There’s a book just over your shoulder that’s carefully been placed there, can you pick the book up and tell me about it? Right! Great book, you should
buy the newer version of this. Brief commercial announcement yeah sure I think I mentioned at some point in our conversation the fact that the people
working on MULTICS, well MULTICS was sort of the second version of timesharing that was
done at MIT with collaboration of Bell Labs and General Electric very big system for providing in effect a computing
utility for programmers. Multex was actually being written in high-level languages ah they started with PL1 which was not a good choice and then
they moved to BCPL language which developed in fact by
Martin Richards of Cambridge. The people doing that who are at Bell Labs in
particular Ken Thompson and Dennis Ritchie had gotten used to the idea that
you could write really interesting operating system kind of software and
tools that supported it in high-level languages so you weren’t writing
assembly language and so when they started working on UNIX this very small
stripped-down version that was done at Bell Labs they were at the same time
exploring the use of high-level languages and there were a variety of
these there was a language called B which was the first attempt it was done
by Ken Thompson a very simple language and I suppose you could say it was sort
of like a stripped down version of BCPL A weak naming convention there and
so you could do interesting things with B but it wasn’t quite powerful enough
and in particular it was an interpreter not a compiler and that meant it didn’t
generate machine code for the particular machine was running on it was just a
program that interpreted what it was trying to say
so it meant it ran relatively slowly. The other thing is that the language did not support the architecture of newer machines that were showing up in
particular that PDP 11 newer machines instead of having everything in the
machine be a single size of in effect integer let’s say 16 bits or something like that they had different sizes that were, the machine would efficiently and naturally
manipulate 8bit, 16bit maybe thirty two-bit & the language B didn’t reflect
that and so Dennis Ritchie undertook to design what amounted to a version of
B that was richer and had mechanisms in the language to say this is an 8-bit
quantity this is a 16 bit quantity basically the char and int types that you see in the early versions of C and so he wrote a compiler for that and then with the
compiler in hand they started to rewrite the operating system itself in C
and this took a while but something in the order of six months to get that working
and at that point then you’ve got the operating system of course all kinds of
other critical core software written in a high-level language rather than in
assembly language and that’s important for all kinds of reasons one is means
that it’s just a lot easier for lots of people to see what the code does you
need so much expertise because it’s a high-level language and the other thing
is that it’s portable in the sense that if somebody makes a C compiler for a
different kind of machine different architecture then you can recompile
whatever your program is for that new architecture in that way you can move your program to a
different machine of this always been the advantage of high-level languages
but now you could do it for the operating system and that meant that UNIX, the
operating system no longer was only PDP 11 but could run on a variety of other
machines as well I think the concept of having a high-level language Iget right, you compile it down to hexes, machine code that tells the processors to do stuff. and if you have a different compiler for a different machine it just changes what those Hexes are -right that’s exactly right so so it should be really simple to understand how you write an OS in a high level language, but is it a bit like, making a sharp tool and using that sharp tool to make a sharper tool? Yeah, right, I think in fact, the complication is in building in writing
of operating system and high-level language in translating it into let’s
say multiple different architectures is there’s a lot of detail to get right
there in there are some things which the high-level language just doesn’t support
So you need a little tiny bit of assembly language assist for any given operating
system the one that’s more like that the conceptual problem that you were
explaining well is how does the compiler itself get started because of course the
C compiler is written in C so there is the how do you get it started and your idea
of the sharper tool making yet a sharper tool and so on is metaphorically the right idea because
what you do is you say I wrote some code in C on paper let me mechanically
translate that into something that will process a bit more of C code and
bootstrap myself up from that so it’s a bootstrapping process and I’ve never
done it so take me with a grain of salt on that but that’s the basic idea so. – OK, so tell me about this book, how did this come about? that’s the first edition (is it autographed?) this one isn’t actually no dear oh dear this however is the 24th printing so. (I’ll just point out that Prof Brailsford brought in a pen for the autograph there.) OK I will autograph it… somewhere early on in this process of
people building interesting languages I got intrigued by the idea of how do you
explain those languages to other people and so I wrote tutorial documents I wrote a tutorial document on B so that people could learn B because Ken Thompson
and to a lesser degree Dennis didn’t write tremendous amount of documentation
let’s say it was a spare and there was not much tutorial stuff so I wrote a
tutorial document on B that was useful when C came along then I wrote a
tutorial document on C and at some point I had already written I guess couple
books at that point and it seemed like the market, the market!? That there might
be a market for a C book and so I twisted Dennis Ritchies arm into
writing the book with me and that is the smartest thing I ever did in my whole
life no ambiguity so we took my tutorial document as kind of a piece of it, we
took his reference manual which is a excellent reference manual as a big
piece of it took that verbatim and then we filled in material in the middle to explain the various parts of the language at length, and we published that, we wrote it in 1977
published at the beginning of 78 and of course it was done with all of the
document preparation tools that we had been working on over the years and so it
had mathematical expressions in it using EQN
it had tables of things like operators using Mike Lesk’s TBL program
it the first edition predates pic the
picture drawing language the second edition has pic pictures so on so is
this incestuous or is this building on what people have done I don’t know but
that’s how it came about and I remember talking to the editor this is published
by Prentice Hall with Karl Karlstrom the editor there and I remember discussion
with him about how many copies do you think this will sell no idea well maybe
five thousand done better than that which is just as well there never an A because B was based on? There was a language Steve
Johnson who was all part of this the creator of Yacc, Steve Johnson spent a sabbatical
at University of Waterloo in Ontario and he came back with a link I don’t
somebody else had done that the language they’re called “A” but it was spelled “EH”
– Bit of Canadian humor I guess…

Leave a Reply

Your email address will not be published. Required fields are marked *