I’m sad that the author seemed to know neither the original proper wording, source, nor context of the jwz quote about regular expressions. Maybe JWZ’s quote has just spread too far or too wide. Either way, I think Jeff Atwood hit this nail on its head: http://blog.codinghorror.com/regular-expressions-now-you-hav... .
It's similar to the misunderstanding about Knuth's optimization quote.
Regex isn't bad, regex is bad when it's used thoughtlessly (like most tools, but worse than many because it's so information-dense that errors and misapplication may be non-obvious). Use regex to recognize strings. Don't use regex to recognize grammars. (A particularly common abuse of regex.) Break your regular expressions up either visually (if your language allows it) or into multiple expressions so that they're clearer and more easily understood and changed.
I can't hear about regular expressions without wanting to tell anybody that loves it so much to try Haskell. Really.
Monadic parsers are so much better, regular expressions become pointless. I've written an entire email server, with literally thousands of lines of parsers, and the only place I've used regular expressions is for accepting them from the user, in a configuration file.
Well... I've used regular expressions as arguments to grep much more often than I've programmed them. But I used them in grep quite often as part of a programming task.
It's like an editor. I think the article is saying "you need a good editor, and to learn to use it well", and I think you're saying "Haskell makes it really handy to write an editor!" That could be true, but it's a bit tangential to the article's point (presuming that I understand both of you correctly).
Emacs. This comes first into my mind when I hear the word "programming tool".
Emacs' default configuration is horrible. It took me many months to get used to it and to realize a perfectly convenient configuration. But since I did that 25 years ago I have stuck with it to this day. Emacs' killer feature is its almost unlimited programmability. org-mode is just one awesome example. There are several other good editors (vim, sublime, atom etc.) but none of them comes close to the power of Emacs.
7 comments
[ 5.2 ms ] story [ 32.6 ms ] threadRegex isn't bad, regex is bad when it's used thoughtlessly (like most tools, but worse than many because it's so information-dense that errors and misapplication may be non-obvious). Use regex to recognize strings. Don't use regex to recognize grammars. (A particularly common abuse of regex.) Break your regular expressions up either visually (if your language allows it) or into multiple expressions so that they're clearer and more easily understood and changed.
Monadic parsers are so much better, regular expressions become pointless. I've written an entire email server, with literally thousands of lines of parsers, and the only place I've used regular expressions is for accepting them from the user, in a configuration file.
It's like an editor. I think the article is saying "you need a good editor, and to learn to use it well", and I think you're saying "Haskell makes it really handy to write an editor!" That could be true, but it's a bit tangential to the article's point (presuming that I understand both of you correctly).
Emacs' default configuration is horrible. It took me many months to get used to it and to realize a perfectly convenient configuration. But since I did that 25 years ago I have stuck with it to this day. Emacs' killer feature is its almost unlimited programmability. org-mode is just one awesome example. There are several other good editors (vim, sublime, atom etc.) but none of them comes close to the power of Emacs.