[fpc-pascal] What is webasssembly?

Michael Van Canneyt michael at freepascal.org
Thu Oct 12 11:34:00 CEST 2023



On Wed, 11 Oct 2023, Steve Litt via fpc-pascal wrote:

> Michael Van Canneyt via fpc-pascal said on Wed, 11 Oct 2023 08:27:35
> +0200 (CEST)
>
>> On Tue, 10 Oct 2023, Steve Litt via fpc-pascal wrote:
>>
>>> What is webasssembly?
>>
>> A bytecode format (similar to what is used in Java and C# runtimes)
>> which is an open standard and which runs in all major browsers or in a
>> host application.
>
> Does this mean I can code an application in Pascal and use webassembly
> to turn it into a web application? If so, could you please point me to
> some simple examples?

Careful, there is no 'simple' in webassembly :-)

Basically, yes, this can be used to run a pascal program.

At the moment, all console applications will work in the browser, 
except for input, unless you use pre-prepared input.

Most packages in FPC that do not rely on external libraries will compile.

For demos:

In the pas2js project, there are demos under the 'wasienv' directory. 
You can adapt the helloworld example to load any .wasm file you want:

https://gitlab.com/freepascal.org/fpc/pas2js/-/tree/main/demo/wasienv/simple

You can do graphics using a HTML canvas (see the canvas demo), 
you can also manipulate the DOM. (see the job_* units in the 'dom' demo)

You cannot (yet) write a Lazarus LCL program and compile it to webassembly.

For those that also use Delphi, I'm currently working on porting FMX to 
Webassembly for my job, to be able to make full-fledged UI programs. 
The outcome is as yet uncertain, but we think it should be doable.

Michael.



More information about the fpc-pascal mailing list