2 ms·
> Every programmer ought to have the experience of implementing a tool for matching regular expressions from scratch. Umm... I'm sure it's fascinating, but I'v
by crazygringo 14y ago
> Every programmer ought to have the experience of implementing a tool for matching regular expressions from scratch.
Umm... I'm sure it's fascinating, but I've really got better things to do with my time, which is why I use RegExs in the first place :)
- daeken 14y agoYou also probably have better things to do with your time than writing your own webserver, or creating your own language and compiler, or creating a database. But every time you do one of those things, you learn a lot about the things you actually use, and you end up being a far, far better programmer on the whole. If you only do the things you need to do, you're never going to be a great programmer.
- crazygringo 14y agoWell of course, I couldn't agree more! My point was that the original post seemed really judgmental in implying that building a RegEx engine ought to be done by everybody. Instead of "every programmer ought to have the experience", they could have said, "it can be valuable to have the experience". But a blanket statement that every programmer should do X... is really annoying and shows a very narrow worldview. Programmers are diverse, and do lots of different things.
- sophacles 14y agoWow, overreaction... there is a standard human communication idiom that is being followed here. For example movies are labeled as "must see", food is described as "you have to try...", and so on. Everyone[1] understands this to be a hyperbolic phrasing that isn't to be taken literally, but to really emphasize how important the speaker[2] finds the experience. Relax a little on the pedantry, it invalidates any statements made about better uses of one's time. [1] The sentence that references this footnote uses the phenomenon it describes for emphasis. [2] This is a similar, but distinct phenomenon of using a term, in this case speaker, with the implicit understanding that it can be generalized, in this case to "communicator". It shouldn't be confused with the situation described, but is also a useful pattern to understand for basic communication.
- tikhonj 14y agoYeah, but writing your own engine will help you understand why your innocent-looking expression has stupid exponential performance. (Assuming you implement something akin to Perl-style regexps that use backtracking rather than actually regular expressions using an NFA.) It will also help you understand why engines like re2[1] are absurdly faster than normal engines. [1]: http://code.google.com/p/re2/ http://code.google.com/p/re2/ In short: it's a great learning exercise. Also, I suggest learning the basic theory behind it (Chomsky hierarchy and so on)--it's very fascinating.
- dizidoro 14y agoNon deterministic regex engine is just plain stupidity. Am i missing something?