With many ongoing discussions and requests of JavaScript and WebAssembly support for V and the misunderstandings that it doesn't exactly exist yet (or a clear path doesn't yet exist), I believe it is important to have a semi-formalized discussion and presentation of this information for V.
Should we put something on the main site and / or within the README.md?
There is ongoing discussion in Discord. And @prime31 has shared what works for him:
for VS Code users this task will get wasm going for you (pretty_c can be slow if you're codebase if over 20 - 30k lines so drop it if you dont need it):
{ "label": "v generate c (WebGL)", "type": "shell", "options": { "cwd": "${fileDirname}" }, "command": "v -pretty_c -d webgl -o ${fileBasenameNoExtension}.c ${fileBasename} && cat <(echo \"#include <emscripten.h>\") ${fileBasenameNoExtension}.c > wasm.c", "group": "build", "problemMatcher": [] }
Any thoughts on formalizing this information and making it all more clear and convenient to inbound V learners and contributors?
Just a note: "JavaSacript" should be spelled "JavaScript"
@medvednikov responded somewhere in the thread that it might be possible to have a -wasm or -os wasm option or something similar, so that v would take care of the boilerplate code for you. No need for extra VS Code macros or anything else. v would also call the C compiler with the proper options so everything would be done.
Right, I think it's just a matter of someone just trying their hand at implementing this right now @JalonSolov. If I recall correctly there was an easy way to do this at one point long ago (circa last July?), but seems to have gone away.
Something done by @Zambonifofex, mentioned here in Discord:
https://github.com/Zambonifofex/v-wasm
dupe #737
& good job @Zambonifofex !
https://twitter.com/v_language/status/1262450417562157062
This is not a dupe of #737. This issue is for discussing the way to implement #737 or otherwise get wasm support into V.
Most helpful comment
dupe #737
& good job @Zambonifofex !
https://twitter.com/v_language/status/1262450417562157062