all 1 comments

[–]filbs111 1 insightful - 1 fun1 insightful - 0 fun2 insightful - 1 fun -  (0 children)

I tried Webassembly. Wrote something in javascript, took a long time to run. Ported it to C and compiled to WebAssembly. In javascript, i'd used the standard convenient stuff - pushing onto variable sized arrays, array map, filter etc. Writing in C without that stuff took longer, and the code is harder to read, but the result was hundreds of times faster than the javascript to run, and not far off "native" C, which sounds like a big win for WebAssembly. However, I then ported the C back to javascript by hand, keeping linked lists, using typedarrays. Result was almost as fast as the WebAssembly version.

As a result, I've decided to just write better javascript where it matters. The build step and harder debugging isn't worth the hassle in my use case. (stuff that runs in a browser)

WebAssembly is probably very useful for something like a physics engine, and if you prefer writing a language other than javascript, or have an existing codebase in another language.