High altitude programming


I enjoyed reading Peter Norvig’s recent article “How to Write a Spelling Corrector”, in which he remarks.

… I figured that on the plane flight home, in less than a page of code, I could write a toy spelling corrector that achieves 80 or 90% accuracy at a processing speed of at least 10 words per second.

This isn’t the first time Google’s director of research has confessed to programming on a plane. While others sit back and listen to their ipod shuffles, Norvig writes a Python program to unshuffle his.

Why ever would anyone want to write code on a plane? There’s hardly enough space on those teeny tables to balance a laptop, and (as he acknowledges in both essays), an internet connection is unlikely.

Possibly he’s showing off: after all, his intelligent friends, Dean and Bill, had no idea how a computer program could even perform such magic, let alone one written in less than a page of code and on a plane. Maybe he’s overworked, and the plane is the only opportunity he gets for such recreational projects.

I don’t think so. I’ll confess to having programmed on a plane myself, and suspect the real reason is that an aeroplane is — perhaps suprisingly — a good place to get some thinking done. The absence of an internet connection can be a bonus: all too often in this age of instant messaging and syndication, the internet is a distraction. I’m not surprised that a serious thinker like Professor Knuth doesn’t even read email.

Some suggest humans are naturally nomadic, and that movement aids concentration. Maybe so. Certainly if I go jogging at lunchtimes, technical problems seem more tractable on my return. And I can digest a specification or a text book at least twice as quickly on a train as I could in an office.

Spell Correcting Google

$ curl -s http://norvig.com/big.txt -o big.txt && \
  curl -s http://norvig.com/spell.py -o spell.py && \
  python -c "import spell; print spell.correct('google')"