Programming, Zen, and…Origami

I’ve started re-reading Zen and the Art of Motorcycle Maintenance. There are so many gems in it that I’ll probably start a page in my backpack for them. Here’s one I like:

”…I’ve a set of instructions at home which open up great realms for the improvement of technical writing. They begin, `Assembly of Japanese bicycle require great peace of mind.’”

This produces more laughter, but Sylvia and Gennie and the sculptor give sharp looks of recognition.

“That’s a good instruction,” the sculptor says. Gennie nods too.

“That’s kind of why I saved it,” I say. “At first I laughed because of memories of bicycles I’d put together and, of course, the unintended slur on Japanese manufacture. But there’s a lot of wisdom in that statement.” … “Peace of mind isn’t at all superficial, really,” I expound. “It’s the whole thing. That which produces it is good maintenance; that which disturbs it is poor maintenance. What we call workability of the machine is just an objectification of this peace of mind. The ultimate test’s always your own serenity. If you don’t have this when you start and maintain it while you’re working you’re likely to build your personal problems right into the machine itself.”

I think this peace of mind is needed if you want to achieve that mental state called flow. I’ll bet that “workability of the machine” translates nicely into the design of the [programming language, platform, library] you’re using – I like Ruby because it gives me greater peace of mind! – but that’s another discussion. For now, I want to talk about two ways I have of getting back that peace of mind, when I lose it.


I learned all the origami I know from a book I got in Disney World when I was 10, and I’ve been folding on and off since then. I’m good enough to impress people who either have never tried it, or are very polite. Man, did I get tired of doing those dollar-bill bow-ties for relatives to leave as fancy restaurant tips.

Folding origami is a really interesting way to spend time (no joking!). You line up edges and folds as perfectly as you can, because the first few times, when you weren’t so careful, it came out like crap, and you learned that origami is a precise art. So you check twice before creasing the paper, and get it as perfect as you can. But the paper gets in the way! If you fold paper over itself enough times, you find that its thickness only seems negligible. You can get really thin paper and try to ignore this, but eventually, it’s always a factor. If that’s not enough, try remaking a fold that didn’t come out right—remake it enough times, and that crease starts to remind you of the maps in the car. Balancing geometric precision against the paper’s physical limits, the abstract ideal against the actual reality, is a lesson that applies beyond origami. How about when applying software design principles? Hiding your object’s data is a good idea, but 50 private variables with 50 getters and 50 setters is decidedly not. If your code reads like an illustrated tour of the GoF Design Patterns, you should chew on this.

Origami philosophy aside, it’s relaxing to do, once your fingers are accustomed to it. After folding a few thousand pieces, finding the sweet spot between the geometry and the paper is almost meditative. How well I achieve that balance is my measure of a piece’s quality.

Origami requires a light focus—just enough to let your mental peripheral vision wander. It’s an easy jog for your brain, somewhere bewteen sitting on the couch and running up a mountain. The same way some people need constraints to be creative, my mind needs something tiny to do, for it to really relax. All this sounds very zen to me: beginner’s mind, nothingness, mindfulness…I have to think about this some more.


I started juggling two weeks ago. Ok, started trying to juggle two weeks ago, and started something-almost-like-juggling in the last few days. Maybe I’ll start juggling this week…I can feel myself getting close. At any rate, I’m at the point where it’s not so frustrating, so I’m even more apt to practice (be warned, my cats).

Juggling also requires a light focus. It’s also kind of medidative. Until I drop a ball, which always happens, but up to that point, it’s really pleasant.

In Closing, Back to Zen

There’s something that connects movement and brainpower, I’m sure. I don’t know nearly enough about it to say anything conclusive or probably even convincing, so I’ll just end with some words from ESR, and if that doesn’t convince you, well…

Train in a martial-arts form. The kind of mental discipline required for martial arts seems to be similar in important ways to what hackers do. …The most hackerly martial arts are those which emphasize mental discipline, relaxed awareness, and control, rather than raw strength, athleticism, or physical toughness.

[The emphasis is of course mine.]

Who’s Afraid of Functional Programming?

Joel Spolsky just published a great (and very brief) explanation of functional programming. There’s also a podcast of Berkeley’s CS 61A SICP course from Spring ’06 that I found — the first few lectures on functional programming are really worth your time. And finally, for a rambling, evening-discussion style explanation of functional programming, complete with historical anecdotes, there’s Functional Programming for the Rest of Us. [You might want to save that one, and come back when you have some time…but do come back to it.]

Joel’s article got me thinking. I’m not really working on applications (at work or for fun) that really need massive concurrency, so that benefit of functional programming never swayed me much. Most of the uses I see for functional programming are simple things, like the selector filters I wrote about in Hacking the Browser’s DOM for Fun…given an array, use a function to specify which elements you’re interested in. Just like Ruby’s find and find_all methods, and Java’s FileFilter and FileNameFilter classes. It’s like I’m using a Maserati just to commute. Well, The Little Schemer is on my wishlist…it’ll be fun to try the examples in both Scheme and Ruby. Maybe even JavaScript.

Now, I went to a Java School, so I only heard about functional programming, LISP, Scheme, Ruby, and all these strange beasts once I started teaching myself off the internet. No one at any of my jobs ever mentioned them. How is it that our field can have such a rich heritage, and almost no one knows about it? Ask the person in the next cube over whether they’ve ever heard of functional programming, whether they know what it is, or can explain it to you. I guess 80% of you get blank looks. [This offer void at telcos and good universities.]

Quite a few people call that a competitive advantage. And they’re right — having scarce information puts you ahead of those without that information. But it seems short-sighted to me to gloat over that temporary advantage, when you’re missing the contributions that the people in the dark could be making.

UPDATE: It occurs to me that this might sound like I think functional programming should be used for everything — hardly the case, especially given my lack of experience with it, which I readily admit to. My point is, why don’t more of us know about it? Why isn’t it taught in more universities, or talked about at work?