Hacker News new | past | comments | ask | show | jobs | submit login

No language handles regular expressions as easily as Perl. Perl's power has always been in its power to do text processing.

That said, it's objects and pointers are a joke. At least Perl 5's are. As for Perl 6, I don't know. It couldn't hold my attention for 15 years.




"That said, it's objects and pointers are a joke. At least Perl 5's are."

MOOOOOOOOOSE!

http://moose.iinteractive.com/en/

I agree, nobody uses the native stuff.

Its like claiming Perl DB support is a joke. Well, yeah, everyone uses the addon package.


That can be also said about Python now that they pretty much froze the stdlib. You are right, a language should be evaluated by it's general power, not just by it's stdlib. If you can easily install Perl packages every Perl package should be part of the equation.


Why is AWK or SED not easy?

So yeah. There are a few languages which are quite good at text parsing nowadays. Another key argument was the huge amount of packages. But most languages have that now. There are also lots of scripting languages who can be written quite fast, like Python or Ruby. That's what I mean with there is not a single thing left that you really need or want to use Perl for beside having used it the last decade already. For everything that Perl can do there is at least another tool that is as good.

But all of that is not a shame. Every language will go that path, especially one that is so common as Perl was. Everybody wants to copy the best, until one day it's not the best anymore.


You missed qr/Moo(?:se)?/

All the nice bits of dynamic OO with the option to go procedural or functional when needed.


How does Perls regex stand up against Python? I mean once Perl was the pearl of regex/text processing (The Common Lisp package that everybody uses for regexis pcre, Perl Compatible Regular Expressions) but that was a long time ago.


= About Python regexes =

Aiui "The Future of Python Regexes" SO answer at http://stackoverflow.com/a/7066413/1077672 written by regex (and Perl) expert Tom Christiansen (and last updated by him in 2012) is still good info.

In brief, https://pypi.python.org/pypi/regex appears to be the path forward for Python. This engine is much closer to the power and Unicode compatibility of Perl 5's default regex engine.

= About Perl 5 regexes =

Aiui the default Perl 5 regex engine is significantly faster than the 're' regex feature included with Python 2. I don't know how it compares to the new 'regex' module.

Regexes in Perl have the advantage/disadvantage that they are syntactically integrated in to the language (a disadvantage if you don't like it being integrated).

Since Perl 5.10, a different regex engine can be plugged in and used without requiring any change in code that uses regexes (unless an engine uses a different syntax of course). (But it takes a lot of effort to package a regex engine up for use with Perl 5.)

A given regex engine can be extended using the overload module. Extending is relatively easy.

= About Perl 6 regexes =

A whole new ball game, two decades ahead of Perl 5 regexes.

http://en.wikipedia.org/wiki/Perl_6_rules

http://doc.perl6.org/language/grammars

https://github.com/moritz/json/blob/master/lib/JSON/Tiny/Gra...

Generally matches Perl 5 regexes feature-for-feature but with a much cleaner syntax. More importantly, unifies regexes and grammars.

Currently way slower than Python or Perl 5 regexes. Supposedly will eventually (5 years? 10?) incorporate all the key optimizations in the Perl 5 engine and become faster than Perl 5 regexes.


Case in point, with the countdown to Perl 6 now on the cause seems hopeless:

Perl 5.20 / 19Mb Apache log file / time: 1 sec

perl -wnl -E 'say $1 if /\b(\w{5})\b/' logs.txt

Perl 6 (MoarVM 2015.02) / 19Mb Apache log file / time: 88 secs

perl6 -n -e 'say $0 if m/(<<\w5>>)/' logs.txt

Given that efficient text & regex parsing is Perl's forte I don't see Perl 6 satisfying the basic requirements of Perl 5 hackers.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: