Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Perl slower than java

by anonymized user 468275 (Curate)
on Dec 08, 2010 at 22:24 UTC ( [id://876127]=note: print w/replies, xml ) Need Help??


in reply to Perl slower than java

If the algorithm is exactly duplicated between Perl and Java, yes, Java is likely to win but C would beat them both. BUT the whole point of Perl is that it lends itself to creating more efficient algorithms easily and so much so that when approached properly, even C is likely to lose unless the C program is massive enough in its complexity to duplicate the terser optimal Perl algorithm. In this case, you are effectively processing all permutations instead of using any kind of sorting efficiency. Try to think of a way to represent the data so that as many losing iterations as possible simply aren't processed by an improved algorithm.

One world, one people

Replies are listed 'Best First'.
Re^2: Perl slower than java
by Christian888 (Acolyte) on Dec 08, 2010 at 22:58 UTC
    Processing-wise, my java equivalent is at least as inefficient as the perl code. I wonder if there is anything in the setting of the interpreter that may be slowing down the execution?

      perl >= 5.10 has gotten pretty bulky compared to older versions.

      I'm a bit curious as to how fast the newest ruby and python run the same algorithms.

      I bet if you would run the same code under perl 5.6 it would run a lot faster (the C data structures behind perl 5.6's variables are a lot more light weight). At least based on a very informal test we did here: Re^3: Why is this code so much slower than the same algorithm in C?.

        You have it backwards. The C data structures in 5.10 and greater are more light weight. Look elsewhere for the speed differences you have seen.
        --
        A math joke: r = | |csc(θ)|+|sec(θ)|-||csc(θ)|-|sec(θ)|| |
        Online Fortune Cookie Search
        Office Space merchandise

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-20 01:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found