Replies: 6 comments 6 replies
-
Thank you so much @rujialiu and everyone who contributed, this is an extremely impressive contribution! Just the 32-bit support by itself would already have been an invaluable contribution, and the WASM support goes far beyond that! Thanks to @infogulch, a pre-built WASM version is already available for download and ready for automatic generation in all future releases: #2006 The mentioned README description contains a usage example: https://github.com/mthom/scryer-prolog#building-webassembly Thank you all! |
Beta Was this translation helpful? Give feedback.
-
Awesome! Thanks to everyone who contributed. Exciting times for Prolog. I think the ideal API would use Wasm Components + WASI. Basically we would write wit definitions for the various basic Prolog types, and some functions for "query" and "redo" (and probably "consult string" as well). Then it would be possible to use wit-bindgen to generate the host APIs for JS and other languages. I'm currently working on this for Trealla, but I think it could work as a common API for all wasm-based Prologs. From there, it would be relatively straightforward to write a JS library like trealla-js that supports any compatible Prolog core (currently trealla-js follows a similar implementation to Scryer's, capturing stdout for everything, but I would like to replace it with Wasm components soon). If this sounds like a good idea, I would love to contribute. Perhaps we should make an issue for workshopping a wit definition? |
Beta Was this translation helpful? Give feedback.
-
Yes! This sounds cool! I don't have much experience about Wasm Components but I'm planning to dig into it in near future. It's also nice to have something similar with trealla-js because trealla is another interesting prolog on the web, and it'll be great to have one js codebase and able to switch between trealla and scryer if needed. If you go along the route I'd love to at least do some testing or debugging :)
|
Beta Was this translation helpful? Give feedback.
-
Many thanks @rujialiu ! It's so amazing that I couldn't wait to try it! So, this afternoon I've been playing with a Scryer Prolog playground, that lets anyone try Scryer Prolog. Very basic, more like a proof of concept: https://play.scryer.pl/ |
Beta Was this translation helpful? Give feedback.
-
The playground is niiiiice!!! @aarroyoc |
Beta Was this translation helpful? Give feedback.
-
Hello! Nice work with the playground! After some help from triska I managed to understand the basics of how to run scryer through it.
I realize these things may not be within the intended scope of the playground, but if one never asks.. :) |
Beta Was this translation helpful? Give feedback.
-
With PR #1986 merged, now Scryer Prolog has some basic WebAssembly support! Besides what
README.md
already says, here are some other points I would like to emphasize:Pros:
wasm-bindgen
should be able to write additional APIs quickly, usually more productive than writing wrappers for emscripten.clpz
(except those only avaiable in optional features)Cons:
This is my first contribution to Scryer Prolog. I thought it would be easy (because my past experience of building my own rust projects to wasm), but it turns out to be much more complex and subtle.
Luckily, I was welcomed and helped by a lot of people @mthom @triska @aarroyoc @lucksus @fayeed @Skgland. Thank you all!
The work is split into several PRs (atom-64bit, optional-features, 32-bit-support and finally wasm32-support), and most of the changes are easy to follow, and I hope additionally maitaining 32-bit systems and wasm32 should not be a big burden in the future.
As I said, writing additional APIs should be technically not hard, but needs discussion and coordination to avoid becoming a big mess. That's why I'm keeping the API minimal now (in theory I can even remove that API but then there's no easy way to validate webassembly actually works).
When the support gets better and better, someday we should be consider native js ffi (just use
wasm-bindgen
inside currentffi
module?).There are still a loooot of things to do, but this is a good start :)
Beta Was this translation helpful? Give feedback.
All reactions