Second demo up!
There are two programs in this demo: a driver program loaded by the demo page, that then loads the worker program. The worker program runs SQLite operations in a separate thread, away from the web browser's main UI thread, keeping the browser responsive.
Tags: Pascal, SQLite, WebAssemblyHappy Chinese New Year! Today is the first day of the year of the Fire Horse.
I've put up a demo of pas2js invoking WebAssembly SQLite.
In this demo, the pas2js program's SQLite database operations run in the web browser's main UI thread. Reload the web page if the output doesn't appear automatically; this may have to do with caching by your web browser, caching cleverness by HTMX, reverse proxy caching on my site, or other web weirdness.
The next demo's program will do its database work in a separate worker thread.
Tags: Pascal, SQLite, WebAssemblyWebAssembly (abbreviated Wasm) is "a binary instruction format for a stack-based virtual machine. Wasm is designed as a portable compilation target for programming languages, enabling deployment on the web for client and server applications." Currently, all major web browsers support Wasm. Standalone and embeddable Wasm runtimes also exist that allow running Wasm programs outside of the web browser.
So far, Wasm seems be have been of more interest among the AOT compile-to-native programming languages. Free Pascal, which works across a large number of processor architectures, operating systems, and embedded platforms, also support Wasm compilation targets; see this wiki page on setting it up. Additionally, Free Pascal also comes with a Pascal-to-Javascript transpiler known as pas2js.
I've put up a reworked Free Pascal Wasm demo of Conway's Game of Life. The game play was implemented by Dmitry Boyarintsev, in Pascal, and compiled to Wasm. The user interface is implemented by me, in Pascal, and transpiled to Javascript. For good measure, I've included a simple web server, also implemented in Pascal, that serves the Wasm, Javascript and other static content.
So, to build all Pascal programs in the demo from source, three Free Pascal compilation targets are used:
Here's a screenshot of the user interface running on my desktop web browser in mobile-responsive mode:
