4 ms·
It's all too clear that they master the regular expression syntax, because they explain their own in terms of it. And I for one have a hard time reading it. Re
by vintermann 4y ago
It's all too clear that they master the regular expression syntax, because they explain their own in terms of it. And I for one have a hard time reading it.
Regex is not fine. It's been recognized as a source of bugs for decades. Fredrik Lundh's famous quote: "Some people, when confronted with a problem, think ''I know, I'll use regular expressions!''. Now they have two problems."
Claiming that nothing needs fixing here is a lot like claiming we don't need Rust because the C prepocessor does all we need, or that we don't need any fancy build tools because we have GNU autotools. I really see that sort of comment anymore anywhere but Slashdot.
The issue is that ideally you use regex as little as possible anyway, so it's not worth the effort of fixing it and pushing for something better.
The main problem with this proposal is that they use almost no time explaining why they've made the changes they made, and even to understand WHAT the changes are you have to be good at reading already existing regexes (which is harder than writing them!)
That said, one change I spot which I heartily approve of, is reversing the quoting assumption. In regular regex, strings by default match themselves, and need to be escaped to get special meanings. This is a poor design because if you reach for regexes in the first place, it's the special meanings which are important, not the literal matches. Even the first change to regex (egrep) partially recognized this, by reversing the escaping assumption on ?, +, | and parentheses. Going all the way would have been the better decision, and I'm glad to see the authors of this project agree with me on that.
- SonOfLilit 4y agoI think you'll love the https://github.com/SonOfLilit/kleenexp https://github.com/SonOfLilit/kleenexp readme, then, I provide so. many. explanations. :)
- rtpg 4y agoI think the point of that quote is less about error prone regexes and more about regexes not being the right tool for many parsing problems. A new regex language doesn't really tackle that right? Maybe we need a new syntax generator language...
- gorjusborg 4y ago> "Some people, when confronted with a problem, think ''I know, I'll use regular expressions!''. Now they have two problems." This is a sort of funny tongue-in-cheek jab, not a factual statement. I'd chuckle if I heard someone say it in real life, but also eye-roll internally. There are some people who will write lines of substr code to trim whitespace from a string. That is the type of person I would expect to crack this joke. Regular expressions are fine, just like an oil filter wrench is fine. I wouldn't use an oil filter wrench to tighten a nut/bolt. I wouldn't write a single regular expression to validate an email address or implement a lexer. While I respect the effort put into making this project, I see it mostly as a distraction for new developers. If you are confused by regular expressions, you may be trying to do too much with them and/or you need to put some effort into mastering them (I recommend Jeffrey Friedl's Master Regular Expressions). If you try to pretend regular expressions don't exist, you are going to have a bad time. You will encounter them, unless you never touch existing code during your tenure. I also don't think this syntax is better. Regular expressions are terse, and that is a feature. It may feel like an anti-feature in larger expressions, but the secret is that if you are writing huge regular expressions, you are probably doing something wrong.