Looking through the code,y buest guess is the Motoko compiler has been compiled into Wasm, and can thus be used in node. Look at the versions/latest directory.
Azle could incorporate this at compile-time at least, Iām not sure the use case though.
The use case would be that a black-holed canister could compile open-source code in a dependable way, making sure that only āblessedā versions of canisters can be deployed. There are other ways of doing this of course, and Cover is trying to serve some of these use cases, but as we move toward DAOs and autonomous software, it would be cool if these DAOs could automate deployment, upgrades, or even create composable canisters on the fly. Imagine a DAO builder that lets you pick modules from a list and then compiles and deploys the DAO for you.
Yep! node-motoko uses js_of_ocaml under the hood, so everything is pure JavaScript.
@matthewhammer and I are currently working on a Rust interpreter for Motoko, which we are calling āMoVM.ā This is much closer to the metal compared to node-motoko (probably at least 2-3 orders of magnitude faster than js_of_ocaml running on Azle).
This project is very early in development, so it could still be worth looking into running the node-motoko compiler from an Azle canister. Here is the js_of_ocaml file (moc.js) which should contain everything you need if you want to try this experiment.
So the JS version of the Motoko compiler compiles Motoko to Wasm?
If so @skilesare this sounds possible to me. And hopefully it wouldnāt even need to be incorporated into Azle, you should be able to install it with npm. We just need to make sure that itās self-contained i.e. doesnāt rely on any APIs not available to a canister.
Another problem has to do with the next version of Azle, we have some buffer size issues with the way were handling some things, and because the node-motoko code is so large (~2mb) this causes problems.
Just checked back on this thread. The syntax error does seem like a bug with the Boa engine. It might be more feasible to run the interpreter (using motoko/versions/latest/moc_interpreter.min.js), although this would still be about 1.2 MB of generated code.
This was certainly worth a try! Iāll keep this in the back of my mind in case thereās a way to eventually make this work.
Once the Wasm binary limit is increased the 1.2mb should be a non-issue Iām hoping. The syntax error is interesting and I will look into it more later, maybe once the Wasm binary limit is lifted.