back to index

C Programming Language | Brian Kernighan and Lex Fridman


Whisper Transcript | Transcript Only Page

00:00:00.000 | - So what's to you, so you wrote a book,
00:00:04.680 | C Programming Language, and C is probably
00:00:07.640 | one of the most important languages
00:00:10.520 | in the history of programming languages,
00:00:12.440 | if you kind of look at impact.
00:00:14.680 | What do you think is the most elegant
00:00:16.560 | or powerful part of C?
00:00:19.840 | Why did it survive?
00:00:21.180 | Why did it have such a long-lasting impact?
00:00:23.960 | - I think it found a sweet spot of expressiveness.
00:00:29.920 | So you could rewrite things in a pretty natural way,
00:00:32.680 | and efficiency, which was particularly important
00:00:35.800 | when computers were not nearly as powerful
00:00:37.960 | as they are today.
00:00:38.800 | You've got to put yourself back 50 years,
00:00:41.580 | almost in terms of what computers could do,
00:00:44.840 | and that's roughly four or five generations,
00:00:48.640 | decades of Moore's law, right?
00:00:50.240 | So expressiveness and efficiency,
00:00:54.480 | and I don't know, perhaps the environment
00:00:57.500 | that it came with as well, which was Unix.
00:00:59.960 | So it meant if you wrote a program,
00:01:01.480 | it could be used on all those computers that ran Unix,
00:01:04.120 | and that was all of those computers,
00:01:05.560 | because they were all written in C,
00:01:07.000 | and that way, Unix, the operating system itself,
00:01:10.120 | was portable, as were all the tools.
00:01:12.240 | So it all worked together, again,
00:01:14.280 | in one of these things where things fed on each other
00:01:17.260 | in a positive cycle.
00:01:19.520 | - What did it take to write sort of a definitive book,
00:01:23.600 | probably definitive book on all of programming,
00:01:25.560 | like it's more definitive to a particular language
00:01:28.080 | than any other book on any other language,
00:01:30.240 | and did two really powerful things,
00:01:32.600 | which is popularized the language,
00:01:36.320 | at least from my perspective, maybe you can correct me,
00:01:38.480 | and second is created a standard of how,
00:01:43.000 | how this language is supposed to be used and applied.
00:01:47.240 | So what did it take?
00:01:48.560 | Did you have those kinds of ambitions in mind
00:01:51.000 | when working on that?
00:01:51.840 | - Is this some kind of joke?
00:01:53.200 | (laughing)
00:01:55.000 | No, of course not.
00:01:56.440 | So it's an accident of timing, skill, and just luck.
00:02:01.440 | - A lot of it is, clearly, timing was good.
00:02:05.120 | Now, Dennis and I wrote the book in 1977.
00:02:07.720 | - Dennis Ritchie.
00:02:08.560 | - Yeah, right.
00:02:10.040 | And at that point, Unix was starting to spread.
00:02:12.520 | I don't know how many there were,
00:02:13.640 | but it would be dozens to hundreds of Unix systems,
00:02:16.920 | and C was also available on other kinds of computers
00:02:20.280 | that had nothing to do with Unix,
00:02:21.920 | and so the language had some potential.
00:02:26.040 | And there were no other books on C,
00:02:31.040 | and Bell Labs was really the only source for it,
00:02:33.960 | and Dennis, of course, was authoritative
00:02:36.160 | because it was his language,
00:02:37.520 | and he had written the reference manual,
00:02:40.360 | which is a marvelous example
00:02:41.640 | of how to write a reference manual.
00:02:43.080 | Really, really, very, very well done.
00:02:45.080 | So I twisted his arm until he agreed to write a book,
00:02:47.840 | and then we wrote a book.
00:02:49.040 | And the virtue, or advantage, at least,
00:02:52.160 | I guess, of going first is that then other people
00:02:54.440 | have to follow you if they're gonna do anything.
00:02:56.880 | And I think it worked well
00:03:00.400 | because Dennis was a superb writer.
00:03:04.000 | I mean, he really, really did.
00:03:05.200 | And the reference manual in that book is his, period.
00:03:08.680 | I had nothing to do with that at all.
00:03:10.880 | So just crystal clear prose, very, very well expressed.
00:03:16.320 | And then he and I, I wrote most of the expository material,
00:03:21.320 | and then he and I sort of did the usual ping-ponging
00:03:23.920 | back and forth, refining it.
00:03:27.040 | But I spent a lot of time trying to find examples
00:03:29.200 | that would sort of hang together
00:03:30.440 | and that would tell people what they might need to know
00:03:32.560 | at about the right time
00:03:33.800 | that they should be thinking about needing it.
00:03:36.120 | And I'm not sure it completely succeeded,
00:03:39.160 | but it mostly worked out fairly well.
00:03:42.160 | - What do you think is the power of example?
00:03:43.760 | I mean, you're the creator,
00:03:47.880 | at least one of the first people
00:03:49.600 | to do the Hello World program,
00:03:52.000 | just like the example.
00:03:54.040 | If aliens discover our civilization
00:03:56.680 | hundreds of years from now,
00:03:57.800 | it'll probably be Hello World programs,
00:04:00.440 | just like a half-broken robot communicating with them
00:04:03.200 | with a Hello World.
00:04:04.400 | So what, and that's a representative example.
00:04:07.040 | So what do you find powerful about examples?
00:04:10.680 | - I think a good example will tell you how to do something,
00:04:15.160 | and it will be representative of,
00:04:17.480 | you might not want to do exactly that,
00:04:19.320 | but you will want to do something
00:04:20.560 | that's at least in that same general vein.
00:04:23.320 | And so a lot of the examples in the C book
00:04:27.000 | were picked for these very, very simple,
00:04:29.320 | straightforward text processing problems
00:04:31.280 | that were typical of Unix.
00:04:33.320 | I want to read input and write it out again.
00:04:37.200 | There's a copy command.
00:04:38.200 | I want to read input and do something to it
00:04:40.640 | and write it out again.
00:04:41.600 | There's a grab.
00:04:42.440 | And so that kind of find things
00:04:44.960 | that are representative of what people want to do
00:04:48.600 | and spell those out
00:04:50.240 | so that they can then take those
00:04:53.000 | and see the core parts and modify them to their taste.
00:04:58.000 | And I think that a lot of programming books that I,
00:05:03.120 | I don't look at programming books
00:05:04.760 | a tremendous amount these days,
00:05:05.920 | but when I do, a lot of them don't do that.
00:05:08.080 | They don't give you examples that are both realistic
00:05:12.640 | and something you might want to do.
00:05:15.480 | Some of them are pure syntax.
00:05:17.320 | Here's how you add three numbers.
00:05:18.920 | Well, come on, I could figure that out.
00:05:20.880 | Tell me how I would get those three numbers
00:05:22.800 | into the computer
00:05:23.720 | and how we would do something useful with them.
00:05:26.000 | And then how I put them back out again, neatly formatted.
00:05:29.160 | - And especially if you follow that example,
00:05:30.760 | there is something magical of doing something
00:05:33.040 | that feels useful.
00:05:34.600 | - Yeah, right.
00:05:35.440 | And I think it's the attempt,
00:05:37.160 | and it's absolutely not perfect,
00:05:39.960 | but the attempt in all cases was to get something
00:05:42.360 | that was going to be either directly useful
00:05:45.160 | or would be very representative of useful things
00:05:49.160 | that a programmer might want to do.
00:05:51.520 | But within that vein of fundamentally text processing,
00:05:54.680 | reading text, doing something, writing text.
00:05:57.240 | (laughs)
00:05:59.320 | (upbeat music)
00:06:01.920 | (upbeat music)
00:06:04.520 | (upbeat music)
00:06:07.120 | (upbeat music)
00:06:09.720 | (upbeat music)
00:06:12.320 | (upbeat music)