Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: Perl 5 Optimizing Compiler, Part 5: A Vague Outline Emerges

by moritz (Cardinal)
on Aug 31, 2012 at 11:16 UTC ( #990985=note: print w/ replies, xml ) Need Help??


in reply to Re: Perl 5 Optimizing Compiler, Part 5: A Vague Outline Emerges
in thread Perl 5 Optimizing Compiler, Part 5: A Vague Outline Emerges

Secondly, any impedance mismatch between perl and javascript is going to give you agonisingly slow performance. For example, if the full semantics or perl hashes can be provided by javascript dictionaries or objects say, then you can directly translate $foo{bar} into foo.bar or whatever. If however, the javascript facilities aren't suitable, then you might end up having to implement a Perl-style hash using javascript code, which is going to be slow. Also what tends to happen in these sorts of conversions is that the early proof-of-concept work (which uses a javascript dict say) works well and is really, really fast. Then you reach the point where you've done 50% of the work and its going really well, Then you get round to implementing the 'each' op, and suddenly realise that it can't be done using a javascript dict. So you switch to the slow route

This rings so true.

I've seen the same thing several times in Perl 6 compilers that targeted other high-level languages (for example kp6 comes to mind, which had a Perl 5 backend). It became so slow that hacking on it wasn't fun anymore, so people stopped hacking on it. (I think perlito descended from kp6 though).

Rakudo had the same problem, parrot's object system didn't fit it. So it had a huge rewrite switching to a custom object system, which only worked because much of it could be written in C. If it had to be done on top of parrot primitives, it could have never worked with decent speed.

And the problem is, there are so many fundamental operations that have subtle differences between both Perl 5 and Perl 6 and possible target languages like Javascript: routine invocation (think of @_ elements being aliases), method dispatch, hash and array access (think of autovivification, or what hashes return in scalar context in Perl 5). You might be able to take the speed hit from adapting one of them the right semantics, but all of them put together will kill you.

I am now convinced that targeting a high-level language like javascript isn't going to result in a speedup. I hope somebody proves me wrong eventually.


Comment on Re^2: Perl 5 Optimizing Compiler, Part 5: A Vague Outline Emerges
Re^3: Perl 5 Optimizing Compiler, Part 5: A Vague Outline Emerges
by BrowserUk (Pope) on Aug 31, 2012 at 11:30 UTC
    I am now convinced that targeting a high-level language like javascript isn't going to result in a speedup.

    FWIW: I reached a similar conclusion.

    Which is why I think the only game in town is (a) Low Level Virtual Machine.

    I'm not (yet) convinced that it can work its magic on Perl5; but I think it would be (have been?) the best possible underpinning for Perl6.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    RIP Neil Armstrong

    p align=right
Re^3: Perl 5 Optimizing Compiler, Part 5: A Vague Outline Emerges
by rurban (Scribe) on Sep 20, 2012 at 21:03 UTC
    moritz: flavio glock's perlito already was able to parse and compile a fast subset of perl and execute it on nodejs (javascript) 3x faster than perl itself, and also with sbcl (a fast common lisp).
      ... a fast subset of perl...

      The same thing came up in Perl 6 development more times than I could remember. Someone would show up and say "I have a very basic Perl 6 implementation on $virtual_machine that's n times faster than $other_implementation!" and it turns out they had implemented a calculator which did integer math.

      No disrespect to Flavio or Perlito, but "fast subset" only starts to get interesting when that "subset" is more set than sub.

        It already is.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

        RIP Neil Armstrong

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (15)
As of 2014-09-16 14:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (31 votes), past polls