←back to thread

160 points todsacerdoti | 5 comments | | HN request time: 0.001s | source
Show context
peutetre ◴[] No.41903189[source]
With WebAssembly getting better both on the client side and the server side, when WebAssembly achieves better performance than JavaScript, and when with WebAssembly you have the opportunity to use almost any other language, why would you use JavaScript?
replies(2): >>41903247 #>>41911674 #
bastawhiz ◴[] No.41903247[source]
On the server, you wouldn't choose wasm, you'd choose a language that compiles to wasm. Which is really just saying "choose another language": there's no point in compiling (e.g.) Rust to wasm just to run it with Node on the server.
replies(1): >>41903330 #
peutetre ◴[] No.41903330[source]
You'd choose wasm on the server if you're using a framework that supports it. For example:

https://blog.nginx.org/blog/server-side-webassembly-nginx-un...

https://github.com/WebAssembly/wasi-http

Write in any language, compile to WebAssembly, have it run on the server no matter what the server's CPU architecture, achieve better performance with high compatibility.

replies(2): >>41903501 #>>41905402 #
1. bastawhiz ◴[] No.41903501[source]
Why in the world would you compile to wasm and make your code slower instead of just compiling to native code? To your example: you don't need nginx to talk to wasm, it already talks to your code running on a local socket.

The only reason for wasm is portability. If you can't compile your code for the server you're going to be running it on, then the original argument of choosing wasm over JavaScript is already moot.

replies(1): >>41903522 #
2. peutetre ◴[] No.41903522[source]
> instead of just compiling to native code?

Because the managed service you signed up to doesn't offer that to you. They like WebAssembly modules because it's a sandboxed runtime.

replies(1): >>41903915 #
3. bastawhiz ◴[] No.41903915[source]
It's an awfully silly choice to use a managed service that only offers JavaScript and wasm if you don't want to use JavaScript and you care enough about performance that you're willing to accept the fairly meager benefits of wasm over JS. The real reason you'd choose wasm in this case is "I don't want to use JavaScript and I'm otherwise forced to use this service".
replies(1): >>41903936 #
4. peutetre ◴[] No.41903936{3}[source]
Or the price is right.

Come on down! Use WebAssembly. You'll love it.

replies(1): >>41905380 #
5. jart ◴[] No.41905380{4}[source]
Use Plinko https://github.com/jart/cosmopolitan/tree/master/tool/plinko

Back in the 1980s it was my greatest ambition to go on The Price Is Right and play Plinko. However all I could accomplish was making this cursed programming language instead. You'll love it.