4 ms·
So... this is regular expressions for people who want to spend time learning this library instead of just learning regular expressions directly?
by kbd 8y ago
So... this is regular expressions for people who want to spend time learning this library instead of just learning regular expressions directly?
- pawelmurias 8y agoPotentially cool if you want to generate regular expressions dynamically at runtime
- dymk 8y agoSo, string concatination?
- kbd 8y agoIndeed! In fact, the library author cites this as one of the "main advantages" of their library (under "Getting Started"): > As you can see one of main advantages of using this library is ability to document every line of code without any hassle. In other words, the 'x' flag. Though it turns out JavaScript doesn't provide the x flag, but it's the same thing as string concatenating a regex across different lines. The fact that the author includes the warning "Never-ever add a semicolon if you want to continue expression" on a method chain shows the level of sophistication this library is intended for.
- verticalpalette 8y agoActually, I think this library could provide a security benefit since generating code by string concatenation is generally dagnerous. Analogous to generating HTML or SQL -- safer to use a library than to construct it yourself.
- dymk 8y agoYeah I don't understand what value this library provides. It's just additional indirection, not a proper abstraction any different than the regex APIs it's calling under the hood.
- dgritsko 8y agoSome people, when confronted with a problem, think "I know, I'll use ReX.js." Now they have three problems.
- kbd 8y agoI know you're meme-ing, but it's a great way to put it tbh. This library struck a nerve with me today because it's a rare example of a library that's actually harmful to its intended beginner audience. The author invented a verbose DSL for what's already a DSL! For the record, I'd never fault anyone for writing any code they want (unless maliciously ofc). "What would a method-based interface to regular expressions look like?" is a perfectly reasonable question! But the author is doing a disservice to anyone he gets to use this. Just use ''.match().
- mamcx 8y agoYeah, is like why use python when assembler is just as obvious. ---- Regex syntax sucks, or more exactly, it look like is the bytecode for programming language that is left as exercise to the reader.
- kbd 8y ago> Yeah, is like why use python when assembler is just as obvious. This is a truly awful straw-man.
- mamcx 8y agoIt is? Regex have a arcane "syntax". Is good, from the point of view of a APL user, but as part of other languages is not. Is totally outside the experience among other DSL. For example, you are on python, your DSLs are pythonic, except this one, that look totally alien.
- robocat 8y ago> Regex syntax sucks Learn it, use it, accept it. Or are you trolling? It is supported by most languages with special syntax because string manipulation is still important. The native support matters due to optimisations present that are peculiar to the runtime. Most any developer can understand your regular expressions, or they know who to ask. You need to know it if you expect to use shell tools. It's just like SQL: sure SQL is missing modern features and modern syntax, but at least once you've learnt it you can use it for debugging, performance, administrative tasks, reporting systems, dev tools, and your future projects that use another language.
- roblabla 8y agoWhy assume trolling? The sentiment that regex sucks is one shared with a very large population. At least to me, it's this kind of terrible "write-once" maintenance hell language that really ought to be wiped off the face of the planet. Its only redeeming feature is that it's fast (assuming you don't use the wrong features - lookaheads can cripple performance). Looking for alternative abstractions is very worthwhile. I'm not suggesting throwing away the existing regex engines, just abstracting away the ugliness. Whether this solution is the right one is debatable. You can draw a comparison with SQL. Lots of projects nowadays hide SQL behind an ORM, only using SQL when a very complex query needs to be written. I'd expect something similar for Regex would help maintainability of lots of projects.
- PavlovsCat 8y agoI think at this stage, the idea is to get feedback on how to improve it, or maybe what to change completely, not saying "recommend this to all newbies to learn instead of regular expressions". I'm just guessing because it seems to be 4 hours old. Maybe for the purpose of a more interesting discussion, let's just assume everybody knows (how to look up the docs for) regular expressions, but sometimes they're still lazy or just feeling playful, and want to do the same stuff with a different syntax... and this is just one first prototype of how maybe to do that. No offense intended, no claim that this will supersede learning regular expressions implied.
- m1sta_ 8y agoThe code written with this is probably going to be a lot easier for people to read that a raw regex. Never forget that code is read many time more often than it is written.