←back to thread

160 points todsacerdoti | 1 comments | | HN request time: 0s | 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 #
ndriscoll ◴[] No.41905402[source]
A quick skim suggests that this framework re-inititalizes the sandbox on each request (so there's no shared context across requests). That's not going to achieve better performance.
replies(1): >>41906808 #
peutetre ◴[] No.41906808{3}[source]
Phew! Thank goodness you skimmed it! For a minute there I thought the NGINX developers knew something you didn't.
replies(1): >>41908203 #
1. ndriscoll ◴[] No.41908203{4}[source]
I'm basing my statement on what they wrote:

> The WebAssembly sandbox’s linear memory is initialized with the HTTP context of the current request and the finalized response is sent back to the router for transmission to the client.

They can feel free to clarify that multiple requests can concurrently use a shared context as well if that's true. Or if that's not true, then the thing will of course be slow assuming it needs to do some kind of IO like a database request.

Note that major FaaS implementations like AWS Lambda don't let you have concurrent requests that share context, so it's not exactly crazy to think this wouldn't either.