Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

As a sidenote, does anyone know how this emscripten stuff works? I understand how you can compile down to a different language, but is there a shim layer that converts OS level API calls to browser APIs? Or is it lower level than that? Either way, that sounds like a massive undertaking and it blows my mind that any of this is even possible.


Came here to ask exactly this question.

Further, and I don't even know if this question is a meaningful one, but are there any curated lists of libraries known to work with wasm, or do you just compile something and hope for the best? I'm curious if there are any gaming-oriented sound libraries known to work well, and with bindings to Rust? I'm a blind developer with a casual interest in building audio games, a niche gaming genre that's basically what it (har har) sounds like. Unfortunately, much of what is available is Windows-only, and I'm a Linux user. But increasingly over the past few years, the web has struck me as a great platform for building these sorts of games. You don't need a powerful CPU for one thing, and the browser's built-in TTS APIs abstract away one of the biggest platform hurdles. There really isn't a good cross-platform hook into text-to-speech systems, and often you need speech presented in ways that clash with how screen readers work.

Anyhow, I've been wanting to experiment with multi-player gaming, and Rust's new wasm support along with Firefox 52's inclusion seems like a nice bit of synchronicity. If only I could find a good audio library known to work, particularly something with spatialization.

And yes, I do know about the Web Audio API, but was disappointed to learn that its panner nodes don't support more than 2 speakers. That said, I don't know if there are any wasm-compatible libraries that'd work with Rust and support 5.1. I'm also looking for a fun project to use Rust with, and an audio game that uses the strengths of both the web and Rust might be just the thing.

Pardon the diversion, but I'm stupidly excited about using the browser as a cross-platform runtime via a language more sane than JavaScript. :)


I've written a blog post about some (C/C++) libraries I found working well in asm.js/wasm:

http://floooh.github.io/2016/04/09/oryol-3rd-party-code.html

All the C libraries in there should be trivial to integrate with Rust, the C++ libs might be a bit more complicated though.

For audio, I can recommend SoLoud, it's multiplatform and also works well in asm.js/wasm (and doesn't add much size):

http://sol.gfxile.net/soloud/


> are there any curated lists of libraries known to work with wasm

I'm not aware of any specifically, but I do know at least one Rustacean who has been playing with this tweeted something like "I'm surprised but these 80 crates i've been using for advent of code work out of the box with wasm". So we'll see!


Emscripten maintains a collection of ports specifically for using with asm.js/wasm: https://github.com/emscripten-ports

It's a bit spare, and certainly not comprehensive. I've personally gotten ICU and jsoncpp working with minimal effort. Basically if the library has good cross platform support it should work.


There's a bunch of maps or polyfills you can use to communicate with external features. Things like WebGL for example. So it just maps those calls to whatever functions you can provide. Or if your C code uses the file system, you can either pick a virtual file system (for web code) or a real file system (for node applications).

The opposite is also true - you have a html5.h header file you can reference to do DOM/browser manipulations from your native code.

It's pretty fascinating.





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

Search: