Merge branch 'gh-pages' into pages_for_v0.09-beta

gh-pages
Hauke D 7 years ago
commit 3842fb6369

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

@ -1,9 +1,10 @@
\[ [Using](using.html) - \[ [Using](using.html) -
Building - Building -
[🦋](perl6.html) -
[Notes](notes.html) - [Notes](notes.html) -
[Legal](legal.html) - [Legal](legal.html) -
[GitHub Wiki](https://github.com/haukex/webperl/wiki/Building-WebPerl) \] [Wiki](https://github.com/haukex/webperl/wiki/Building-WebPerl) \]
Building WebPerl Building WebPerl
================ ================
@ -13,6 +14,9 @@ Building WebPerl
Some things may not work yet, and parts of the API may still change. Some things may not work yet, and parts of the API may still change.
Your feedback is always appreciated! Your feedback is always appreciated!
This page documents the Perl 5 support, for the *experimental*
Perl 6 support, see [here](perl6.html).
Prerequisites Prerequisites
------------- -------------

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

@ -1,16 +1,17 @@
\[ [Using](using.html) - \[ [Using](using.html) -
[Building](building.html) - [Building](building.html) -
[🦋](perl6.html) -
[Notes](notes.html) - [Notes](notes.html) -
[Legal](legal.html) - [Legal](legal.html) -
[GitHub Wiki](https://github.com/haukex/webperl/wiki) \] [Wiki](https://github.com/haukex/webperl/wiki) \]
Welcome to WebPerl! Welcome to WebPerl!
=================== ===================
WebPerl uses the power of [WebAssembly](https://webassembly.org/) and WebPerl uses the power of [WebAssembly](https://webassembly.org/) and
[Emscripten](http://emscripten.org/) to let you run Perl 5 in the browser! [Emscripten](http://emscripten.org/) to let you run Perl in the browser!
WebPerl does not translate your Perl code to JavaScript, instead, it is WebPerl does not translate your Perl code to JavaScript, instead, it is
a port of the `perl` binary to WebAssembly, so that you have the full a port of the `perl` binary to WebAssembly, so that you have the full
@ -20,6 +21,8 @@ power of Perl at your disposal!
Some things may not work yet, and parts of the API may still change. Some things may not work yet, and parts of the API may still change.
Your feedback is always appreciated! Your feedback is always appreciated!
[**New: Experimental Perl 6 Support**](perl6.html)
```html ```html
<script src="webperl.js"></script> <script src="webperl.js"></script>
<script type="text/perl"> <script type="text/perl">

@ -1,9 +1,10 @@
\[ [Using](using.html) - \[ [Using](using.html) -
[Building](building.html) - [Building](building.html) -
[🦋](perl6.html) -
[Notes](notes.html) - [Notes](notes.html) -
Legal - Legal -
[GitHub Wiki](https://github.com/haukex/webperl/wiki) \] [Wiki](https://github.com/haukex/webperl/wiki) \]
WebPerl Author, Copyright, and License WebPerl Author, Copyright, and License
====================================== ======================================

@ -1,9 +1,10 @@
\[ [Using](using.html) - \[ [Using](using.html) -
[Building](building.html) - [Building](building.html) -
[🦋](perl6.html) -
Notes - Notes -
[Legal](legal.html) - [Legal](legal.html) -
[GitHub Wiki](https://github.com/haukex/webperl/wiki) \] [Wiki](https://github.com/haukex/webperl/wiki) \]
Misc. Notes on WebPerl Misc. Notes on WebPerl
====================== ======================
@ -17,54 +18,78 @@ Other places I've written about WebPerl:
- [Run Perl 5 in the Browser!](https://www.perlmonks.org/?node_id=1220426) - [Run Perl 5 in the Browser!](https://www.perlmonks.org/?node_id=1220426)
- [WebPerl Regex Tester (beta)](https://www.perlmonks.org/?node_id=1221705) - [WebPerl Regex Tester (beta)](https://www.perlmonks.org/?node_id=1221705)
- [Embedding WebPerl Code Demos into Other Pages](https://www.perlmonks.org/?node_id=1223812) - [Embedding WebPerl Code Demos into Other Pages](https://www.perlmonks.org/?node_id=1223812)
- [WebPerl now has Experimental Perl 6 Support!](https://www.perlmonks.org/?node_id=1225647)
I also gave a [lightning talk](http://act.perlconference.org/tpc-2018-glasgow/talk/7475) ### Talks
at YAPC::EU 2018 in Glasgow: [Video Link](https://youtu.be/KrGSg7uVZj0?t=29520)
- YAPC::EU 2018 in Glasgow - [lightning talk](http://act.perlconference.org/tpc-2018-glasgow/talk/7475), [Video Link](https://youtu.be/KrGSg7uVZj0?t=29520)
- *(planned)* German Perl Workshop 2019 in Munich - [talk](http://act.yapc.eu/gpw2019/talk/7616) (slides in English, talk in German 🇩🇪)
- *(planned)* YAPC::EU 2019 (PerlCon) in Rīga - [talk](https://perlcon.eu/talk/40)
[![DOI 10.5281/zenodo.1400490](https://zenodo.org/badge/DOI/10.5281/zenodo.1400490.svg)](https://doi.org/10.5281/zenodo.1400490) [![DOI 10.5281/zenodo.1400490](https://zenodo.org/badge/DOI/10.5281/zenodo.1400490.svg)](https://doi.org/10.5281/zenodo.1400490)
### In the Press ### "In the Press"
- WebPerl gets a mention in Will Braswell's talk ["Perl 11 - The Future of Saint Larry's Language"](https://fosdem.org/2019/schedule/event/perl11/)
- [Perl Advent Calendar 2018, Day 2](http://www.perladvent.org/2018/2018-12-02.html) (by Mark Fowler)
- [Reddit: Your scientists were so preoccupied with whether or not they could, they didn't stop to think if they should (2018-10-22)](https://www.reddit.com/r/programmingcirclejerk/comments/9qerw5/your_scientists_were_so_preoccupied_with_whether/) 😉 - [Reddit: Your scientists were so preoccupied with whether or not they could, they didn't stop to think if they should (2018-10-22)](https://www.reddit.com/r/programmingcirclejerk/comments/9qerw5/your_scientists_were_so_preoccupied_with_whether/) 😉
- [Hacker News (2018-10-21)](https://news.ycombinator.com/item?id=18269071) - [Hacker News (2018-10-21)](https://news.ycombinator.com/item?id=18269071)
- [Reddit /r/programming (2018-10-21)](https://www.reddit.com/r/programming/comments/9q65tf/run_perl_in_the_browser_with_webperl/) - [Reddit /r/programming (2018-10-21)](https://www.reddit.com/r/programming/comments/9q65tf/run_perl_in_the_browser_with_webperl/)
- [Facebook Group "Perl Programmers" (2018-10-20)](https://www.facebook.com/groups/perlprogrammers/permalink/2141844605848316/) - [Facebook Group "Perl Programmers" (2018-10-20)](https://www.facebook.com/groups/perlprogrammers/permalink/2141844605848316/)
- [Reddit /r/perl: WebPerl Regex Tester (2018-09-05)](https://www.reddit.com/r/perl/comments/9d5n77/webperl_regex_tester/) - [Reddit /r/perl: WebPerl Regex Tester (2018-09-05)](https://www.reddit.com/r/perl/comments/9d5n77/webperl_regex_tester/)
### Prior Art
Several people have built microperl with Emscripten:
- Harsha <https://github.com/moodyharsh/plu>
- Shlomi Fish <https://github.com/shlomif/perl5-for-JavaScript--take2>
- FUJI Goro <https://github.com/gfx/perl.js>
TODOs TODOs
----- -----
1. Testing 1. Testing
- How to best disable individual tests that we know won't work? (qx etc.)
- How to handle the many tests that call an external Perl?
- patching t/test.pl's runperl() seems easiest at the moment, and we can use the iframe method from the IDE
- Continue work on `WebPerl.t` - Continue work on `WebPerl.t`
- More tests for Unicode support (Perl/JS interface, Perl.eval(), plus Emscripten's virtual FS) - More tests for Unicode support (Perl/JS interface, Perl.eval(), plus Emscripten's virtual FS)
- Focus on getting the tests running in the browser instead of node.js - Focus on getting the tests running in the browser instead of node.js
- How to best package tests? - How to best package tests?
- If possible, a separate bundle, so that it can be loaded optionally and we don't need to rebuild - If possible, a separate bundle, so that it can be loaded optionally and we don't need to rebuild
- How does `make test` find and handle all the various modules' `t`s? - How does `make test` find and handle all the various modules' `t`s?
- How to best disable individual tests that we know won't work? (qx etc.)
- How to handle the many tests that call an external Perl?
- patching t/test.pl's runperl() seems easiest at the moment, and we can use the iframe method from the IDE
2. Misc 2. Misc
- Write up a full RPC example - Write up a full RPC example
- Add `Future` to the WebPerl build for a little more async niceness?
- Would `Future::AsyncAwait` work in WebPerl? (Or maybe with a JS backend?)
- `Future::HTTP` (probably just as a frontend to XHR?)
- Improve Perl 6 integration
- Build a packaged Rakudo.js ourselves instead of borrowing from <https://perl6.github.io/6pad/>
- Perhaps get an API change or two into Rakudo.js: `STDOUT` currently gets output with HTML escapes
- See also notes in [Perl 6 Support 🦋](perl6.html)
- Investigate Emscripten's main loop concept for handling nonblocking sockets? - Investigate Emscripten's main loop concept for handling nonblocking sockets?
- Turn some patches from emperl5 into patches for P5P - Turn some patches from emperl5 into patches for P5P
- Submit some patches to Emscripten - Submit some patches to Emscripten
- <https://github.com/kripken/emscripten/pull/7005> - <https://github.com/kripken/emscripten/pull/7005>
- <https://github.com/kripken/emscripten/issues/7029> - <https://github.com/kripken/emscripten/issues/7029>
- Would we need to patch Perl's signal functions if Emscripten's stubs weren't noisy? - Would we need to patch Perl's signal functions if Emscripten's stubs weren't noisy?
- Add Perl.Util functions for making file uploads and downloads easier - Add `Perl.Util` functions for making file uploads and downloads easier
- Plus an example showing how to use it to run a "legacy" Perl script with inputs and output - Plus an example showing how to use it to run a "legacy" Perl script with inputs and output
- Perhaps create a CPAN Bundle:: module or similar for `build.pl` deps?
- There is some potential for restructuring: - There is some potential for restructuring:
- `Perl.glue()` and `Perl.dispatch()` could go into `WebPerl.xs` (?) - `Perl.glue()` and `Perl.dispatch()` could go into `WebPerl.xs` (?)
- Parts of `webperl.js` could go into `common_preamble.js` or `WebPerl.xs`, - Parts of `webperl.js` could go into `common_preamble.js` or `WebPerl.xs`,
so that `emperl.js` is runnable on its own in a Web Worker (?) so that `emperl.js` is runnable on its own in a Web Worker (?)
(see notes in `perlrunner.html` / `e12f1aa25a000`) (see notes in `perlrunner.html` / `e12f1aa25a000`)
- `nodeperl_dev_prerun.js` could probably be merged into that as well - `nodeperl_dev_prerun.js` could probably be merged into that as well
- Could put a `WebPerl` stub on CPAN
- In theory could write a `WebPerl::Local` that contains the `WebPerl` API, and
have various drivers such as `WebPerl::WebDriver` or `WebPerl::JSAny` that
runs the code given to WebPerl's `js()`...
- Regarding the funky syntax highlighting on GitHub: <https://github.com/atom/language-html/issues/88#issuecomment-431361414> - Regarding the funky syntax highlighting on GitHub: <https://github.com/atom/language-html/issues/88#issuecomment-431361414>
3. See Also 3. See Also
@ -158,16 +183,6 @@ Release Checklist
- If there was a `pages_for_vX.XX` branch of `gh-pages`, don't forget to merge that - If there was a `pages_for_vX.XX` branch of `gh-pages`, don't forget to merge that
Prior Art
---------
Several people have built microperl with Emscripten:
- Harsha <https://github.com/moodyharsh/plu>
- Shlomi Fish <https://github.com/shlomif/perl5-for-JavaScript--take2>
- FUJI Goro <https://github.com/gfx/perl.js>
*** ***
Copyright (c) 2018 Hauke Daempfling (haukex@zero-g.net) Copyright (c) 2018 Hauke Daempfling (haukex@zero-g.net)

@ -0,0 +1,139 @@
\[ [Using](using.html) -
[Building](building.html) -
🦋 -
[Notes](notes.html) -
[Legal](legal.html) -
[Wiki](https://github.com/haukex/webperl/wiki/Perl6) \]
WebPerl Experimental Perl 6 Support 🦋
=====================================
Thanks to [**Paweł Murias**](https://github.com/pmurias) and his
amazing work on **`Rakudo.js`** and
[**6Pad**](https://perl6.github.io/6pad/), I've been able to patch
support for Perl 6 into WebPerl!
Currently **requires Google Chrome** (due to BigInt support), see the
[Quick Start](#quick-start) below on how to get this up and running on
your local machine!
```html
<script src="webperl.js"></script>
<script type="text/perl6">
say "Hello, Perl 6 World!"; # goes to JavaScript console by default
my $document = EVAL(:lang<JavaScript>, 'return document');
my $window = EVAL(:lang<JavaScript>, 'return window');
$document.getElementById('my_button')
.addEventListener("click", -> $event {
$window.alert("You clicked the button!");
} );
</script>
```
Quick Start
-----------
- Prerequisites: `perl` (a recent version is recommended, e.g. v5.26 and up),
and [`cpanm`](https://metacpan.org/pod/App::cpanminus) to easily install
dependencies (otherwise, see the files `cpanfile` for the dependencies and
use the module installer of your choce).
- In a shell (the following assumes Linux):
$ git clone https://github.com/haukex/webperl.git
$ cd webperl
$ wget https://github.com/haukex/webperl/releases/download/v0.07-beta/webperl_prebuilt_v0.07-beta.zip
$ unzip -j webperl_prebuilt_v0.07-beta.zip '*/emperl.*' -d web
$ cpanm --installdeps .
$ cd experiments ; cpanm --installdeps . ; cd ..
$ experiments/p6/6init.pl # this patches Perl 6 support in
$ plackup web/webperl.psgi
- Then point your Chrome browser at <http://localhost:5000/6demo.html>,
and have a look at its source.
Have fun!
Experimental Status and Notes
-----------------------------
- I don't have enough experience with `Rakudo.js`
- <https://github.com/rakudo/rakudo/tree/master/src/vm/js>
- <https://perl6.github.io/6pad/>
- <http://blogs.perl.org/users/pawel_murias/>
- <https://github.com/perl6/perl6-parcel-example>
- <https://www.youtube.com/watch?v=LN0mKjmraVs>
- requires BigInt support, which is currently only available in Chrome
- <https://developers.google.com/web/updates/2018/05/bigint>
- <https://github.com/tc39/proposal-bigint>
- <https://v8.dev/blog/bigint>
- Large download (10MB compressed, 74MB uncompressed) - can we
repackage it to make it smaller, or is there a good way to
distribute this?
- STDERR only goes to console, STDOUT gets output with HTML escapes
Documentation
-------------
My code steal^H^H^H^H^Hborrows the prepackaged `Rakudo.js` build from
[6Pad](https://perl6.github.io/6pad/) and caches it locally. The script
`experiments/p6/6init.pl` also patches the experimental P6 support into
`webperl.js` (see the [Quick Start](#quick-start) above).
Note that both Perl 5 and Perl 6 are only loaded on demand by
`webperl.js`, so if you only use one or the other, you won't have the
overhead of loading both.
For now, I've basically just patched `Rakudo.js`'s `evalP6()` into
`Raku.eval()`, and `NQP_STDOUT` into `Raku.output`, to make things more
like the Perl 5 WebPerl, and provided some of the same API for Perl 6
as I provide for Perl 5.
The JS API provided by WebPerl for Perl 6 currently closely mirrors
[the Perl 5 API](using.html#webperljs): There is a JS object `Raku`
which provides the following functions / properties that do mostly the
same as for Perl 5:
- `Raku.addStateChangeListener( function (from,to) {} )`
- `Raku.state`
- `Raku.output = function (str,chan) {}`
- `Raku.makeOutputTextarea()`
- `Raku.init( function () {} )`
- `Raku.eval( code )`
You can add Perl 6 code to your HTML pages with `<script>` tags
with `type="text/perl6"` or `type="text/raku"`.
For everything else, I defer to `Rakudo.js` for now! I will update this
documentation as things evolve.
***
Additional notes on WebPerl's experimental Perl 6 support may be found
in the [GitHub Wiki](https://github.com/haukex/webperl/wiki/Perl6).
***
Copyright (c) 2018 Hauke Daempfling (haukex@zero-g.net)
at the Leibniz Institute of Freshwater Ecology and Inland Fisheries (IGB),
Berlin, Germany, <http://www.igb-berlin.de>
Please see the ["Legal" page](legal.html) for details.
***
You can find the source for this page at
<https://github.com/haukex/webperl/blob/gh-pages/perl6.md>

@ -1,9 +1,10 @@
\[ Using - \[ Using -
[Building](building.html) - [Building](building.html) -
[🦋](perl6.html) -
[Notes](notes.html) - [Notes](notes.html) -
[Legal](legal.html) - [Legal](legal.html) -
[GitHub Wiki](https://github.com/haukex/webperl/wiki/Using-WebPerl) \] [Wiki](https://github.com/haukex/webperl/wiki/Using-WebPerl) \]
Using WebPerl Using WebPerl
============= =============
@ -13,6 +14,8 @@ Using WebPerl
Some things may not work yet, and parts of the API may still change. Some things may not work yet, and parts of the API may still change.
Your feedback is always appreciated! Your feedback is always appreciated!
This page documents the Perl 5 support, for the *experimental*
Perl 6 support, see [here](perl6.html).
- [Basic Usage](#basic-usage) - [Basic Usage](#basic-usage)
- [Serving WebPerl](#serving-webperl) - [Serving WebPerl](#serving-webperl)
@ -268,8 +271,9 @@ It is important to keep apart the different ways to access files:
- A `<script type="text/perl" src="foo.pl"></script>` tag will cause `webperl.js` - A `<script type="text/perl" src="foo.pl"></script>` tag will cause `webperl.js`
to fetch `foo.pl` from the *web server*, not the virtual filesystem! to fetch `foo.pl` from the *web server*, not the virtual filesystem!
- *However*, that Perl script will *also* only see the virtual filesystem, - *However*, that Perl script will *also* only see the virtual filesystem,
not the web server, so it won't even be able to see "itself". You can still not the web server, so it won't even be able to see "itself" (`webperl.js`
fetch things from the webserver using e.g. AJAX requests. may save files such as `/tmp/scripts.pl`, but that's *not* guaranteed).
You can still fetch things from the webserver using e.g. AJAX requests.
While a WebPerl instance is running, you can modify files in the virtual file system While a WebPerl instance is running, you can modify files in the virtual file system
as you might be used to from regular Perl. But the virtual filesystem is reloaded every as you might be used to from regular Perl. But the virtual filesystem is reloaded every
@ -291,6 +295,7 @@ either. If you need to safely store files, it's best to store them on the user's
In particular, even though you might make heavy use of `/mnt/idb` when testing with the "mini IDE", In particular, even though you might make heavy use of `/mnt/idb` when testing with the "mini IDE",
remember that this storage is *not* a way to distribute files to your users, and in fact, some remember that this storage is *not* a way to distribute files to your users, and in fact, some
users' browsers may automatically regularly clear the `IndexedDB`, or have it disabled altogether. users' browsers may automatically regularly clear the `IndexedDB`, or have it disabled altogether.
It also may not work at all in a "sandboxed" `iframe`.
For providing your application to your users, either use `<script type="text/perl">` tags, For providing your application to your users, either use `<script type="text/perl">` tags,
compile the script into the virtual file system, or use the JavaScript `Perl` object. compile the script into the virtual file system, or use the JavaScript `Perl` object.
@ -418,11 +423,11 @@ Defaults to a simple implementation that logs via `console.debug()`.
#### `Perl.makeOutputTextarea(id)` #### `Perl.makeOutputTextarea(id)`
This function will create a new DOM `<textarea>` element, set up a `Perl.output` This function will create a new DOM `<textarea>` element, set up a
handler that redirects Perl's output into the `<textarea>`, and return the `Perl.output` handler that redirects Perl's output (merged STDOUT and STDERR)
DOM element. You may optionally pass this function a string argument giving into the `<textarea>`, and return the DOM element. You may optionally pass this
a DOM ID. You will need to add the `<textarea>` to your DOM yourself function a string argument giving a DOM ID. You will need to add the
(see `webperl_demo.html` for an example). `<textarea>` to your DOM yourself (see `webperl_demo.html` for an example).
WebPerl.pm WebPerl.pm

Loading…
Cancel
Save