There is a joke in the computer industry that I enjoy. It has to do with how less experienced individuals try to solve a certain class of problems, known as parsing problems.
Parsing problems are common. If you’ve ever compiled software, you’ve asked a computer to parse some text. It’s also the case that when you enter the date or your credit card number into a web form, there will be some code running behind the scenes that is trying to parse, or make sense, out of what you’ve entered.
Now, there are a few ways to approach parsing problems. Some are more work than others. Regular expressions are great, light weight and relatively easy to use, but they don’t work for every kind of parsing problem, and knowing when they will work and when they won’t is pretty subtle and computer-sciency. They can also be remarkably terse and therefore opaque. Finally, they can be very hard to test thoroughly.
A different approach is to write a grammar and an associated parser for that grammar, in a programming language like C, Java, or Lisp, etc. This approach is more work, but it can handle a wider range of problems, and if you know what you’re doing, you can be more certain that there aren’t a lot of corner cases where bugs can hide.
So the joke is this: A young man is asked to solve a parsing problem. He immediately thinks “I know, I’ll use regular expressions!” Now he has two problems!
I have seen this problem play out time and time again over my thirty-some years of writing software. And of course, I have succumbed to the same error frequently. I’m not writing myself an exemption here!
So what’s the point of this story? It’s to make this point: The approach you use in dealing with problems matters greatly, and it’s not always obvious when you’re making a mistake. If you’re just writing code, maybe that’s not such a big deal. But what if you’re making a mistake that might cost you a significant value? Should you be cavalier about your first assumptions, or perhaps give them some more consideration?
I’m in this situation right now. I’m thinking about a few situations and how I want to approach them. The thought that is running through my mind, fairly often, is this:
“A novice strives to change others; a wise man strives to change himself.”
I’ll have more to say about this in the future. In the interim, I’m interested in any thoughts you wish to share.