Lex Fridman PodcastDonald Knuth: Programming, Algorithms, Hard Problems & the Game of Life | Lex Fridman Podcast #219
EVERY SPOKEN WORD
150 min read · 30,187 words- 0:00 – 0:48
Introduction
- LFLex Fridman
The following is a conversation with Donald Knuth, his second time on this podcast. Don is a legendary computer scientist, Turing Award winner, father of algorithm analysis, author of The Art of Computer Programming, creator of TeX that led to LaTeX, and one of the kindest and most fascinating human beings I've ever got a chance to talk to. I wrote him a letter a long time ago. He responded, and the rest, as they say, is history. We've interacted many times since then and every time has been joyful and inspiring. To support this podcast, please check out our sponsors in the description. This is the Lex Fridman Podcast, and here is my conversation with Donald Knuth.
- 0:48 – 24:11
First programs
- LFLex Fridman
Your first large-scale program, you wrote it in IBM 650 Assembler in the summer of 1957.
- DKDonald Knuth
I wrote it in decimal machine language. I didn't know about Assembler until a year later.
- LFLex Fridman
But the year 1957-
- DKDonald Knuth
The year, it was, it was-
- LFLex Fridman
... and the program is tic-tac-toe.
- DKDonald Knuth
Y- yeah. I might have learned about A- Assembler later that summer. Yeah, I probably did. In 1957, hardly anybody had heard of assemblers. You looked at the user manuals, (laughs) "H- h- how do you write a program for this machine?" It would, it, it would, it would say, um, uh, y- y- y- you know, you would say 69 which meant load the distributor and, and then you would give the address of, of the number you wanted to load into the distributor.
- LFLex Fridman
Mm-hmm.
- DKDonald Knuth
Uh, yesterday, uh, my friend at, uh, Doug Spicer at the Computer History Museum sent me a link to something that just went on YouTube. It was IBM's, uh, progress report from 1956 which was, you know, very contemporary with 1957. (laughs)
- LFLex Fridman
(laughs) Yes.
- DKDonald Knuth
Um, and in 1956, IBM had donated to Stanford University an IBM 650, one of the first ones. When they showed a picture of the assembly line for IBM 650s and they said, you know, "This is number 500 or something coming off the assembly line." And-
- LFLex Fridman
Mm-hmm.
- DKDonald Knuth
... and I had never seen so many (laughs) IBM 650s ex- I did in this movie that was, uh, it's on YouTube now.
- LFLex Fridman
Mm-hmm.
- DKDonald Knuth
Um, and, and it showed the picture from Stanford, uh, that, that's, m- m- you know, they, they, they said, you know, "We, we donated one of these to Stanford, one to MIT," and they mentioned one other, oh, oh, one other college. And in, in December of '56, they donated to, to my university, Case Tech.
- LFLex Fridman
Mm-hmm.
- DKDonald Knuth
Um, but anyway, they showed a picture then, uh, of a class session, uh, where a guy was teaching programming and on the blackboard, it said, "69 8,000." I mean, he-
- LFLex Fridman
Mm-hmm.
- DKDonald Knuth
... he, he, it, it was, uh, the, he was teaching them how to write, uh, code for this IBM 650 which was in decimal numbers. So, so, so the instructions were 10 di- 10 decimal digits. You had, you had two digits that said what, wh- wh- what to do-
- LFLex Fridman
Mm-hmm.
- DKDonald Knuth
... four digits to say, uh, uh, what to do it to (laughs) -
- LFLex Fridman
(laughs)
- DKDonald Knuth
... and four more digits to say where to get your next instruction.
- LFLex Fridman
And there's a manual that describes what each of the numbers mean?
- DKDonald Knuth
And the manual was actually what, uh, if the manual had been well written, I probably never would have gone into computer science. But it was so badly written, I figured, uh, that I must have a talent for it because I'm only a freshman and I c- and I could write a better manual.
- LFLex Fridman
(laughs)
- DKDonald Knuth
Uh, and, and-
- LFLex Fridman
That's what you did.
- DKDonald Knuth
... a- a- and so I, I, I started working at the computer center, um, uh, and, and, uh, wrote some manuals then. But, but, (laughs) yeah, but, but this was, uh, uh, but this was the way we did it. And, and my first program then was June of, uh, 1957.
- LFLex Fridman
The tic-tac-toe. That-
- DKDonald Knuth
No. That was the second program. The first, this, the third pro- the, the first program was factoring a, a number.
- 24:11 – 27:20
Literate programming
- LFLex Fridman
Bach, if somebody looked at Don Knuth code, would they be able to tell that this, uh, is a distinct style of thinking going on here?
- DKDonald Knuth
Huh.
- LFLex Fridman
What do you think?
- DKDonald Knuth
Uh ...
- LFLex Fridman
(laughs) And what, what would be the defining-
- DKDonald Knuth
I, I, yeah, uh-
- LFLex Fridman
... uh, characteristic of the style?
- DKDonald Knuth
Well, uh, uh, my code now is, uh, it, it, it is literate programming so I'm, it's a combination of English and C mostly. (laughs) But, but, but e- if you just looked at the C part of it, you would also probably notice that I don't, y- uh, that it, you can't, you know, that I use a lot of global variables that other people don't and, and, and I, and I expand things inline more than in- instead of calling ... anyway, I, I have different subset of C that I use. Um-
- LFLex Fridman
Okay. But that's, that's a little bit stylistic, uh-
- DKDonald Knuth
Yeah. But, but with literate programming, you alternate between English and, and, and, and C or whatever, or, yeah, yeah, yeah. And, um-
- LFLex Fridman
And by the way, people listening to this should look up literate programming. It's very interesting, uh, concept that you, uh, that you proposed and developed over the years.
- DKDonald Knuth
Yeah. Yeah. The ... I, I'm s- that, that's the most, uh, significant thing f- I think to come out of the TeX project is the pro- is, is that I-
- LFLex Fridman
Mm-hmm.
- DKDonald Knuth
... uh, uh, I, I realized that, uh, um, my programs w- were to be read by people and not-
- LFLex Fridman
(laughs)
- DKDonald Knuth
... (laughs) not just by computers and, and, and that typography could massively enhance that. And, and, and, and, and so, uh, I mean, it, there are just wonderf- if they're gonna look it up, that they should also look up this book by, it's called Physically Based Rendering-
- LFLex Fridman
Mm-hmm.
- DKDonald Knuth
... by Matt Fahr and, gosh, uh, anyway, it, you know, got an Academy Award. But it's, but, but all the eff- all the graphic effects you see in movies, uh, like, uh, you know, are accomplished by algorithms. And this book, it is, the whole book is a literate program. It tells you not only h- how you do all the shading and, uh, and, and, uh, bring images in that you need for ani- animation and textures and so on, but it also, uh, you can run the code. (laughs)
- LFLex Fridman
Mm-hmm.
- DKDonald Knuth
Uh, so, uh, and, and, and so, uh, I find it, uh, uh, an extension of the way I, uh, of, of, of how to teach programming is, it is but by, is by telling a story, uh, as part of the program. (clears throat)
- LFLex Fridman
So it's, uh, it, it works as a program, but it's also readable by humans.
- DKDonald Knuth
Uh, e- e- e- es, and especially by me, uh-
- LFLex Fridman
(laughs) Yeah.
- DKDonald Knuth
... uh, a week later or a year later.
- LFLex Fridman
That's a good test.
- DKDonald Knuth
Yeah.
- LFLex Fridman
If you yourself understand the code-
- DKDonald Knuth
Yeah.
- LFLex Fridman
... uh, easily, uh, a week or month-
- DKDonald Knuth
Write it.
- 27:20 – 33:15
Beauty in programming
- LFLex Fridman
Okay. You, uh, dodged this question in an interview I listened to. Uh, so let me ask you again here. (laughs) Uh, what makes for a beautiful program?
- DKDonald Knuth
What makes for a beautiful program?
- LFLex Fridman
Yeah. What are the characteristics you see? Like you just said literate programming, what are the characteristics you see in a program that make you sit back and say, "That's pretty good."
- DKDonald Knuth
Well, the reason I didn't answer it because there are mo- there are dozens and dozens of answers to that bec- be- because e- each-
- LFLex Fridman
Yes.
- DKDonald Knuth
... you, you can define beauty, the same person will define beauty a different way from hour to hour. I mean, it depends on what, uh, uh, on what you're looking for. It, it, at one level, you, it's, it's beautiful just if it works at all. (laughs) At another level, it's beautiful if it's, I- if it, uh, uh, uh, can be understood easily. If it's b- it's, it's, it's beautiful if it, uh, uh, if it's literate programming, it's beautiful, it makes you laugh. I mean, uh ...
- LFLex Fridman
Yeah. I'm actually, so I'm with you. I think beauty, if it's readable.
- DKDonald Knuth
Readable, yeah.
- LFLex Fridman
Is if you understand what's going on, and also understand the elegance of thought behind it, and then also as you said, wit and humor. I was always, um ... I remember having this conversation, I had this conversation on Stack Overflow whether humor is good in comments. And I think it is.
- DKDonald Knuth
Wh- wh- whether humor, is, is good in comments?
- LFLex Fridman
Like, uh, when you add comments-
- DKDonald Knuth
Yeah.
- LFLex Fridman
... to your code.
- DKDonald Knuth
Yeah.
- LFLex Fridman
Uh, I always thought a little bit of humor is good. (laughs) It shows personality.
- DKDonald Knuth
Mm-hmm.
- LFLex Fridman
It shows character, shows wit and fun and all those kinds of things-
- DKDonald Knuth
Mm-hmm. Yeah.
- LFLex Fridman
... of, of the personality of the programmer.
- DKDonald Knuth
Yeah. Okay. So, uh, a couple of days ago, I received a, uh, a wonderful present from my former editor at Addison-Wesley. He, he, he's downsizing his house and he found, uh, that, that somebody at the company had, had found all the, all of their internal files about The Art of Computer Programming from the 1960s-
- LFLex Fridman
Mm-hmm.
- DKDonald Knuth
... and they gave it to him. (laughs) Uh, and then, uh, you know, before throwing, throwing in the garbage. And then he, so he said, "Oh, yeah," he, he planned to keep it for posterity, but now he realized that posterity is a, it's a bit too much for him to handle, so he sent it to me.
- LFLex Fridman
(laughs)
- DKDonald Knuth
Uh, and so, and, and so I just received, uh, this big, big stack of, uh, of letters. Uh, some of which I had written to them, but, but many of which they had written to early guinea pigs who were, who, telling 'em whether they, they should publish or not, you know?
- LFLex Fridman
Mm-hmm.
- DKDonald Knuth
And, and one of the things wh- was, uh, uh, in, in the, uh, in the comments to, to volume one, uh-... uh, the, the major, the major reader was, was Bob Floyd, uh, who, who was my great, uh, co-worker in the '60s, um, died early unfortunately. But, but, uh, uh, and, and he, he, he commented about the humor I- i- in it. And so, so, so we had, you know, he loo- r- ran it by me, you know, he says, you know, "Keep this joke in or not?" You know.
- LFLex Fridman
(laughs) yeah.
- DKDonald Knuth
Uh, uh, he, you know, they also sent it out to focus groups, you know (laughs) , "What do you think about humor in a, i- i- i- in a book about computer programming?"
- LFLex Fridman
What's the conclusion?
- DKDonald Knuth
And I stated my philosophy is, it says, you know, the ideal thing is, uh, that it's, it's like, it's something where the reader knows that there's probably a joke here if you only understood it, and this is a motivation to understand, to, to, to think about it a little bit. Um, but, but anyway, it, it, it, it's a very delicate humor. It's a very... I mean, it's, it's really a... each, each century invents a different kind of humor too. I mean, and, uh, and, and d- different cultures have different, different kinds of humor, um.
- 33:15 – 42:26
OpenAI
- LFLex Fridman
Let me explain it, maybe you'll find it interesting. So OpenAI is a company that, that does, uh, AI work. And they have this language model, it's a neural network that can generate language pretty well.
- DKDonald Knuth
Uh huh.
- LFLex Fridman
But they also have, on top of that, developed something called OpenAI Codex, and together with GitHub, they developed a system called OpenAI Copilot. Let me explain what it does. There's echoes of literate programming in it. So what you do is you start writing code and it completes the code for you.
- DKDonald Knuth
Uh huh.
- LFLex Fridman
So for example, you start... let's go to your factoring program. You start, you write in JavaScript, in Python, in any language...
- DKDonald Knuth
Yeah.
- LFLex Fridman
... that it trained on. Uh, you start l- you write the first line and some comments, like what this code does, and it generates the function for you. And it does an incredibly good job. Like, it's not provably right, but it often does a really good job of completing the code for you.
- DKDonald Knuth
I see. Whether... but how do you know whether it did a good job or not?
- LFLex Fridman
You could see a lot of examples where it did a good job, and so you... it's, it's not a thing that generates the code for you.
- DKDonald Knuth
Yeah, exactly.
- LFLex Fridman
It starts... it gives you, um... uh, so it puts the human in the seat of fixing issues-
- DKDonald Knuth
Yeah.
- LFLex Fridman
... versus writing from scratch. Do you find that kind of idea at all interesting?
- DKDonald Knuth
Every year, we're gonna be losing more and more control over what machines are doing. And, e- e- and people are saying, "Well, it seems to..." I, when I was (laughs) a professor at Caltech, uh, in the, in the '60s, we had this, this guy who, who talked a good game. He could give inspiring lectures and you'd think, "Well, he..." uh, th- thrilling things he was talking about and an hour later, you'd say, "Well, what did he say?"
- LFLex Fridman
(laughs)
- DKDonald Knuth
Um, uh, but what, but, but he really felt that it didn't matter whether computers got the right answer or not, it just mattered whether it made you happy or not. In other words, if, you know, if, if, if your boss paid for it, uh, he, uh, he, you know, then you had a job, you could, you, you know, you could, you could take care of your wife and-
- LFLex Fridman
So happiness is more important than truth.
- DKDonald Knuth
E- exactly. He didn't believe in truth, but he was a philosopher. (laughs)
- LFLex Fridman
(laughs) I like it. Um, and somehow, you, you see a...
- DKDonald Knuth
But w- we're going that way. I mean, w- so, so many more things are, are taken over by saying, "Well, this seems to work." And-
- LFLex Fridman
So-
- DKDonald Knuth
... and, and when there's, when, when there is, uh, competing interests involved, neither side understands why the decision is being made. Uh, uh, uh, it, uh, it, you know, we, we realize now that it's, that it's bad. But, uh, but consider what happens five, five year, 10 year-
- LFLex Fridman
Mm-hmm.
- DKDonald Knuth
... years down the line when, when things get even more f- further detached and each thing is based on s- something from the previous year.
- LFLex Fridman
Yeah. So you start to lose... the more you automate, the more you start to lose track of, uh, some deep-
- DKDonald Knuth
Exponentially.
- LFLex Fridman
... human things. Exponentially. But, so that's the dark side.
- DKDonald Knuth
That is.
- LFLex Fridman
The positive side is...... the more you automate, the more you let humans do what humans do best. So, maybe programming this, you know, maybe humans should focus on a small part of programming that requires that genius, the magic of the human mind and the mess you let the machine generate.
- DKDonald Knuth
Yeah.
- 42:26 – 48:31
Optimization
- LFLex Fridman
In The Art of Computer Programming, you wrote, "The real problem is that programmers have spent far too much time worrying about efficiency in the wrong places and at the wrong times. Premature optimization is the root of all evil."... in parentheses, or at least most of it, in programming. Can you, uh, explain this idea? Uh, what's the wrong time? What is the wrong place for optimization?
- DKDonald Knuth
So, f- first of all, the word "optimization." I, I, I started out writing software, uh, and optimization was... I was a compiler writer, so optimization meant, uh, making the, uh, making a better translation, it- it- it, so that it would run faster on a- o- on a machine.
- LFLex Fridman
Mm-hmm.
- DKDonald Knuth
So an optimized program is just like, you know, you, you, you run a pr- program and you set the optimization level f- uh, f- uh, to- to the compiler. So that's one w- word for optimization. Um, and at that time, I, uh, I happened to be looking in an unabridged dictionary, uh, for some reason or other and I came to the word optimize. I said, "What's the meaning of the word optimize?" And it says, "To view with optimism."
- LFLex Fridman
(laughs)
- DKDonald Knuth
And, and you, you look in Webster's-
- LFLex Fridman
Yeah.
- DKDonald Knuth
... Dictionary of English Language in 196- or the 1960s, that's what optimize mean- meant. Okay. Um, eh, now, eh, uh, now, so people started doing cost optimization, other kinds of things, uh, uh, you know, c- whole subfields of, uh, of, uh, algorithms and economics and whatever are, are based on what they call optimization now. But, uh, but to me, optimization, when I was saying that, was saying, uh, uh, changing a program to make it more, uh, tuned to the machine. And I found out that, um, w- when a person writes a program, uh, e- e- he or she tends to think that the parts that were hardest to write are gonna be hardest for the computer to execute. S- s- so, so, so maybe I have 10 pages of code, but I, I had to work a week writing this page. I, uh, mentally think that when the com- computer gets to that page, it's gonna slow down.
- LFLex Fridman
(laughs) Right.
- DKDonald Knuth
Uh, it's gonna say, "Oh, I don't understand what I'm doing. I better, I better be more care..." Anyway, this is, of course, silly, but it's, it, it's something that we, that we, that we don't know when we write a piece of code. We don't know what-
- LFLex Fridman
Mm-hmm.
- DKDonald Knuth
... wha- whether the computer is actually gonna be executing that code very much.
- LFLex Fridman
Mm-hmm.
- DKDonald Knuth
S- so, so people had a, had a very poor understanding of, o- of wh- what the computer was actually doing.
- LFLex Fridman
Mm-hmm.
- DKDonald Knuth
Uh, I, I made one test where, w- where we, we studied a, uh, Fortran compiler and it was spending more than 80% of its time reading the comments card.
- LFLex Fridman
Mm-hmm.
- DKDonald Knuth
Um, but as a programmer, we were really concerned about how fast it could take a complicated expression that had lots of levels of parentheses-
- LFLex Fridman
Mm-hmm.
- DKDonald Knuth
... and, a- and, and convert that in- in- into something. But that was just, you know, less than 1% of the... (laughs) Uh, uh, so if we optimize that, uh, uh, we didn't know what we were doing. But it, but, but if, if we knew that it was spending 80% of its time on the comments-
- LFLex Fridman
Mm-hmm.
- DKDonald Knuth
... card, you know, in 10 minutes, we could, we could make the, the, uh, the compiler run more than twice as fast.
- LFLex Fridman
And you can only do that once you've completed the program and then you empirically-
- DKDonald Knuth
Right.
- LFLex Fridman
... study where-
- DKDonald Knuth
I had some kind of profiling that, that I knew what was important. Yeah.
- LFLex Fridman
So, uh, you, you don't think this applies generally? I mean, there is something that rings true to this across all programs.
- DKDonald Knuth
I'm glad that it applied generally, but it, but it was, it was only my good luck. I, I said it, but he, you know, but it, but I did, but I said it in a limited context and I, and, and I'm gl- glad if it makes people think about stuff because I, you know, I'm... But it applies i- in another sense too that is, um, sometimes I will do optimization in a, in a way that does help the, the, the actual running time but makes the program impossible to change next week-
- LFLex Fridman
Right.
- DKDonald Knuth
... because I've changed my data structure or something that, that made it less adaptable. So one of the great, uh, uh, principles of computer science is, uh, is, uh, is laziness or whatever you call it, uh, uh, late binding. Uh, you know, don't... Hold, hold off decisions w- when you can.
- 48:31 – 57:14
Consciousness
- DKDonald Knuth
- LFLex Fridman
Let me ask you a weird question. So Roger Penrose, uh, has talked about computation, computers and, uh, he proposed that...... the way the human mind discovers mathematical ideas is something more than a computer, that, that a universal Turing machine cannot, uh, do everything that a human mind can do.
- DKDonald Knuth
Mm-hmm.
- LFLex Fridman
Now this includes discovering mathematical ideas and it also includes, he's written a book about it, consciousness. So I don't know if you know Roger, but-
- DKDonald Knuth
Mm. Yeah.
- LFLex Fridman
... do you think-
- DKDonald Knuth
My, uh, my daughter's kids played with his kids in Oxford. (laughs)
- LFLex Fridman
(laughs) Nice. So do you think there is such a limit to the computer? Do you think consciousness is more than a computation? Do you think the human mind, the way it thinks is more than a computation?
- DKDonald Knuth
I, I mean, I, I, I could say yes or no but, but, but I don't be- I have no reason t- I, I mean-
- LFLex Fridman
So you don't find it useful to have an intuition in one way or the other? Like when you think about algorithms, do you-
- DKDonald Knuth
Mm. Well-
- LFLex Fridman
... isn't it useful to think about-
- DKDonald Knuth
... I, I think it's an unanswerable-
- LFLex Fridman
... the limits?
- DKDonald Knuth
... uh, unanswerable question. And my opinion is, is no better than anybody else's.
- LFLex Fridman
You think it's unanswerable? So you-
- DKDonald Knuth
Yeah.
- LFLex Fridman
... you don't think eventually science will be able to-
- DKDonald Knuth
How many angels can dance on the head of a p- I mean, I don't know.
- LFLex Fridman
No, but angels aren't-
- DKDonald Knuth
... I, I, I, anyway, there, there are lots of things that are beyon- that, uh, that we can speculate about but, uh, I don't want somebody to say, "Oh yeah, Knuth said this and, and so he's, he's, he's smart and so, so he, so that must be..."
- LFLex Fridman
(laughs)
- DKDonald Knuth
I, I mean, I, I say it's something that, uh, we'll, we'll never know, uh ...
- LFLex Fridman
Interesting. I, uh, okay, that's a strong statement. I, I don't, I personally think it's something we will know eventually. Like there's no reason to me why the-
- DKDonald Knuth
Yeah.
- LFLex Fridman
... workings of the human mind are not within the reach of science.
- DKDonald Knuth
That's absolutely possible and I'm not denying it.
- LFLex Fridman
Yeah.
- DKDonald Knuth
Uh, and, and, it, no-
- LFLex Fridman
But right now you don't have a good intuition one way or the other.
- 57:14 – 1:10:01
Conway's game of life
- DKDonald Knuth
- LFLex Fridman
So, there's a tricky thing, I don't know if you have any expertise in this, you might be a little bit on the sideline, it'd be interesting to ask though, what are your thoughts on cellular automata and the Game of Life? Have you ever played with those kind of little, uh, games?
- DKDonald Knuth
I think, uh, The Game of Life, uh, it is- is wonderful and, uh, uh, and- and- and shows all kind of stuff about how things can evolve without the creator understanding anything more than the- the power of learning in a way. But to me, the most im- (laughs) important thing about The Game of Life is the- is- is how it focused for me what it- what it meant to have free will or not.
- LFLex Fridman
(laughs)
- DKDonald Knuth
Because The Game of Life is obviously totally deterministic.
- LFLex Fridman
Yes.
- DKDonald Knuth
And- and I- I find it hard to believe that anybody who's ever had children cannot believe in free will.
- LFLex Fridman
Right.
- DKDonald Knuth
On the other hand, this makes it crystal clear, uh, John Conway said, uh, he wondered whether it was im- immoral to shut the computer off after he got into a particularly interesting play of The Game of Life.
- LFLex Fridman
Yeah.
- DKDonald Knuth
Um...
- LFLex Fridman
Wow. Yeah, so there is... uh, to me, the reason I love The Game of Life is exactly as you said, a clear illustration that from simple initial conditions with simple rules, you know exactly how the system is operating, it's deterministic, and yet if you let yourself, uh, if- if you allow yourself to lose that knowledge a little bit enough to see the bigger organisms that emerge, and then all of a sudden they seem conscious, they- they seem, uh, not conscious but living.
- DKDonald Knuth
If- if- if the universe is finite, it- we're all living in The Game of Life, just slowed down, uh, I mean sped up a lot. Uh...
- LFLex Fridman
But do you think technically some of the ideas that you used for analysis of algorithms can be used to analyze The Game of Life? Can we make sense of it or is it too weird of a system?
- DKDonald Knuth
Yeah. I mean I- I've got- I've got a dozen exercises in volume four of Fascicle 6, uh, that actually work rather well for that purpose. (laughs)
- LFLex Fridman
But...
- DKDonald Knuth
Bill Gospers came up with the- with- with- with the algorithm that- that allows- that allowed Golly to- uh, to- you know, to run thousands and thousands of times faster, to get... you know the website called Golly?
- LFLex Fridman
Uh...
- DKDonald Knuth
G-O-L-L-Y, just-
- LFLex Fridman
It simulates the cellular automata, like Game of Life?
- DKDonald Knuth
Yeah, you got- you gotta check it out, yeah.
- LFLex Fridman
Can I ask you about John Conway?
- DKDonald Knuth
Yes. In fact, uh, I- I'm just reading now the- the issue of Mathematical Intelligence that came in last- last week. It's a whole issue devoted to- to (laughs) , uh, uh, you know, mem- remembrance of- of- of him. (clears throat)
- LFLex Fridman
Did you know him?
- DKDonald Knuth
I- I slept overnight in his house several times. I- (laughs) yeah.
- LFLex Fridman
He recently passed away.
- DKDonald Knuth
Yeah, he die- he died a year ago, um, May I think it was, of COVID.
- LFLex Fridman
What are you... what are some memories of him, of his work that stand out for you? Is... did- uh, did... on, o- on a technical level, did any of his work inspire you? On a personal level, did-
- DKDonald Knuth
(laughs)
- LFLex Fridman
... did he himself inspire you in some way?
- 1:10:01 – 1:13:21
Stable marriage
- LFLex Fridman
So, you mentioned your wife, Jill. You mentioned stable marriage. Can you tell the story of how you two met?
- DKDonald Knuth
So we celebrated 60 years of wedded bliss, like, uh, last month (laughs) .
- LFLex Fridman
(laughs)
- DKDonald Knuth
And, and we met because of, uh, I was dating her roommate. This, this was my sophomore year or her freshman year, and I was dating her roommate and I wanted her advice on strategy or something like this. And anyway, I found I enjoyed her advice better (laughs) than, than her. I enjoyed her roommate.
- LFLex Fridman
(laughs) You guys were ma- majoring the same thing?
- DKDonald Knuth
No, no, no.
- LFLex Fridman
'Cause I, 'cause I read something about, uh, working on a com- computer in grad school on a difficult computer science topic.
- DKDonald Knuth
So, so, so she's an artist and I'm a-
- LFLex Fridman
Okay.
- DKDonald Knuth
... and I'm a, a, you know, a geek and-
- LFLex Fridman
What was she doing with a computer science book? Or I read the... Was it the manual that she was reading? What was she reading?
- DKDonald Knuth
I wrote the manual that she had, had. She had to take a class in computer science.
- LFLex Fridman
Okay.
- DKDonald Knuth
And, and, and, uh-
- LFLex Fridman
So you're the tutor?
- DKDonald Knuth
No, no, yeah. No, we... Yeah, we... There were careful times, uh, uh, you know, trying to learn cer- certain concept. But I learned art from her. And so we, we worked together, uh, you know, occasionally in design pro- projects. But, but every year we, we write a Christmas card and, and we each have to compromise our, our own s-
- LFLex Fridman
(laughs)
- DKDonald Knuth
... notions of beauty. (laughs)
- LFLex Fridman
Yes. Uh, when did you fall in love with her?
- DKDonald Knuth
That day that I asked her about her, her roommate. (laughs)
- LFLex Fridman
(laughs) Okay.
- DKDonald Knuth
I mean-
- LFLex Fridman
You, you-
- DKDonald Knuth
No, I, I, I... Okay, so you're... I, I don't mind telling these things, uh, depending on how you far- how far you go, but, uh-
- LFLex Fridman
(laughs)
- DKDonald Knuth
... but, but, but let, let me tell-
- LFLex Fridman
I promise, I promise not to go too far. (laughs)
- DKDonald Knuth
... let, let me tell you this, that I, I never really enjoyed kissing, uh, uh, uh, until I found how she did it.
- LFLex Fridman
(laughs) Wow. And 60 years.
- DKDonald Knuth
Yeah.
- 1:13:21 – 1:24:15
Richard Feynman
- LFLex Fridman
uh, you mentioned that Richard Feynman was someone you looked up to.
- DKDonald Knuth
Yep.
- LFLex Fridman
Um, probably you've met him in Caltech?
- DKDonald Knuth
Uh, well, we knew each other th- th- yeah, at Caltech for sure. Yeah, I- I-
- LFLex Fridman
Uh, you are one of the seminal personalities of computer science. He's one for physics.
- DKDonald Knuth
Yep.
- LFLex Fridman
Have you ever ... Hav- is there specific things you picked up from him by way of inspiration or, uh-
- DKDonald Knuth
So, so we used to go to each other's lectures and s- and, and, uh, but, uh, but if I saw him sitting in the front row (laughs) it would throw me for a loop actually and I, I, I would, I would miss a few, a few sentences. Oh, what unique story do I have about ... I mean, I, I, I've s- ... You know, I, I, I, I often refer to his, his time in Brazil, uh, where he, um, es- essentially s- said they were teaching all the physics students the wrong way. They were just bl- they were just learning how to pass exams and not learning any physics and s- ... And he said, uh, tu- ... You know, "If you want me to prove it," you know, "here, I'll turn to any page of this textbook and, uh, a- a- and I'll tell you what's wrong with this page." And, and, and he did so. And, and the textbook had been written by his host and, (laughs) and he, and it was, uh, a big embarrassing incident. But he had previously asked his host if, if he was supposed to tell the truth. Um, eh, but, but anyway, it, it re- epitomizes the way, uh, uh, e- education goes wrong, uh, in all kinds of fields-
- LFLex Fridman
Mm-hmm.
- DKDonald Knuth
... uh, and has to periodically b- be brought back f- from h- from, from a process of m- of giving credentials to a process of giving knowledge. (clears throat)
- LFLex Fridman
Yeah, it's probably a story that continues to this day in, in a bunch of places where it's too easy for, uh, educational institutions to fall into credentialism versus, uh, ins- inspirationalism. (laughs)
- DKDonald Knuth
Mm-hmm.
- LFLex Fridman
I don't know if those are words but sort of, uh-
- DKDonald Knuth
Yeah, uh-
- LFLex Fridman
... understanding versus just giving a little, um, uh-
- DKDonald Knuth
It, it, it, it-
- LFLex Fridman
... plaque.
- DKDonald Knuth
... uh, and, you know, it, it's a, it's very much like what we were talking about if you want the computer to (laughs) ... If you want to be, be able to believe the answer a computer is-
- LFLex Fridman
Sure.
- DKDonald Knuth
... uh, is doing. That, w- one of the things Bob Floyd showed me in the '60s, there was a, uh, h- he loved this cartoon. There was a ... There, there, there were two m- guys standing in front of ... In those days, a computer was a big thing, you know, and the-
- LFLex Fridman
Okay.
- DKDonald Knuth
And, and the first guy says to the other guy, he said, "This machine can do in one second what it would take, uh, a million people to do in 100 years." And the other guy says, "Oh, so how do you know it's right?"
- LFLex Fridman
(laughs) Ah, that's a good line.
- DKDonald Knuth
Mm-hmm.
- LFLex Fridman
Uh, (laughs) d- is there some interesting distinction between physics and math to you? H- have you looked at physics much to, like, speaking of Richard Feynman? So, uh, th- the difference between the physics community, the physics way of thinking, the physics intuition versus the computer science, the theoretical computer science, the mathematical sciences. Do you see that as a gap? Are they strongly overlapping?
- DKDonald Knuth
Y- I, uh, it's quite different, I, uh, i- in my opinion. I, um, I started as a physics major and I switched into math, uh, and p- probably the reason was that I could, I could get A+ on the physics exam but I'd, but I never had any idea why I would (laughs) have been able to come up with the problems that were on those exams.
- LFLex Fridman
Mm-hmm.
- DKDonald Knuth
Uh, but, but in math, uh, I, I, I, I knew wh- you know, why the teacher set those problems and I thought of other problems that I could s- do.
- LFLex Fridman
Mm-hmm.
- DKDonald Knuth
And I believe it's, it's quite a different mentality. Uh-
- 1:24:15 – 1:33:47
Knuth-Morris-Pratt Algorithm
- LFLex Fridman
Can you describe what the, uh, Knuth-Morris-Pratt algorithm does, and how did you come to develop it? One of the many things that you're known for and has your name attached to it.
- DKDonald Knuth
Yeah. All right. So it should be actually Morris-Pratt-Knuth-
- LFLex Fridman
(laughs)
- DKDonald Knuth
... but we decided to use alphabetical order when we published the paper. The problem is, uh, something that everybody knows now if they're, if they're using a search engine, uh, uh, you k- you have a, a large collection of texts, and, and you wanna know if, if the word Knuth appears anywhere in the text we'll say, or, or some, some other word that's less interesting than Knuth.
- LFLex Fridman
(laughs)
- DKDonald Knuth
Okay? But anyway, like, like-
- LFLex Fridman
That's the most interesting word, yeah.
- DKDonald Knuth
... Morris or something.
- LFLex Fridman
Like Morris, right. (laughs)
- DKDonald Knuth
So anyway, we have, we have, uh, a large piece of text, and, and it, it's all one long one-dimensional thing, you know? It's first letter, second letter, and et cetera, et cetera, et cetera. And so, uh, the, the ques- uh, uh, you would like to be able to do this quickly. Um-And the obvious way is, uh, cl- let's say we're looking for Morris (soft music plays) , then, okay, go there. So we would, we would go through and wait till we get to letter M. Then we look at the next word and, uh, sure enough, it's an O, and then a- an R. But then there, oh, oop, too bad, um, you know, the next letter is, is E.
Episode duration: 2:21:26
Install uListen for AI-powered chat & search across the full episode — Get Full Transcript
Transcript of episode EE1R8FYUJm0
Get more out of YouTube videos.
High quality summaries for YouTube videos. Accurate transcripts to search & find moments. Powered by ChatGPT & Claude AI.
Add to Chrome