Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you embed GraalVM application in a browser?

GraalVM has so many surprising capabilities. But one thing I haven't seen, but would like to, is to be able to run a GraalVM application in a browser. Sources like this (Top 10 Things To Do With GraalVM) shows interop with Node.js, but not running a compiled application in the browser.

Is this possible? If so, is there documentation on this? Thanks!

like image 452
Jeff Avatar asked Jun 12 '18 07:06

Jeff


2 Answers

Well, it looks like this may be possible using Webassembly. From the Graal VM lead Thomas Wuerthinger: https://twitter.com/thomaswue/status/943592646915878912?lang=en

Webassembly is useful for statically typed languages (as LLVM backend). I am not aware of any Ruby, R, or Python implementation successfully targeting Webassembly. Graal VM will be able to run via Webassembly in the browser. It also has a "native" mode with standalone binaries.

So if you're coding in something like Clojure or Python and planning on compiling to Webassembly via Graal VM, you would likely run up against the same restrictions that Webassembly has, such as the browser sandbox and only being able to access web APIs. It will be interesting to see if those boundaries can be communicated through error messages or other compile-time checks.

like image 156
Jeff Avatar answered Oct 27 '22 04:10

Jeff


It would be very interesting to see a browser that embeds GraalVM and can run its engine for languages, even if only for JavaScript initially.

Currently, there's no such browsers, as far as I know. Maybe an interesting first step would be to take Electronjs, and try replacing the version of node they use with the version of node.js from GraalVM. It's not trivial, since they introduce some changes to the stock node.js and GraalVM introduces some changes when replaces the JavaScript engine with its own implementation.

However, it definitely should be possible to achieve.

like image 26
Oleg Šelajev Avatar answered Oct 27 '22 06:10

Oleg Šelajev