19 comments

[ 2.9 ms ] story [ 23.2 ms ] thread
Why use a 'better regex' when PEGs exists?
FTA: "RPL is based on Parsing Expression Grammars, which are more powerful than regex, obviating the need for “recursive regex” or “regex grammars”, both of which are ad hoc extensions and are not commonly supported in regex libraries."
If it is so much better and easier to read than regex, why not show any examples? Even the examples page is void of any examples.
A canonical regex pattern vs Rosie pattern should be front and center on the landing page. I want to immediately judge whether it's worth my time to read more.
I need to scroll about halfway through the reference documentation page to see what appears to be pattern-related syntax. Starting with a module system is really strange.
I came to make this exact comment, lmao. And it sounds like I went through the exact same process too.
I've look for a while at this, and have come to this conclusion:

At the time I need a multi-line pattern language, I just whip up a FSM-like program in code. And I'll continue to do that.

> At the time I need a multi-line pattern language, I just whip up a FSM-like program in code. And I'll continue to do that.

Not that this is an invalid approach, not at all, but I feel like there's a load-bearing "just" here that indicates this project could be useful for a lot of people :)

It's true. I've written a number of lexers/parsers, and it feels really natural to me make a big loop with switch/case.

If I started from "scratch", perhaps the overhead of learning Rosie would be worth it.

It's also a command line tool, and a library of useful patterns.

    curl -sL news.ycombinator.com | rosie grep -o subs net.url
How many LOC is your ad-hoc "FSM-like program", and have you done correctness and performance testing on it? If I had a nickel for every incorrect email validity checker I ran across, I'd have an awful lot of nickels.
> If I had a nickel for every incorrect email validity checker I ran across, I'd have an awful lot of nickels.

I won't argue with that. Email is a clusterf---. To make a validator to be truly "correct" is essentially impossible. Three RFCs have successively created standardized regexes and the latest RFC 5322 still has a bug. [1]

You'd have to convince me that you'd be significantly fewer nickles had they used Rosie.

> library of useful patterns

That's cool. I certainly use a library if I need to validate emails.

[1] https://stackoverflow.com/a/201378

It's really disingenuous to sell your project as a replacement for regular expressions when it has greater expressive power than them in the Chomsky hierarchy.
It's a replacement for regular expressions in purpose, not according to theoretical equivalence criteria.

The main selling points appear to be naming patterns in order to reuse them from libraries, functions, and more systematic grouping and lookahead operators: increased expressive power, which probably matters only in complex situations far beyond the limits of appropriate use of grep-like tools, is only a minor benefit.

I say this so often: "I can't believe it's $year and we're still using regex!" So when I see "new pattern matching language" my eyes light up and I run over there -- but there's no example, no docs, even where it says "examples", and "docs", and it's hard to find anything I can use. I'm sorry, am I a vulgar entitled twit for not finding the spoon right away?

Regex is terrible to read. Give me an example, things we frequently match for, IP, credit card number, dates ... I read the example for date parsing, I'm ... not sure what the equiv is? I suggest the authors put up a Rosetta stone of sort, eg. in regex-speak: [0-1][0-9]-[0-3][0-9]-201[0-9], in Rosie-speak: xyz. What about capture group, that's what makes regex powerful, not just matching, that and the look-ahead look-behind.

Meta-comment: regex is buried in everything significant that I work with, it's buried in grep, the language libraries, Splunk. It's going to be hard to dislodge, there's a deep moat because the tools and common use cases are ugly but well-understood. Why are regex still being used? Why has nothing better come along? How would I even regex-match extended Unicode?

Examples link has no examples. That's the quality you'll find with this project. Stupid.