NOP0 / rustmatic

PLC programming in Rust!
Apache License 2.0
35 stars 2 forks source link

Compile target(s) #13

Open NOP0 opened 4 years ago

NOP0 commented 4 years ago

What will be the compile target of 61131-3? Rust, some bytecode, etc?

NOP0 commented 4 years ago

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: )

Michael-F-Bryan commented 4 years ago

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.

Michael-F-Bryan commented 4 years ago

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.

NOP0 commented 4 years ago

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?