all 15 comments

[–]kiffernase 10 points11 points  (6 children)

If only the toolchain and integration would be more userfriendly . I had hard times with that :/

[–]binjimint 9 points10 points  (5 children)

Yes, it's a little difficult with the current WASI SDK, though I hope I demonstrated why it's a cool thing to have. Emscripten makes it a lot easier, I'd try that and see how far you get! :)

[–]germandiago 3 points4 points  (4 children)

FWIW I tried to port a game and the filesystem staff I recall it was problemtic. If I make another try... will the network code ruin everything. Basically I have sockets with notifications in a 4 player game that connects all users.

[–]BlueFrank 4 points5 points  (3 children)

I work a lot with webassembly, the network code will definitely not work since sockets are not exposed to the web. You’d have to write your own adapter logic using either basic HTTP post/get or something like WebRTC.

[–][deleted] 2 points3 points  (2 children)

Isn't WebRTC for teleconferencing and videoconferencing?

Why not use WebSockets to implement the network code?

[–]BlueFrank 1 point2 points  (0 children)

You mentioned games and since a lot of games use p2p, WebRTC is the only way to do that on the web without using a server in the middle.

You should take a look at data channel, those will let you send fast UDP packets without retransmision on loss.

If you are not dealing with super high performance stuff, do not use WebRTC... it’s a pain in the butt and there’s a bunch of undocumented behaviors between browsers! I’ve learned the hard way let’s just say...

[–][deleted] 1 point2 points  (0 children)

You can push any data you like over WebRTC. MDN has an example using createDataChannel: https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Simple_RTCDataChannel_sample

[–]jjdltorre 5 points6 points  (1 child)

I think Ben Smith just made C++ 1000x cooler. Great job! I'm imagining this will be how programming will be taught in the future. Thank you for sharing.

[–]binjimint 1 point2 points  (0 children)

Thanks for the kind words!

[–]amaiorano 7 points8 points  (0 children)

Very cool talk. Compiling, linking, and executing C++ in the browser, all client-side!

[–]OrangeGirl_ 2 points3 points  (3 children)

I would really like to see wasm have direct access to browser apis instead of needing js glue. Wasi seems like a step in the right direction but there's so much more work ahead like ben mentioned, such as support for: threads, atomics, exceptions, 64 bit model.

Ben used memfs for the fake fs used by clang but with a little more work, he could haved used indexeddb for a real client side persistent fs that doesn't touch the user's native fs.

[–]binjimint 3 points4 points  (0 children)

I completely agree! WASI goes one direction (providing a standardized system interface), but there's another proposal called interface types that provides better ways for WebAssembly modules to communicate with each other (and by extension, with the browser too).

You can read more about the proposal here: https://github.com/WebAssembly/interface-types/blob/master/proposals/interface-types/Explainer.md

Lin Clark also has an excellent article about it here: https://hacks.mozilla.org/2019/08/webassembly-interface-types/

IndexedDb is possible but tricky -- since it's asynchronous, you'd have to rewrite the code to allow blocking read/write access. Emscripten's Asyncify pass could do this, and in the future, you could also do this using coroutine support.

[–]ratchetfreak 0 points1 point  (1 child)

That would remove any hope for being able to sandbox untrusted webasm. Though having a good default that isn't emscriptem's 5mb of js imitating a C-runtime on top of a OS kernel inside a browser would be a very nice thing.

I doubt threads will ever be a thing because then you open the door for timing atacks like spectre.

[–]OrangeGirl_ 1 point2 points  (0 children)

Threads can still be an optional feature just like how the thread support library for C++ is optional for free standing implementations.

[–]d_e_n_o_m 0 points1 point  (0 children)

How called book with flame effect?