Hacker News new | past | comments | ask | show | jobs | submit login

What are you writing the games in?



C++ with a little bit of JS glue to interact with web APIs, https://florr.io


Wouldn't code written in JS be just as fast after being turned into wasm?


You can't really turn Javascript into WASM without also compiling the whole Javascript runtime to WASM because of Javascript's highly dynamic nature.

You could use a more restrictive Typescript subset like https://www.assemblyscript.org/ though.

Also languages like C, C++ or Rust let you exactly define the layout of data on the heap, which is crucial for performance (look up data-oriented-design), and WASM preserves this in-memory layout (since it uses a simple linear heap, like C, C++, Rust, etc... but unlike Javascript, C# or Java). Achieving something similar in a high level language like Javascript would involve mapping all application data into a single ArrayBuffer "pseudo heap", and at that point, it's easier and more maintainable to do the same thing in C (or C++ or Rust).

Having said all that: modern Javascript engines can perform surprisingly well (in general I'm seeing that Javascript performance is underrated, and WASM performance is often overrated - sane Javascript, WASM and native code can all be in the same performance ballpark, but native code usually has the most "optimization potential").


Assemblyscript is unfortunately not that fast (yet?), same as javascript in most cases, also because it uses a garbage collector.

"in general I'm seeing that Javascript performance is underrated, and WASM performance is often overrated - sane Javascript, WASM and native code can all be in the same performance ballpark, but native code usually has the most "optimization potential""

And strong disagree. Javascript is indeed quite fast, but if you use a native compiled wasm libary in the right way (avoiding too many calls to wasm and back) - you will get a worlds difference in performance.


> avoiding too many calls to wasm and back

Well yeah, that because each call is basically an "optimization barrier" for the compiler (on both sides of the call), and of course the call itself also adds overhead, although that has been drastically reduced over the years.


No, because the semantics of JS aren't amenable to producing fast wasm.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: