http://www.perlmonks.org?node_id=955879

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

Marhall's comment on Re: Need to fill password in with perl on Javascript? made me think that with Parrot will come better interop between languages,which means that you could control the browser using Perl6 calling Javascript libraries,since everything bolts down to PIR acting as the common language denominator.

There is an attempt to port Javascript on Parrot

Is this assumption valid?

Replies are listed 'Best First'.
Re: Control the browser with Perl6
by Corion (Patriarch) on Feb 24, 2012 at 06:40 UTC

    For controlling "the browser", that is, Firefox, you only need a TCP connection to the mozrepl plugin. If you want to write your own Javascript-capable browser, then it could be beneficial to reuse a Javascript interpreter written for Parrot, if you tie yourself to Parrot. But the main work of writing a Javascript-capable browser is implementing enough of a credible DOM so that most of the Javascript on a page works.

Re: Control the browser with Perl6
by moritz (Cardinal) on Feb 24, 2012 at 07:12 UTC

    That is indeed Parrot's vision for the distant future, but even I as a Perl 6 developer and advocate think that it's far off in the future.

    Browsers embed highly specialized and optimized javascript JIT compilers, and a general-purpose dynamic VM like parrot can't really hope to compete in terms of speed any time soon. And since speed is a major concern for browsers, we can't really expect to see wide spread adoption of parrot on the browser level until the performance issues have been sorted out.

      Wasn't there a plan to run Perl 6 on Google's JS engine sometime back. What happened to that?

        Wasn't there a plan to run Perl 6 on Google's JS engine sometime back. What happened to that?

        Cash is cash :) Perlito/v6

Re: Control the browser with Perl6
by Marshall (Canon) on Feb 24, 2012 at 07:49 UTC
    In the "Library for WWW with Perl", (LWP) "wars", Corion's Mechanize::Firefox is like the ultimate "nuclear weapon"!

    It is possible to telnet into Firefox (if you have the MozRepl add-on installed) and "drive it around" and that is just way cool! WWW::Mechanize::Firefox uses that interface.

    I have no idea of how to run JavaScript from within Perl. The good news is that most of the time, you don't have to do it (actually run the JavaScript).

      "Ultimate" is subjective. :) The various Webkit Perl bindings are technically superior, Mozrepl is a crummy hack compared to driving a browser around on the windowing/widget level.

      Mech-Firefox maintains the overall advantage because of its copious documentation and Corion diligently giving support.