7 ms·
Sure, it's much easier to read, especially when it comes to finding and understanding a two-character diff in a 50-char regex. Sure, I get the benefits of type
by yoz 6y ago
Sure, it's much easier to read, especially when it comes to finding and understanding a two-character diff in a 50-char regex.
Sure, I get the benefits of type safety.
Sure, it'll save me time debugging when I accidentally create an invalid regex.
But what am I meant to do with all that time saved? Read a book? Write more code? I don't get it. Let me waste the time on a ludicrously arcane syntax where I spend half the time looking at every bracket trying to understand if it's a control character in that particular context, because the ego trip I get from mastering this ridiculousness is HUGE!
(Yes, I understand regex syntax. I've been able to explain the phrase "zero-width negative lookbehind assertion" for the past twenty years. I inhaled the Friedl book and got utterly high on the idea that the awesome power of regular expressions - which are genuinely great in how they ease flexibility in accepting input - is entwined with their completely inhuman syntax. But I was wrong.)
- sixo 6y agoIt's fun to write regex but it is absolutely miserable to read it. This looks like an improvement.
- szatkus 6y agoIt is. For most parts regexes like "\d+" are ok, but when there is something more complicated I pull Verbal Expessions into a project. To these days reactions on CR were mostly positive or netural at worst. If it was built into the standard library I would probably use it instead of regex, but adding a new dependency and interfacing it with libraries that expect Java regex objects has its cost.
- maweki 6y ago> Sure, I get the benefits of type safety. It seems not ;) It's as if your java-compiler would stop warning you on forgotten semicolons and would instead error out during runtime when it reaches the statement with the missing semicolon. It's not your time saved. It's time saved not running the test suite, for example. An uncompilable regex is a category of errors that you can ban completely from your program. Like java bans syntax errors as a category of (runtime) errors. It's time saved as any developer will not break this in a way that is not a semantic error. It's time and mind saved not thinking about a whole class of errors.
- yoz 6y agoThank you for the clarification! To be clear: my post is sarcastic, and I was trying to say that this library looks like a significant usability improvement over traditional regex syntax.
- lgeorget 6y agoFortunately C++ won't suffer from this kind of problems since there, you can make your regex builder a constexpr! (lol)
- deleted 6y ago[deleted]
- pwdisswordfish4 6y agoVerbose does not ‘easier to read’ make; especially when you don’t know whether ‘anythingBut’ means (?!...) or [^...]. Type safety is nice, sure, but it’s a rather small benefit in this case. It doesn’t mean abandoning commonly-understood syntax is worth it. Most regular expressions are short enough to make errors visible with the naked (or IDE-assisted) eye. This library at best looks like a crutch for a deficient language (which Java admittedly is), and at worst an unnecessary obfuscation layer.
- alisonkisk 6y agoThe "deficient language" is "regex" not Java. Escape codes and special characters for regex semantics is a deficiency of the 1980s programming world, not Javam
- romanoderoma 6y agoThey can be hard to read, but I don't think they are deficient, on the contrary I think they are very elegant Stephen Cole Kleene was a brilliant mathematician and when he invented regexs in the 50s of the past century, he anticipated a lot of concepts that became popular in computer science, such as recursion (which he also founded as a branch of mathematics and computer science together with Alonzo Church, Kurt Gödel and Alan Turing) Java on the other hand has some deficiencies here and there and it's not really a modern language free from old cruft
- Yeroc 6y agoIs there any language 20+ years old without cruft?
- notreallytrue 6y agoHaskell? (30 years old) Where are the Lispers when you need them? :)
- 6y ago
- grishka 6y agoI've never had any problems writing and debugging regular expressions after I came across this: https://regex101.com https://regex101.com And since regexes are usually write-once, adding this complexity on top of them serves no additional benefit. If anything, it'd probably make it harder for the next guy to understand your code.
- ziml77 6y agoI bought RegexBuddy years ago and have loved it for debugging. However it only runs on Windows. Found regex101 recently and I think it's a great alternative (though I almost didn't check it out because the domain has SEO abuse site vibes).
- Something1234 6y agoCan you explain the SEO abuse vibes? I always felt it was a straight forward name. It's a site the provides the basics of regexes.
- ziml77 6y agoI think that's actually the problem. I'm used to domains that are very precise being used to host junk content. Most popular sites aren't so narrowly focused and/or have some brand-name-like domain.
- Hallucinaut 6y agoHave you seen https://regexr.com https://regexr.com? I've only come across it recently but I really appreciated the visual description of complicated regex, especially for interpreting someone else's work.
- brown9-2 6y agoSaving time is not just about getting to use it elsewhere - you also save time fixing bugs and the harm they can cause.
- sergeykish 6y agoRegular expression defines graph, graphical representation looks like a better choice: https://jex.im/regulex/#!flags=&re=%5E(%3F%3Ahttp)(%3F%3As)%3F(%3F%3A%5C%3A%5C%2F%5C%2F)(%3F%3Awww%5C.)%3F(%3F%3A%5B%5E%5C%20%5D*)%24 https://jex.im/regulex/#!flags=&re=%5E(%3F%3Ahttp)(%3F%3As)%... Usage example — CSS Syntax Module Level 3 documentation: https://www.w3.org/TR/css-syntax-3/#string-token-diagram https://www.w3.org/TR/css-syntax-3/#string-token-diagram and JSON specification: https://www.json.org/json-en.html https://www.json.org/json-en.html Have not found visual editor, made sample in quiver: https://q.uiver.app/?q=WzAsMTEsWzIsM10sWzAsNl0sWzEsMCwiXiJdLFsyLDEsImh0dHAiXSxbMywyLCI6Ly8iXSxbMiwyLCJzIl0sWzQsMywiXFxidWxsZXQiXSxbMywzLCJ3d3cuIl0sWzQsNCwiJyAnIl0sWzMsNCwiXFxidWxsZXQiXSxbNSw0LCJcXGJ1bGxldCJdLFsyLDNdLFszLDRdLFszLDVdLFs1LDRdLFs0LDZdLFs0LDddLFs3LDZdLFs2LDgsIm5vdCIsMV0sWzgsOV0sWzksNl0sWzYsMTAsIiQiLDFdXQ== https://q.uiver.app/?q=WzAsMTEsWzIsM10sWzAsNl0sWzEsMCwiXiJdL...
- wwright 6y agoGraphs may be more clear, but if we rule out visual editors, IMO this approach is still a net positive.