If you want to keep up with the changes as fast as they are committed and can read Prolog, C, CMake, JSON, HTML and JavaScript then just check the SWI-Prolog development repository commits that start with WASM
Note: AFAIK there is no way on GitHub to limit the search for commits by name.
48 hours do not reflect all the work and people involved in this work
academic papers are not just code that do what others have done before (if it does not teach anything that people knew before, there is no point in publishing it)
there exists excellent research papers about implementation details, where multiple decisions were considered and benchmarking evaluates them
Research is complementary to this industrial work. Sometimes 3 years are really necessary to find, write, and review a solution. Usually it is much less (around 6 months).
I sincerely believe that Prolog ignoring research is shooting oneself in the foot. If the language is nice, runs fast, or can do things that others cannot do, it is because someone did really hard research work.
Thanks @jan. We have the same set of benchmarks then. Iām curious about other aspects of the execution (loading code, indexing, etc.) that may affect uses of Prolog code in real life.
I would not like to get into a discussion of āindustrial workā vs āacademiaā, first because this is not the forum and also because it should be obvious to everyone that they are both necessary and quite complementary, but an important characteristic of academic research is that it is refereed, to ensure correctness, relevance, and originality. All of this is important and takes time, and is how we ābuild on the shoulders of giantsā. Without this process we are condemned to reinvent the wheel, as mentioned by @jfmc.
Pushed some cmake magic to fix this. Note that the build dependencies are still incorrect in the sense that just pulling the source and running ninja doesnāt always get the preload directory right. The ugly but safe way to rebuild after pulling the source is
rm -rf src/wasm-preload && ninja
The src/wasm-preload directory must be populated with what must appear in the /swipl directory of the WASM version (the Prolog home). That needs to be assembled from home and generated Prolog files for the various packages and may (unlike home) not use symlinks as that will result in symlinks to nowhere in the final WASM .data file So, we copy some directories using cmake -E, but this is not automatically redone if some Prolog library file changes
As for Lightweight compilation of (C)LP to JavaScript I think you are being a bit dismissive? Just to give some examples, it talks about several problems and possible solutions, and, it provides some performance figures, which have allowed other people to have an idea about how far you can get with that approach, without having to redo all the work (which is the point of publishing research). And all of that checked by reviewers, with references, etc. I honestly do not understand why you have a problem with it.
And yes, if to explain something well it takes several papers or a book, there is no problem with that. And note that that paper came with publicly available code in a repo.
I do agree that blogs, stack overflow, etc., are wonderfully useful, but they do not replace academic publications. Looking at some language implementations nowadays this is painfully obvious: many great ideas that are very carefully described in papers are systematically ignored and the mistakes and solutions are repeated over an over again, with the respective authors living in the illusion that they have invented something.
But, hey, I may just be an oldtimer, totally willing to accept that.
It is not the cache but the browser localStorage. The cache merely avoids re-fetching pages. The localStorage is a way to associate key/value pairs with a given document (web page) that persist. Deleting works (for me) in Chromium as well. Note that it deletes the current file and switches to āprogram.plā. You cannot delete āprogram.plā itself (but you can blank it).
That is now allowed. It only allows for a limited set of characters to avoid nasty injection attacks. Simple but effective
That was a bit of a challenge. That it behaves badly was to be expected: it executes a sleep in WASM, so if all is right it nicely writes, but as the browser event loop isnāt triggered nothing appears. This is now handled by redefining sleep/1 in library(wasm) to use js_yield/2. Then the wrapper around yieldable calls returns an object classified as builtin that can be executed and aborted. The execution calls setTimeout() and the abort clearTimeout() followed by resuming using wasm_abort.
For others using Chrome and wondering how to see Local Storage see
Of note to other using Chrome on Windows
While I can see the entry for the key and value removed (deleted) in the Chrome developer tools (F12) I can not see the file removed on the site. At present I am not worried about this nor is it high enough on my list to hunt down the root cause for this.
So as not to overload you with a large number of possible issues by doing this all at once I plan during those short pauses in the day to use code I find on SWISH and try them with #wasm_demo.
Are there items you want me to prioritize and others that I should disregard?
Iām still not sure how to continue. The current shell.html is a demo and experimentation platform to get the communication working and verify that the WASM version functions normally. Eventually it should be able to verify the core Prolog engine using ctest under Node.js.
The open question is how to interact with JavaScript. There are several issues to that
Calling Prolog from JavaScript. This is ultimately done through the C API but we surely want something more high level.
Calling JavaScript from Prolog. Now there is js_call/1 that takes a string that is passed to emscripten_run_script(). If the script raises an exception the page is broken Still wondering how to handle this.
Yield still has its limitations
Well, Iām not that far The progress has been better than I feared. One issue is how to call JavaScript from Prolog, so we can manipulate the DOM. I see:
emscripten_run_script() can call anything, but we get no return value and Iām unsure we can handle exceptions.
EM_JS() allows calling a fixed JavaScript function. Possibly we can make this work by first placing the function (name) and arguments somewhere, use this and fetch the results from some other well known place?
We could use js_yield(Request, Response)
First step seems a good bidirectional default translation between Prolog data and JavaScript.
Unfortunately this makes another problem surface: the http package contains too much. json support should never have been there and neither should most of the html support. The whole HTTP infrastructure requires threads. The WASM version clearly wants the HTML, JavaScript and JSON support, but not the HTTP server libraries.