rustmatic
rustmatic copied to clipboard
Compile target(s)
What will be the compile target of 61131-3? Rust, some bytecode, etc?
How difficult is wasm as a target vs. some "dumbed down" Rust (like some languages compiling to Javascript or C)?
As an inexperienced person I would assume that you would have to deal more with register allocation and other low-level stuff in wasm than in a high level compile target like Rust?
But there surely has to be advantages of targetting wasm also? (Besides the cool fact of running a plc in your browser! :wink: )
I'd prefer to use WASM as a compilation target because there are already libraries which can compile to it (e.g. LLVM and Cranelift) plus runtimes which are capable of executing WASM code and letting it call Rust functions (e.g. wasmer, Lucet, and wasmtime).
It wouldn't be difficult to generate a C header file containing the intrinsics guaranteed to be provided by the runtime, and then instead of writing programs using IEC, you could write them in C or C++.
It also (in theory) allows us to create a runtime which can run in the browser. Which, in terms of demonstration ability, is 100x better than alternative PLC runtimes.
In https://github.com/Michael-F-Bryan/rustmatic/pull/23/commits/136a420d6009277dfcc1c055b3e80dfc677ea523 I started playing around with a "standard library" which can be compiled to WASM and linked with all IEC programs to provide higher-level functionality.
In 136a420 I started playing around with a "standard library" which can be compiled to WASM and linked with all IEC programs to provide higher-level functionality.
Would it be good if I stubbed out the interfaces of the standard functions I know of? Just fill with unimplemented?