Edwin Yip 154 Posted April 17, 2021 (edited) And here is the link of the github project: Wasm by marat1961. @Arnaud Bouchez ;) Just in case you didn't know, WASM is a subject of JavaScript that's optimized for speed and cross-platform. Edited April 17, 2021 by Edwin Yip 1 Share this post Link to post
pyscripter 689 Posted April 17, 2021 (edited) 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 April 17, 2021 by pyscripter 1 Share this post Link to post
Andrea Raimondi 13 Posted April 18, 2021 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 Posted April 18, 2021 (edited) 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 April 18, 2021 by Guest Share this post Link to post
Arnaud Bouchez 407 Posted April 18, 2021 (edited) 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 April 18, 2021 by Arnaud Bouchez 2 Share this post Link to post
Der schöne Günther 316 Posted April 18, 2021 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. Share this post Link to post
David Schwartz 426 Posted April 19, 2021 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
Stefan Glienke 2002 Posted April 19, 2021 (edited) 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 April 19, 2021 by Stefan Glienke Share this post Link to post
Der schöne Günther 316 Posted April 19, 2021 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