Regular Expressions are Evil

by Nick Friday, June 23, 2006 10:49 AM

As I'm prone to do from time to time... here is another programming rant.  One of the books on my shelf at work is Mastering Regular Expressions from O'Reilly.  It's a very good book on the topic, and if you're interested in learning regular expressions, I highly recommend it.  Recently a coworker came into my cube, noticed the book and said "Wow, you have a regular expressions book.  I really want to learn about them, because they look so great!"  Her voice was filled with excitement.  I had to say it, but felt bad when I killed that excitement by saying, "They're not.  They're evil.  They should be used as little as possible."

Regular Expressions are very versatile, very powerful, and can do an amazing number of functions, and if I had my way, I'd never use them.  From my experience in industry, the programmer who generally likes regular expressions is also the type of programmer who never comments their code.  They're also the type of programmer who tries to combine as many operations as possible into one statement.  They like compact.  Compact looks cool... but compact can't be understood easily.

The reason why I think regular expressions are evil is because, unless you are a true regular expressions expert (and few really exist), you can't look at a regular expression and quickly say what it does.  It's this weird black box of strange characters strung together that's difficult to interpret.  It probably works, and it probably does the job very well.  But when you come back to that section of code in 3 months, will you be able to say what it does?  Will someone else who didn't write that expression be able to come in tomorrow and know what it does quickly?  Or will they have to spend an hour parsing through it in order to determine its purpose?

I do use regular expressions sparingly... but I comment the hell out of them.  I tend to use 3 times the number of comment lines when I embed regular expressions than normal code.  You have to if you want to know what you did a month later.  I say regular expressions are evil, because my goal is to always write code that someone can come in and look at, and know what it does without having to tear their hair out.

I don't always succeed in that goal, but at least I try.

Programming One Liner of the Day

by Nick Friday, June 23, 2006 9:38 AM

From a comment on Asymmetrical Information:

I'm a poor programmer whose solution to execution failures is type louder and more slowly.

I hear evidence of this in the cubes all around me sometimes.

The Hotel AOL

by Nick Wednesday, June 21, 2006 2:50 PM

You can check-out any time you like, but you can never leave.  Check out the link to a story about a 30 year old guy who attempted to cancel his AOL service... but couldn't because the representative wouldn't let him.  At one point, the service representative even asked to talk to his father!  Apparently this is not an isolated incident.  I don't have very high opinions of AOL, so I can't say I'm exactly surprised.  And I'm almost willing to say this guy got what he deserved by using such a crappy company for so long.  But that would be going too far.  When you cancel, that ought to be it.  No ifs ands or buts.

Ozzie, Lotus Notes and Simplicity?

by Nick Monday, June 19, 2006 12:34 PM

This article was featured on Slashdot, and I couldn't help but laugh as I read some of the concepts that were combined together to describe Ray Ozzie, the new Chief Software Architect at Microsoft:

Mr Gates himself was once moved to declare Mr Ozzie "one of the top five programmers in the universe" and revealed that he and Mr Ballmer had wanted for more than a decade to persuade him to join Microsoft. To the outside world, Mr Ozzie's programming prowess is known mainly through Lotus Notes, the e-mail and collaboration software that he masterminded, which was acquired by IBM in 1995.
"Complexity kills," Mr Ozzie wrote. "It sucks the life out of developers, it makes products difficult to plan, build and test, it introduces security challenges, and it causes end-user and administrator frustration."

I'm sorry... is that the architect of Lotus Notes saying that complexity kills, as if he's somehow an expert on simple software?  Did I read that right?  Lotus Notes is probably one of the worst, and most bloated pieces of email and collaboration software I've ever had the misfortune to use.  I pray... pray... that software at Microsoft (despite its problems) doesn't regress further by following the Notes model.


by Nick Sunday, June 18, 2006 10:01 PM

This weekend I happened to be talking to a fellow blogger, and I was reminded of Nick Burns from Saturday Night Live.  One of my jobs as a consultant right now is actually teaching.  Not only am I supposed to do software design, and actually write code, but I'm also supposed to be teaching .NET development to former mainframe and VB6 programmers on my team.  Now then, some of them are coming along really well, and one of them is not doing so hot.  But no matter what the situation, sometimes it takes all the energy inside me to stop from saying "Mooove!" and just taking over their computer and doing what needs to be done.

Now, I fully realize that this is not how to teach.  Showing someone how to do something by typing it out for them, and letting them look over your shoulder is absolutely nothing like actually having them struggle through it, giving them occasional hints and clues until the finally figure it out.  And the majority of the time, I don't push them aside, but instead let them ask questions, answer them where I think I should, and probe their own knowledge to try to steer them in the right direction.  But frankly, sometimes I just don't have time for that.  I have work I need to get done too, and my coworkers know it.  They can see it in my eyes.  They can see that I just want to push them aside, quickly bang it out, and leave.  That's when then look at me and say "Do you want to drive?"

I thought you'd never ask.  And oh yeah... You're welcome!

We All Have to Pay The Bills Somehow

by Nick Monday, June 12, 2006 5:42 PM

As you know, Blogging isn't free for me anymore, and I don't get enough traffic to support real advertising yet.  But, I'd still like to make this little enterprise of mine self sufficient.  As you may know, Phel at The Confidentials has started up a new Cafe Press store (which you should definitely check out).  What you might not know is that I've been working on a similar enterprise, and have just opened one up myself called CubicleRevenge.  You can find it at  Right now there are three designs with several more on the way in the next few days.


So head on over and check them out.  And if you feel so inclined, support my blogging with some nice merchandise.  And as Bartles and James would say... Thank you for your support.

About Me

Nick Schweitzer Nick Schweitzer
Wauwatosa, WI

Contact Me
I'm a Software Consultant in the Milwaukee area. Among various geeky pursuits, I'm also an amateur triathlete, and enjoy rock climbing. I also like to think I'm a political pundit. ... Full Bio

Community Involvement



Flickr Photos
This is a Flickr badge showing public photos and videos from Nick_Schweitzer. Make your own badge here.

Standard Disclaimers

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2017 Nick Schweitzer