One afternoon a guy from the lab went to the blackboard and wasexplaining to the three of us freshmen what this machine did. I found amanual for the machine and they had example ten-line programs. It seemedto me they were kind of stupid—it looked like there was a way to improveeven those little programs.

And it turned out it was possible to go at night and touch the machine. Thiswas unusual. I think Dartmouth and Case were the only universities that letundergraduates touch machines. Other places they had professionals andyou submitted decks of cards and got your answers the next day. But atCase it was hands-on. They just said, “Oh, yeah, watch out for this; youdon’t want to do that; it’ll mess up the machine,” so we had a really nicechance to play with it.

Anyway, I got to see if one of my little changes to the program would alsowork, and it did. So I said, “My goodness, this is pretty amazing. I’m only afreshman and I can do better than what was in this book—this might besomething I have talent for.” Well, it turned out I did have a talent for it butnot in the way I thought, because almost anybody in the world could havedone better than that program in that particular manual.

The machine was a decimal machine, so it wasn’t quite as strange as if I hadto learn binary arithmetic, although I played with binary arithmetic a little bitwhen I was in high school. But the fact that it was decimal made it somehowmore human or something—comfortable. I can still remember the machinelanguage—sixty-five is reset-add-lower—it helps me making up passwords andthings now.

Seibel: Uh-oh; you just revealed your secret there.

Knuth: Yeah, right. Then I decided I would write a little program tocalculate the prime factors of a number. It was about 100 lines long. I wouldcome at night when nobody else was using the machine, and debug it. And Ifound more than 100 bugs in my 100-line program. But 2 weeks later I had aprogram that would find prime factors of any 10-digit number that youdialed into the console switches.

That was how I learned programming—basically taking one program that Imade up myself and sitting at a machine over a period of some weeks, andkept getting it to work a little better and a little better.

My second program was converting between binary and decimal. But mythird program was a program to play tic-tac-toe and that was what reallymade me a programmer.

I had to use data structures for that. I made three versions of tic-tac-toe,one of which was self-learning so that it would start out knowing nothingabout the game and then it would remember every time it lost a game thatthe moves it made were suspicious and the moves that the opponent madewere good, and it would upgrade the quality of certain positions anddowngrade the quality of other positions, and then after you played 400games it would do a fairly decent job of tic-tac-toe.

Seibel: It seems a lot of the people I’ve talked to had direct access to amachine when they were starting out. Yet Dijkstra has a paper I’m sureyou’re familiar with, where he basically says we shouldn’t let computer sciencestudents touch a machine for the first few years of their training;they should spend all their time manipulating symbols.

Knuth: But that’s not the way he learned either. He said a lot of reallygreat things and inspirational things, but he’s not always right. Neither am I,but my take on it is this: Take a scientist in any field. The scientist gets olderand says, “Oh, yes, some of the things that I’ve been doing have a reallygreat payoff and other things, I’m not using anymore. I’m not going to havemy students waste time on the stuff that doesn’t make giant steps. I’m notgoing to talk about low-level stuff at all. These theoretical concepts arereally so powerful—that’s the whole story. Forget about how I got to thispoint.”

I think that’s a fundamental error made by scientists in every field. Theydon’t realize that when you’re learning something you’ve got to seesomething at all levels. You’ve got to see the floor before you build theceiling. That all goes into the brain and gets shoved down to the pointwhere the older people forget that they needed it.

Seibel: I’ve asked the people I’ve talked to for this book about how muchthey’ve read The Art of Computer Programming. Most have used it as areference but a few said they’ve read it cover to cover. Should everyprogrammer be able to read your books? It’s pretty mathematically intensestuff.

Knuth: I sometimes wonder if I can read them. I’m trying to organize a lotof wisdom that surrounds the topic that I’m discussing and I gather it fromall these places where it appeared in parts and put it into some unity thatcan be carried forward, and gets the history right, and corrects bugs andobscurities in the original sources.

Like in the parts that I’m writing now, I’m starting out with stuff that’s inmath journals that is written in jargon that I wouldn’t expect very manyprogrammers to ever learn, and I’m trying to dejargonize it to the pointwhere I can at least understand it. I try to give the key ideas and I try tosimplify them the best I can, but then what happens is every five pages of mybook is somebody’s career.

In other words, there’s still so much more beyond any five pages of mybook that you can make a lifetime’s worth of study, because there’s just thatmuch in computer science. Computer science doesn’t all boil down to abunch of simple things. If it turned out that computer science was verysimple, that all you needed to do was find the right 50 things and then learnthem really well, then I would say, “OK, everybody in the world shouldknow those 50 things and know them thoroughly.”

But it isn’t that way. I’ve got thousands of pages and exercises, and I write itdown and put it in the book so that I don’t have to have it all in my head. Ihave to come back to it and learn it again. And I have the answers to theexercises because I know that ten years from now I won’t remember howto do the darn thing and it will take me a long time to reconstruct it. So Igive myself at least the clues to how to reconstruct stuff.

I’m constantly torn between saying, “Well, this is too complicated; you’dbetter not talk about it at all,” and the other feeling that people are saying,“But all you’ve put in your book is just so trivial; there’s nothing good.” I canargue at any particular time that I should cut everything out or that I haveway too little.

What it really boils down to is, all of the really cool things that can beexplained in a half a page have to be in my book, on some half a page. Andall the things I’ve seen that are just too good to be left out. So I find out thatthe section I just wrote about binary decision diagrams, it turned out that Ihad more than 260 exercises because there just was more and more stuffthat seemed to me there would be more than a trivial audience for. But I’mnot saying everybody is the audience for all 260 of these things. Still, I knowthere are a large number, for each of these, that are going to appreciate it.

I consider it amazing that some people do go cover to cover in my books. Inmost cases I know that people are going to pick and choose the parts thatthey like. But they know that if they dig further then they’ll get somethingthat has only one subset of jargon describing it instead of all different kindsof notations and terminology—if I didn’t write the books it would be muchharder for people to find stuff out. That’s what turns me on.

Also, I try to explore the territory in a way that is most relevant to apractical programmer rather than the most academic cachet for gettingsomething published that’s theoretically interesting but wouldn’t really beused in a real program.


Перейти на страницу:
Изменить размер шрифта: