3 ms·
For me, the showstopper regarding WebAssembly is that browsers do not support a textual version that I can just throw in where I want to hand optimize a functio
by TekMol 6y ago
For me, the showstopper regarding WebAssembly is that browsers do not support a textual version that I can just throw in where I want to hand optimize a function.
If I could just replace my slowest Javascript function with handcrafted WebAssembly code, that would be great.
But having to dabble with external compilers and splitting my code into multiple files is too much of a burden.
- candiodari 6y agoShouldn't be too hard to make a library that would allow this. Would you be interested in that ? So let's say something like the following example, would you use it? This should be possible: <script src="some.url/gopherjs.js"> <script type="application/golang"> package main import "fmt" func main() { fmt.Printf("yeah baby\n") // Effectively console.log } </script> Obviously this would take more than a bit of time to start up (seconds), but the idea is of course that you don't do this once you deploy to production, and replace by inline webassembly.
- TekMol 6y agoI would surely try it out! What is "inline webassembly"?
- candiodari 6y agoWebAssembly.instantiate(new Uint8Array([0,97,115,109,1,0,0,0,....], { type: 'application/wasm' }); Inline webassembly = directly specifying the wasm binary inside of the html or javascript file.
- kevingadd 6y agoYou can pretty easily just ship a 1kb .wasm module and load it and export a function from it to call from JS. Of course, then all your data needs to live in wasm-accessible memory, and you can't use strings or objects anymore...