4 ms·
> WASM is not supported in the standard library. Would using the C output and using emcc on it solve this problem?
by benterix 1y ago
> WASM is not supported in the standard library.
Would using the C output and using emcc on it solve this problem?
- cb321 1y agoYeppers - https://github.com/treeform/nim_emscripten_tutorial https://github.com/treeform/nim_emscripten_tutorial FWIW, people have been doing that for about as long as there's even been an emscripten, but the article is pointing out the lack of more tight integration with stdlib/std compilation toolchains. I would say evolving/growing the stdib in general is a pain point. Both the language and compiler are more flexible than most, though. So, this matters less in Nim that it might otherwise.
- miguel_martin 1y agoTo be clear, you can compile to WASM with emscripten. However, if you want to call JavaScript code, e.g. to interact with the DOM from WASM in browser, then the bindings that are declared in the standard library will not work. Instead, you will need to write your own bindings. Here's an example repository of mine using emscripten with Nim: https://github.com/miguelmartin75/nim-wasm-experiments https://github.com/miguelmartin75/nim-wasm-experiments and here are bindings to emscripten's C API for websockets: https://github.com/miguelmartin75/nim-wasm-experiments/blob/main/src/jwebsockets.nim https://github.com/miguelmartin75/nim-wasm-experiments/blob/... With emscripten, you can create bindings to JavaScript using EM_JS macros, which you can emit in Nim. Here is an example of how to do so: https://github.com/treeform/windy/blob/bc98d4642c700f02775510094edcbef53b24a734/src/windy/platforms/emscripten/emdefs.nim#L13-L85 https://github.com/treeform/windy/blob/bc98d4642c700f0277551...