Elm and WASM can they talk?

@elmlang is it possible to integrate something like emscripten with elm? Can elm interact with this technology directly or will I have to default to javascript? Can I instantiate a wasm module from elm and import wasm functions to elm?

You can’t call Wasm functions from inside Elm code (you can’t do that with JS either). Instead you’d need to use ports to pass messages out of your Elm app to some JS code which can then do whatever it wants, which in your case would be calling Wasm.

1 Like

Oh wow thanks. By the way you can actually call functions written in C/C++ in js by using imports.

Sorry if I was a bit vague with my wording.

How does that work exactly?

From MDN docs: WebAssembly/Loading_and_running it says:

WebAssembly is not yet integrated with <script type='module'> or ES2015 import statements, thus there is not a path to have the browser fetch modules for you using imports.

And then it goes on to explain the approaches to loading, instantiating and running the code.

What are you referring to?

https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html. I was referring to emscripten. Again sorry for my vagueness.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.