Please share your experience of what you were able to build using WebAssembly.
Sorry, missed the request. Some words about WA experience:
Being inspired by Screeps, I was looking for a scalable, high performance and virtualization-friendly solution for Screeps-like AI environment. The candidates were Lua (provides high performance virtual machine and a simple script language) and WA (extremely high performance + built-in virtualization by design). Well, Python should be mentioned here: it's very difficult to build a bulletproof VM for it, and its performance without dirty hacks is really bad. I realized that Lua is not popular enough to be a main language for AI describing and developing, so WA was chosen.
There were several underwater rocks while implementing scalable architecture of shared AI sandboxes:It was difficult to find a compromise between API flexibility, performance and environment restrictions ("Game map as a shrared mmaped raw memory? Awesome, but memory protection? Map updates? Synchronization?") For now it's still not very comfortable to perform IPC with WA (message queue layer was written as dirty mix of WA API, JS and native C++ -- this layer and its endpoints seems for me overcomplicated, but all the workarounds are using pretty same API calls, and I've found the performance of portable robust solution is not very nice due to tons of unnecessary memory copying). Memory mapping and sharing (mmap or shmem etc.) are sometimes broken due to unexpected Node or WA restrictions. Due to environment restrictions, it's very difficult to debug native modules or write correct test suits. Moreover, I'm not sure about C++11 exception support by WA nowadays. So, it's extremely easy to hang or drop native module... or even write a malicious code due to leaky Node + WA API and permissions vulnerabilities -- it still seems not safe enough.
Because of points mentioned above, I've found WA modules are very useful for "dense" computational (some difficult algorithmic code with few inputs and outputs), but not flexible enough to be a full replacement of JS in most egine's cases despite on performance benefits. For now my project is frozen, but I've got tons of experience, and gonna return to it later with new vision and experience (and may be some followers:).
@artch: Thank you for reply!
It's an option to write critical code natively to increase your script's performance.
Nice idea, imho. Endpoints and synchronization problems are still difficult (see above), but it can really increase performance.
All APIs in the WebAssembly namespace are exposed to the user space in full.
It's a disputable point due to safety problems, but still nice for beginning. Offtop: Screeps community is really very nice here to not to abuse or even looking for vulnerabilities, and report them:)
Actually, WebAssembly object is exposed by default on Node 8.x, so I don't think it is really that breaking.
Oh, it's nice, but I'm mostly about safety underwater rocks (and, as you pointed out, about rewriting critical code).