5 ms·
Biased core dev here... I've used Perl 6 for IRC bots. The ease of writing parallel code, nice OO model, multi dispatch, and subsets make it very pleasant to d
by zoffix222 10y ago
Biased core dev here...
I've used Perl 6 for IRC bots. The ease of writing parallel code, nice OO model, multi dispatch, and subsets make it very pleasant to do them in Perl 6. Here's a bot I wrote that listens for GitHub webhooks and reports new commits and PRs: https://github.com/perl6/geth https://github.com/perl6/geth and here's another one that's just a bunch of random features: https://github.com/zoffixznet/perl6-buggable/ https://github.com/zoffixznet/perl6-buggable/
I also heard people say grammars are the most note-worthy feature of Perl 6 and people basically use them to quickly hack up a nice little micro-language in which they then attack their problem. Before I came to Perl 6 I was dumb as shoe when it came to writing parsers, but I find it trivial to do with Perl 6 grammars.
Do I like it? Although I'm obviously biased, I love the language. It lets you write beautifully concise, yet still readable, code. It even lets you use much more readable syntax for regexes. Somewhat regretfully, it made it very difficult for me to learn other languages, as in them I end up writing 3x, 4x, 6x the amount of code and I keep getting reminded of Larry Wall saying Perl 6 would be the last language you'd learn. In Perl 6 I can "talk"; in other languages, I write "code".
However, while the language is fantastic, the implementation still has a lot of work to be done to polish it off. It's basically a 1.0 release. Unlike Go, Rust, or Swift, there isn't a giant corporation behind Perl 6 that can just throw money at problems until they disappear. Compared to other languages, some things are still unoptimized and are much slower. I spotted some leakage that makes it problematic for very-long-running (months) programs. About 65 new bug tickets are opened per month. The test suite is pretty sparse in some areas (which is the likely reason for many of the new bug tickets). But... three new core developers joined this January, so hopefully all that will get improved pretty fast.
Someone in the comments also mentioned the baby-sized ecosystem... Since Perl 6 lets you use C libraries without needing to compile anything, people wrote stuff like Inline::Perl5 and Inline::Python that let you import and even subclass stuff from Perl 5 and Python. And that's a bit of a double-edge sword: yes, it's trivial to use libraries from Perl 5 and Python, but it also stunts the ecosystem; no one has enough motivation to re-invent the wheel in Perl 6 when the wheels from other languages are reasonably usable.
- chubot 10y agoDo you know what algorithm grammars use under the hood? I don't see it mentioned in documentation like this: https://docs.perl6.org/language/grammars https://docs.perl6.org/language/grammars "Group of named regexes that form a formal grammar" Are Perl 6 "regexes" as powerful as a context-free grammar? I guess they use the same kind of backtracking algorithm and ad hoc recursion as Perl 5? That is, does the algorithm for regexes differ from Perl 5, or only the syntax? I think the syntax is a big improvement BTW.
- yellowapple 10y agoIIRC, Perl 6 grammars are parsing expression grammars (PEGs). I don't know if these are compiled down to recursive descent or packrat parsers; my guess would be the latter (since that's typical for PEGs).
- chubot 10y agoThe sibling post says that they have both || and |. The || operator sounds like ordered choice from PEGs, and | sounds like a non-deterministic choice from regexes and CFGs. So it's basically a mix of paradigms, which muddies the waters in terms of what computational complexity guarantees you can get. Pure regular expressions can be matched in linear time; CFGs in cubic time and some subsets in linear time; packrat parsing in linear time, and backtracking PEG in exponential time. Perl 5 regexes are exponential time in general. I've used regexes extensively on big data so I don't like this mix of paradigms. I'd rather have separate dialects for each paradigm than having to guess what it's using underneath. Backtracking causes real problems in production: https://news.ycombinator.com/item?id=12132045 https://news.ycombinator.com/item?id=12132045 I would bet money that Perl 6 uses backtracking, because it has a mix of paradigms that makes it harder to do anything smarter. Backtracking is also bad for adversarial input, which is essentially always a concern nowadays.
- mst 10y agoRoughly (so far as I understand it), it's PEG with an escape hatch to regexps if you really must, and it doesn't backtrack by default. Please do have a play some time and assuming that I got the above right, donate however much money you would've been willing to bet to the Perl Foundation or the Enlightened Perl Organisation as you prefer :)
- CodeWriter23 10y agoThanks. Your comment has uniquely challenged my skepticism and hesitancy around Perl 6. I mean that with sincerity.