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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Perl 5 Optimizing Compiler, Part 5: A Vague Outline Emerges
by BrowserUk (Patriarch) on Aug 31, 2012 at 11:30 UTC | |
Re^3: Perl 5 Optimizing Compiler, Part 5: A Vague Outline Emerges
by rurban (Scribe) on Sep 20, 2012 at 21:03 UTC | |
by chromatic (Archbishop) on Sep 20, 2012 at 21:14 UTC | |
by BrowserUk (Patriarch) on Sep 20, 2012 at 23:15 UTC | |
by chromatic (Archbishop) on Sep 20, 2012 at 23:31 UTC | |
by BrowserUk (Patriarch) on Sep 21, 2012 at 00:29 UTC |