[Lazarus] WebAssembly support for DOM access

Michael Van Canneyt michael at freepascal.org
Sun Sep 4 11:39:57 CEST 2022


Hello,

Thanks to the sponsoring by Tixeo, the FPC & Lazarus team has developed a
pretty unique feature for the FPC WebAssembly support.

Webassembly is a bytecode format and embedding specification that allows you
to load and run compiled code into the browser in a restricted environment. 
It is supported by all major browsers.

You can also run webassembly bytecode in command-line tools such as wasmtime
or even in an FPC program, using the wasmtime library.

By itself, WebAssembly has no access to its environment. It can only use
what the environment provides: file access, DOM acces etc. If the
environment defines it, WebAssembly can use it. The webassembly
specification only defines a mechanism to import/export routines from/to the
environment in which it runs.

The browser has a rich environment, which it does not (yet) expose to the
WebAssembly world. Which is a pity, because this limits the usefulness of
WebAssembly in the browser considerably.

FPC has now developed a protocol which allows you to use all Browser APIs by
the JOB (Javascript Object Bridge) mechanism, in particular the DOM
functionality.

This allows you to build a UI (using HTML) for webassembly programs
running in the browser: one can imagine running Lazarus in the browser...

More info about this unique feature can be found in the Wiki:

https://wiki.freepascal.org/WebAssembly/DOM

To my knowledge, the only other programming language to offer this kind of 
general support for browser API access from webassembly is Rust.

Enjoy,

Michael.


More information about the lazarus mailing list