Software Engineering discussion
Beautiful Code
>
A Regular Expression Matcher
date
newest »


I wish I had the time to code and run these examples.

To me, RegEx syntax feels like a "little language". It's a great skill to have basic understanding with, because it can be applied within other languages and for so many diverse tasks.
At a BBQ this weekend, my friend and I were talking about grep. He brought up AWK, which was great since we had just read about that in the previous book. That experience had made reading this chapter have an extra level of meaning for me.
It's certainly a delicate balance between compacting code and making it understandable. I think everyone is a little different in this area too. It's the artistic part of writing code. Personally, I don't need or like heavy commenting, but I am a fan of over things (e.g. giving literals and variables descriptive names).
I've worked for companies that enforce coding conventions and ones that don't care much. I don't think there's a right and wrong, but some people take this issue pretty seriously (even religious like).
I like small code examples that illustrate a variety of principles, and this regular expression matcher does just that. It would be fun to try to write this in Haskell.