Sunday, January 29, 2006

A Man for All Seasons

We went to see A Man for All Seasons with Martin Shaw last night with my parents, who are visiting from the U.S. It was excellent. I only dimly remember the film and never saw it on stage before, but my father watched the play in the early 1960s, with Paul Scofield, and he enjoyed this production as well. If you get a chance, catch it before it closes on April 1st.

My favorite part of the play is when More defends the law against the ultimate in "the end justifies the means" arguments. The character Roper and More's daughter Alice beseech More to have his eventual betrayer arrested before he leaves the house, even if he has to make up some pretext. More argues that doing that would be a very bad idea:

Alice: While you talk, he's gone!

More: And go he should, if he was the Devil himself, until he broke the law!

Roper: So now you'd give the Devil benefit of law!

More: Yes. What would you do? Cut a great road through the law to get after the Devil?

Roper: I'd cut down every law in England to do that!

More: Oh? And when the last law was down, and the Devil turned round on you - where would you hide, Roper, the laws all being flat? This country's planted thick with laws from coast to coast - man's laws, not God's - and if you cut them down - and you're just the man to do it - d'you really think you could stand upright in the winds that would blow then? Yes, I'd give the Devil benefit of law, for my own safety's sake.

Roper's sentiment is as strong as ever. Terrorism, or whatever the evil du jour, may seem to justify sweeping away inconvenient laws, as long as it makes us safer. But it has the opposite effect in the long run.

Tags: ,

Sunday, January 22, 2006

Programming and Writing

I was speaking to a fellow editor recently and confessed my secret: I program computers for fun.

"Are you sure you're in the right job," she asks.

Yes, I reply, because programming and writing, especially non-fiction writing, are essentially identical skills. I believe that's why there are many good programmers who are also good writers -- Paul Graham, just to take one example. That we don't see too many examples of the reverse is because few writers understand the symmetry.

Both aim to convey information -- ideas, images, numbers and text -- in the most concise and efficient way possible. And both achieve beauty when they succeed. I wouldn't compare programming to Shakespeare, but there's not much separating a good software application from a well-written news story or essay. Software conveys information to a computer initially, while the written word is read directly by a human reader. But even that difference is just a distraction. The ultimate target of both is a person.

I've written for a living and programmed for fun for at least 20 years now and find that practice in one improves the other. Neither can be done well unless I'm thinking very clearly about the problem I'm trying to solve or the ideas I want to convey. Building logically from one point to another, in the simplest, clearest way possible makes good source code and good writing.

And just as learning different human languages can make you a better writer, learning other computer languages makes you a better programmer. I'm absolutely hopeless at learning human languages, and struggle enough with English to keep me well occupied. I studied French for years and still can't ask for directions or understand the answer. I don't remember much about the Latin I studied in High School, nor the Russian I spent two years wrestling with at university, but I do believe I've received benefits from them. I may not remember many specifics, but I do remember the ideas, recognize a Latin root or two and have observed the pluses and minuses of their different approaches. A phonetic alphabet (Russian) is a good thing, for example, as is precision in the choice of words.

I can't claim to be any better at computer languages, but at least I pick them up faster. I've programmed in Basic, Pascal, Fortran, C, C++, Java, Perl, Visual Basic and lots of different application-specific macro languages. My current favorite is Python, and I've written fairly complex graphical programs in it. As with the human languages, I've absorbed them to varying degrees. I can still pick up a Basic program, even though I haven't programmed in the language in any serious way since the Apple IIe, while I would have to learn C++ and Java again from scratch. And, again, I've benefitted from each, because each has a unique way of approaching and solving problems.

Since the beginning of the year I've also been putting in some serious effort into learning Common Lisp, so I'll use that to illustrate some of the benefits.

Lisp has been compared to Latin. In computer terms, it's certainly as old as Latin, dating back to the mid 1950s. But I think it's closer to a language with a completely different alphabet or wholly unfamiliar grammar, like Greek, Japanese or Hebrew. Unlike most modern languages, which are based on a predecessor known as Algol, Lisp isn't written in a way that would look familiar to most people.

The Pythagorean Theorem --

c = √(a²+b²)

-- might be written in a Algol-derived language such as Python, like this:

c = sqrt(a**2 + b**2)

Most people would find that at least familiar, once told that sqrt means square root and ** means exponent, anyway.

In Lisp, however, one way to write the same thing might be:

(setf c (sqrt (+ (* a a) (* b b))))

The inside-out style is definitely unfamiliar, but it doesn't take too many bouts with really hairy algebra or tricky text manipulation to understand that it is more efficient for some problems. There are many tasks that would take several steps in an Algol language, but can be solved with a tight one-liner in Lisp that, once you get used to it, is still readable. Learning a new language, in other words, is forcing me to think differently, out of the box.

Another benefit of putting effort into both disciplines is that it puts you in charge of two essentials of the modern world: communications and computers. The latter is getting as ubiquitous and as necessary as the former. Just as illiteracy can turn a free human being into a slave, computer ignorance will make you steadily less and less in control of your life in the next decades. Kids today are being taught nothing about computers in school except how to run Word and Excel. Who's the master in that relationship? It isn't the student. Programming has made me as confident in wielding a computer as the written word. (Read: not very, but I'm learning.)

The original question -- about whether I'm sure I'm in the right job -- assumes a divide between the sciences and the liberal arts, math and art, computers and words. I don't think it exists. I'm proud to be interested in both.

And, anyway, it's a lot more interesting than doing a crossword puzzle.

Tags: ,