Peter Norvig
317
advantage of being young is it’s important to grasp the whole program, the
whole problem, in your head—being able to concentrate. And I think that’s
easier when you’re younger, because your brain is better at it, or maybe it’s
just that you have less distractions. If you have kids, and family, and so on,
you just can’t devote as many consecutive hours as when you don’t. So
that’s part of it. But on the other hand, you’ve got this range of experience,
so you can make up for that in some ways by being able to do more
because you know how to do it.
Seibel: One of the aspects of the modern style of programming, as you
were saying, is that programmers have to absorb things quickly. How do
you tackle the problem of understanding a big pile of code, none of which
you’ve ever seen before?
Norvig: I think you do a mix of statically and dynamically. You start reading
the code and trying to make sense of it and then you get some traces of
what calls what, and where most of time is spent, and what’s the flow
through it. Then try to do something. Say, “I’m going to make this trivial
little change.” Or go to the issues database and say, “I’ll take this one.” In
order to do that, I have to learn a little piece of it. There’s only a little piece,
but you get that done and you move on to the next one.
Seibel: Have you ever done literate programming a la Knuth?
Norvig: I never used his tools per se. I’ve certainly written macros and so
on. And I’ve used the Java docs and things like that. In many ways, Lisp
programming encourages you to make your own system as you go, and so it
ends up being literate in that way. You find your own macros for your own
application-specific programming, and part of that is the documentation, part
of it’s the data, and part of it’s the code, so I’ve certainly done that. Then
more recently, in whatever language I’m using, whether it’s Java, or Python,
or whatever, I’ve certainly been careful to write test cases, and document
around that.
You look at Knuth’s original Literate Programming, and he was really trying to
say, “What’s the best order for writing a book,” assuming that someone’s
going to read the whole book and he wants it to be in a logical order.
People don’t do that anymore. They don’t want to read a book. They want
an index so they can say, “What’s the least amount of this book that I have