Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: Run Perl 5 in the Browser!

by Corion (Patriarch)
on Aug 20, 2018 at 11:09 UTC ( [id://1220704]=note: print w/replies, xml ) Need Help??


in reply to Re: Run Perl 5 in the Browser!
in thread Run Perl 5 in the Browser!

Why use a Javascript library for CSV parsing when Text::CSV_XS can be bundled with WebPerl and provide all CSV parsing already?

Update: On the other hand, if you don't have Perl in your browser, Papa Parse seems to be a Javascript CSV parser.

Replies are listed 'Best First'.
Re^3: Run Perl 5 in the Browser!
by Anonymous Monk on Aug 20, 2018 at 11:17 UTC
    So webperl doesnt tra slate to js? I thought it did. Oh well
      So webperl doesnt tra slate to js? I thought it did. Oh well

      You're not the first to ask me about that, so I updated http://webperl.zero-g.net to mention that.

      WebPerl is a port of the perl binary to WebAssembly, so what is being run really is a perl, plus some glue code between JavaScript and Perl. Your Perl script is parsed and executed like it would normally be when you run perl (since as we know, only perl can parse Perl). The glue code provides a Perl js() function that you give a string of JavaScript code, if that JS code returns an object (hash), array, or function, it is wrapped inside a special Perl object that you can use like a Perl object (with overloaded hash, array, and coderef dereferencing), but all the operations on that object cause the equivalent JavaScript code to be run on the JavaScript object. In that sense, it is kind of like "translating Perl to JS", but in the dynamic, runtime sense, instead of some kind of source-to-source compilation.

      So it's perfectly viable to use any JavaScript library of your liking from WebPerl. For example, the included webperl_demo.html shows how to get the jQuery object from JavaScript and use that in Perl, the exact same thing could be done with the Papa object provided by Papa Parse. But then again, since my intention was to replace JavaScript with Perl, personally I'm probably going to stick to Perl modules like Text::CSV_XS for that kind of stuff, and only use JavaScript when I need to do stuff related to DOM manipulation. WebPerl is just meant to be a tool, so you're free to do what you like, of course :-)

      A few minor additions.

        I don't get the purpose of Webassembly here? Is it something like Perl<->Webassembly<->Javascript ? I mean,could it be done without Webassembly?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-03-29 06:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found