webr
webr copied to clipboard
Discussion: Would it be possible to have a webR standalone version?
Good afternoon.
I have a question about the possibility of using WebR
server-side (possibly with WASI):
- Is there any expectation (or plan) to generate a WebR WebAssembly Standalone version?
- Or if there have been any attempts to have something like this in the past?
I ask this because it would be extremely interesting to be able to use/test WebR
server-side, mainly,
in experimental Serverless
platforms (Function as a Service
) that use Wasm as a containerization tool.
Thanks in advance.
We have indeed discussed a version of R for WASI internally, and it is something we'll be interested in the future. However, there are a couple of blockers standing in the way right now.
The biggest is probably R's reliance on C's setjmp
and longjmp
. Wasm originally didn't have support for exceptions, and so Emscripten by default emulates the behaviour using JavaScript's try/catch
. While browsers and node can execute JS code while running a Wasm binary, a pure Wasm engine may not have access to such a JS engine.
Luckily, the a Wasm exception-handling proposal exists, and Emscripten can emit code using the features introduced in that proposal to implement setjmp
/longjmp
, rather than dropping into JavaScript. Unfortunately, it looks like neither Wasmer nor Wasmtime supports Wasm exceptions yet.
Once Wasm exceptions are better supported by standalone Wasm engines, and if other useful proposals such as Wasm stack-switching are accepted and implemented, we might be able to revisit building R for WASI.
Adding a "verbal" vote for this support. It would make webR callable from Rust