Thursday, August 10, 2006

Now they have two problems...

Today, I'm going to write a bit about programming. But first, a short detour into the wonderful world of USENET, and the adaptability of certain quotes to any situation...

There's a fairly well known quote (among programmers, at least), that goes like this:

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

-- Jamie Zawinski

Jamie posted this to USENET back in 1997, and people have been quoting it ever since. I did some more searching, and I found an earlier variation, with citations going back as far 1988. Yes, Google Groups does have (some) USENET postings going back nearly 20 years. The older version is this:

Whenever faced with a problem, some people say `Lets use AWK.'
Now, they have two problems."

-- D. Tilbrook

Cool, so this is apparently one of those all-purpose jokes, much like any ethnic joke. Actually, that could be pretty interesting:

Whenever faced with a problem, some people say "Lets have the American do it." Now, they have two problems.

-- M. Bessey

Wow, that's comedy gold! Okay, maybe not. But it leads nicely into the topic I actually wanted to talk about:

presenting...

Mark's list of the Top Four programming technologies that fit into the "now they have two problems" template:
(in no particular order)

1. Threads
2. XML
3. Singleton objects
4. Regular Expressions

The common theme here is that these are all useful techniques, but are often misused by well-meaning programmers. I've seen more grief caused by misapplication of these technologies than anything else in my career. I'm going to write up a couple of quick rants on each of these subjects. This will be good for two reasons:

1. It gives me something to write about for the next couple of days.
2. I can vent a little about some particularly irritating instances of these things that I've seen.

7 comments:

Anonymous said...

Zawinsky is also the source of one of my favorite comments, that all software tends to expand until it can read mail.

His comment is also similar to the old joke, "First prize is two tickets to [bad show or lousy sports team here]. Second prize is four tickets."

I guess I have no fear of using regular expressions to do ad-hoc data parsing, since it strikes me as being simpler than using an actual parser generator (which have always seemed opaque and difficult to use to me, although I haven't looked at any recent ones). Of course, the data I'm usually parsing is itself pretty ad-hoc, so it's a match made in... somewhere.

I'm looking forward to your articles on the other subjects. :-)

Anonymous said...

I don't tend to fear using XML, although for small amounts of data (for "internal" projects, if you will) any structured text format that is actually agreed-upon and documented will work fine. I have encountered the "use-XML-since-it-will-solve-all-our-problems" approach that fits this template. People don't seem to remember that while XML solves several problems, it's not a panacea ...

Anonymous said...

I find it amusing that both of the quotes by Jamie Zawinski and Erik Naggum are taken out of anti-Perl rants. The regex comment should probably be interpreted as s/regex/Perl/

Anonymous said...

Is they use Threads, they can get as many problems as they want, limited by the number of cpu cores at a time :-)

bondage sex said...
This comment has been removed by a blog administrator.
Anonymous said...

I disagree with the order: singletons should almost never be used, and XML is often better replaced with a human readable alternative (json, etc), even if it can be useful for serialization.

Threads and regexes, however, are more often useful even if they can of course be misused.

Anonymous said...

"singletons should almost never be used"
-> where almost never == once, correct?