This site will look much better in a browser that supports web standards, but is accessible to any browser or Internet device.

Anomaly ~ G. Wade Johnson Anomaly Home G. Wade Home

July 01, 2008

Regular Expressions as a Problem

Jeff Atwood had an interesting post on regular expressions a few days ago. Most of the article talks passionately about the usefulness of regular expressions, strategies for writing readable regular expressions, and tools to help write and debug regular expressions.

Along the way, Jeff points out a comment that usually pops up when the topic of regular expressions appears:

Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.

The post points to some interesting further research on the quote and then gets down to the meat of his regular expression advocacy. But not before taking a swipe at the Perl programming language with:

Should you try to solve every problem you encounter with a regular expression? Well, no. Then you'd be writing Perl, and I'm not sure you need those kind of headaches.

I know I shouldn't be, but I'm continually surprised by how many people really seem to dislike Perl.

The Two Problems

First off, I have to say that I do find the two problems quote to be amusing and somewhat clever (at least, the first time I heard it). According to Jamie Zawinski, who originated this version of the quote, he got it from another version before that used sed instead of regular expressions. Honestly, you could probably insert the name of any technology that you wanted to bash in that spot and get an equivalent quip.

Part of why the quote is funny is a real kernel of truth. Any time someone learns a new technology, they attempt to apply it to every problem that comes along. Doing so almost always results in an additional problem. (Using the wrong tool for the job.)

I would, however, like to to counter it with a question from a good friend and mentor, Rick Hoselton:

What do you call a programmer with only one problem?
Unemployed.
Posted by GWade at July 1, 2008 09:20 PM. Email comments