Slashdot Mirror


Donald Knuth Rips On Unit Tests and More

eldavojohn writes "You may be familiar with Donald Knuth from his famous Art of Computer Programming books but he's also the father of TeX and, arguably, one of the founders of open source. There's an interesting interview where he says a lot of stuff I wouldn't have predicted. One of the first surprises to me was that he didn't seem to be a huge proponent of unit tests. I use JUnit to test parts of my projects maybe 200 times a day but Knuth calls that kind of practice a 'waste of time' and claims 'nothing needs to be "mocked up."' He also states that methods to write software to take advantage of parallel programming hardware (like multi-core systems that we've discussed) are too difficult for him to tackle due to ever-changing hardware. He even goes so far as to vent about his unhappiness toward chipmakers for forcing us into the multicore realm. He pitches his idea of 'literate programming' which I must admit I've never heard of but find it intriguing. At the end, he even remarks on his adage that young people shouldn't do things just because they're trendy. Whether you love him or hate him, he sure has some interesting/flame-bait things to say."

10 of 567 comments (clear)

  1. Shocked by gowen · · Score: 5, Interesting

    He pitches his idea of "literate programming" which I must admit I've never heard of
    I'm shocked to discover that Knuth is taking an opportunity to push literate programming, given that he's been pushing literate programming at every opportunity for at least 25 years.

    Now, I've no problem with literate programming, but given that even semi-literate practices like "write good comments" hasn't caught on in many places, I think Don is flogging a dead horse by suggesting that code should be entirely documentation driven.
    --
    Athletic Scholarships to universities make as much sense as academic scholarships to sports teams.
  2. What? by TheRaven64 · · Score: 5, Interesting
    You've heard of TeX, written in Web, the language designed for Literate Programming, but you've not heard of Literate Programming?

    I have a lot of respect for Knuth as an algorithms guy, but anything he says about programming needs to be taken with a grain of salt. When he created the TeX language, he lost all credibility - designing a language in 1978 which makes structured programming almost impossible is just insane. TeX gets a lot of praise as being 'bug free,' but that's really only half true. The core of TeX is a virtual machine and a set of typesetting algorithms, both of which are very simple pieces of code (they'd have to be to run on a PDP-10). Most of the bits people actually use are then metaprogrammed on top of the virtual machine, and frequently contain bugs which are a colossal pain to track down because of the inherent flaws in the language (no scoping, for example).

    If you want to learn about algorithms, listen to Donald Knuth and you will learn a great deal. If you want to learn about programming, listen to Edsger Dijkstra or Alan Kay.

    --
    I am TheRaven on Soylent News
    1. Re:What? by cbart387 · · Score: 5, Interesting

      If you want to learn about algorithms, listen to Donald Knuth and you will learn a great deal. If you want to learn about programming, listen to Edsger Dijkstra or Alan Kay. For those that didn't read the article, Knuth expressed criticism on several of the questions asked, but he didn't want to just duck the question. For instance, the 'trendy question' he said this.

      With the caveat that thereâ(TM)s no reason anybody should care about the opinions of a computer scientist/mathematician like me regarding software development
      --
      Lack of planning on your part does not constitute an emergency on mine.
  3. You misunderstand by Rix · · Score: 4, Interesting

    Using "MULTIPLYBY" instead of "*" is asinine, because both are equally descriptive. Putting a comment above the line telling people why you're doing it isn't.

  4. Re:Literate programming... by 1729 · · Score: 4, Interesting

    ... looks like it falls into the same trap as COBOL. The idea that by making programming languages incredibly verbose, they will somehow become easier to use is a fallacy.

    Using "MULTIPLYBY" instead of "*" isn't going to make your code easier to read. From what I've seen (particularly of CWEB), literate programming doesn't change the programming language itself, it just adds a TeX style markup to the comments so that detailed (and nicely typeset) documentation can be generated from the source code. Take a look at some of Knuth's CWEB code, such as his implementation of Adventure:

    http://sunburn.stanford.edu/~knuth/programs/advent.w.gz

    It appears to be ordinary C once the CWEB documentation is stripped out.
  5. Re:Did anyone claim the bug prize on TeX? by 1729 · · Score: 4, Interesting

    It is probably folklore. But the story during my grad school days was that, Knuth offered 1000$ prize to anyone fining a bug TeX and he doubled it a couple of times. And it was never claimed. If that was true, it is very unlikely he was just flame baiting. He offers rewards for reporting errors is his books and for finding bugs in his code:

    http://en.wikipedia.org/wiki/Knuth_reward_check

    Many people save these (usually small) checks as souvenirs. My father -- a frugal mathematician -- received a few $2.56 checks from Knuth, and he promptly cashed each one.
  6. Re:He's right by clap_hands · · Score: 4, Interesting

    The thing about unit testing is that it's subject to the law of diminishing returns. A simple test of the basic functionality gets you a lot for minimal effort. Writing dozens of carefully chosen tests to examine boundary conditions etc. gives you a little bit more, but for a great deal more effort. Whether or not it's worth it depends very much on the situation and the nature of the code you're writing.

  7. Re:Unit Tests are not wasteful by seaturnip · · Score: 5, Interesting

    It actually doesn't sound to me like Knuth has heard of the term 'unit test' before this interview at all. It sounds like he thinks it means prototyping a function before writing the real version. Given that he likes to push his model of documentation-driven programming, I think he might be more sympathetic to unit tests if he understood that they can serve as a kind of formalized documentation.

  8. Re:Spaghetti-O Code by Kent+Recal · · Score: 4, Interesting

    I know this problem very well from the dark days when I was still writing java.
    There doesn't seem to be a satisfactory solution, it's always a tradeoff.

    While reading this thread I realized a funny thing: This particular annoyance
    totally vanished from my day-to-day headaches when I switched to python about
    a year ago.

    It's a bit wierd because Python doesn't even use braces so one would expect
    it to be even harder to identify where a block begins and where it ends.
    But the opposite has been the case for me: The clean syntax and language
    design has led me to write, on average, shorter blocks with very little
    nesting.

  9. Re:Literate programming... by mkcmkc · · Score: 4, Interesting

    Most people using C++/Java/C# end up writing "} //end while" anyway,
    Pray god I never have to work on code written by these fictitious "most people". Well, actually, once you've programmed in Python for a while, all of those spurious '}'s to close blocks really start to look as annoying and useless as "} //end while".
    --
    "Not an actor, but he plays one on TV."