Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Java's RegExp Engine Faster Than Perl's?

by YAFZ (Pilgrim)
on Sep 09, 2004 at 11:52 UTC ( [id://389631]=perlquestion: print w/replies, xml ) Need Help??

YAFZ has asked for the wisdom of the Perl Monks concerning the following question:

Fellow monks,

As I was exchanging e-mail with one of the Java programmers in an NLP (Natural Language Processing project for Turkish I advised using RegExp for some processing. He said that RegExp was okay and latest version of Java runtime included a RegExp engine. After that he commented that "Java's RegExp is way much faster than Perlīs". I was startled! He linked to an article: Java Regexp Wrangling.

Since I don't know much about the internals of Perl's RegExp mechanism I couldn't comment further but I'd like to be enlightened.

Did you have similar experiments? Can you comment on Java's RegExp being faster than Perl's? Or is the example misleading? If so, in what ways? I'm really curious about this matter and I'd like to hear your detailed comments.
  • Comment on Java's RegExp Engine Faster Than Perl's?

Replies are listed 'Best First'.
Re: Java's RegExp Engine Faster Than Perl's?
by Arunbear (Prior) on Sep 09, 2004 at 12:07 UTC
Re: Java's RegExp Engine Faster Than Perl's?
by synistar (Pilgrim) on Sep 09, 2004 at 13:34 UTC

    Tim Bray also posted again on the subject admitting that the test was not a fair comparison of the RE engines (and pointing to the response here on PM). It seems likely that the differences have more to do with Unicode handling in Perl vs. Java. See the article here.

Re: Java's RegExp Engine Faster Than Perl's?
by jacques (Priest) on Sep 09, 2004 at 21:58 UTC
    This same, tiresome episode comes up about once every year. Some Java programmer posts a hilarously flawed comparison article and points it out to a Perl hacker, who, in a huff, comes here (or use.perl) and complains.

    This will not die for a few reasons:

    1. Although they always admit the comparison was flawed, the authors will not go to great lengths to correct the accusation for obvious reasons.

    2. Many programmers like to brag about their favorite language. Java programmers are no different than anyone else. (Well, okay, they are not as smart as us but that's beside the point.)

    3. This is not in our FAQ, as it probably should be.

Re: Java's RegExp Engine Faster Than Perl's?
by perrin (Chancellor) on Sep 09, 2004 at 18:40 UTC
    I wrote about this here.
Re: Java's RegExp Engine Faster Than Perl's?
by Anonymous Monk on Sep 09, 2004 at 14:27 UTC
    I wonder if Java supports the same regex futures as Perl does (look ahead, look behind, .....).

    Also, that article doesn't give any information of the test script whatsoever, for example:

    while (<FILE>) { m/xyz/; }
    Will/Should be slower then
    $regex = qr/xyz/; while (<FILE>) { m/$regex/; }

    Also, the regex that is used in that article seems (at first look) not a very well written regex...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://389631]
Approved by broquaint
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-25 11:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found