Public demo at https://wasm.swi-prolog.org/wasm/tinker
This repository implements SWI-Tinker, a SWI-Prolog playground running in your browser based on SWI-Prolog compiled using Emscripten to WASM.
The current system is primarily a proof-of-concept. You are encouraged to help improving it. The TODO file in this repo gives a list of possible improvements.
- Run SWI-Prolog in your browser
- Basic REPL loop window
- Basic editor support based on CodeMirror
- Saves command history and programs to your browser local store
- Allows uploading and downloading programs
- Allows for loading (compiling) these programs as well a loading programs directly from the internet.
- Load large programs quickly as
.qlf
files. - Support for a basic debugger using the common
?- trace, mygoal.
command. Support for spy- and break-points.
SWI-Tinker is over 10 times slower than native SWI-Prolog on the same hardware. SWI-Tinker lacks many libraries bundled with the native version, either for reducing the size or because required primitives are lacking. It also lacks important features of SWI-Prolog such as multi threading and access to a lot of system resources. To get a list of available and not-available libraries, run
?- check_installation.
Some alternatives for running Prolog in your browser are:
- SWISH provides a server-based alternative, i.e., your queries are executed on a server. The SWISH environment is much more evolved, providing notebooks, file storage including version control, file sharing, etc. SWISH supports a different set of features. Queries on SWISH are executed stateless and are limited by a sandbox.
- Ciao playground provides a WASM based version of Ciao Prolog.
- Tau Prolog provides a Prolog version completely written in JavaScript.
Raivo Laanemets did most of the ground work getting SWI-Prolog to run using WASM. Jesse Wright provides the npm package swipl-wasm. Torbjörn Lager created the first version of SWISH.