Jump to content
Edwin Yip

WASM engine in pure Pascal - an interesting open source project to watch!

Recommended Posts

9 hours ago, Edwin Yip said:

Just in case you didn't know, WASM is a subset of JavaScript that's optimized for speed and cross-platform.

Not quite.  WebAssembly (WASM in short) is a binary executable format supported by all major browsers.  See WebAssembly.

Quote

WebAssembly (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.

 

Various compilers of different programming languages produce WASM code.   Fpc is already moving ahead with support for Webassembly target. See WebAssembly/Roadmap - Lazarus wiki (freepascal.org).  Overall WebAssembly is an alternative to compilation to JS.  .Net has already a WASM target they call Blazor.

Edited by pyscripter
  • Like 1

Share this post


Link to post

I would be very interested in something like this if there were clear demos and examples on how to use this properly.

I would be especially interested in "working demos" such as UI pieces etc. I know you can do this with TMS and JavaScript or a host of other options (such as Smart Pascal or Quartex) but they all revolve around the very insecure NodeJS and I want nothing to do with that. 

 

So... something that doesn't use that would be welcome in my mind. 

Share this post


Link to post
Guest
3 hours ago, Andrea Raimondi said:

I would be especially interested in "working demos" such as UI pieces etc. I know you can do this with TMS and JavaScript or a host of other options (such as Smart Pascal or Quartex) but they all revolve around the very insecure NodeJS and I want nothing to do with that.

There's an option of running WebAssembly via ChakraCore. I've blogged about it here: WebAssembly with Delphi and ChakraCore. There's source code for Delphi 7 or higher and Free Pascal 3.0.4 or higher.

It should be possible to use V8 or SpiderMonkey in a similar way. I haven't tried this.

I also know of some WebAssembly runtimes like wasmtime and wasmer (these two are both written in Rust) but unfortunately their C-style API is still incomplete (even the API spec itself is still work in progress)...

Edited by Guest

Share this post


Link to post

Without a JIT, I don't see any much interest for WebAsm, to be honnest...
I know that https://github.com/wasm3/wasm3 projects are good enough to run most simple processes.
Having a Delphi version - sad it is not FPC compatible - is a good idea. Even if it is Wintel only.
 

In terms of interpreting some logic, with proper sandboxing, a transpiler from other languages to JavaScript could be of a better interest, since most high-level features (like object mapping/dictionary, or strings) are already coded in compiled/native code.

Since everyone is throughin away references, take a look at https://github.com/saghul/txiki.js coupled quickjs (fastest interpreter, but slower than Chakra, V8 or SM) and wasm3.  🙂

 

Edit: the FPC webassembly backend is more a proof of concept, just like the LLVM backend - on which it is based somehow, at least to produce the binary output. It lacks some pascal features, and is not ready to be used on any project sharing the same code than regular FPC pascal code. Also in this respect, the JavaScript FPC transpiler is much more advanced and usable.

Edited by Arnaud Bouchez
  • Thanks 2

Share this post


Link to post
9 hours ago, Der schöne Günther said:

A lot of Delphi code (at least the one I deal with) is often plagued by VCL or Windows platform dependencies. Not going to run in a browser anyway.

You might want to look at TMS WebCore running on VSC.

Share this post


Link to post
3 minutes ago, David Schwartz said:

You might want to look at TMS WebCore running on VSC.

While it certainly looks impressive and pas2js has come a long way it is still far from being able to just take your existing code (non VCL dependant of course) and compile/run that.

Edited by Stefan Glienke

Share this post


Link to post
5 hours ago, David Schwartz said:

You might want to look at TMS WebCore running on VSC.

Yes, I had seen that, and it looks incredibly capable and powerful. If I had a use case, I would certainly try it out.

 

I was just trying to say that, unless you already had completely platform and UI-independent Pascal code (and a use case for it), I don't really see what you would use it for. A bit like a solution, still looking for a problem.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×