logoalt Hacker News

apatheticonionyesterday at 10:08 PM3 repliesview on HN

Agreed. This and (sane) access to multi-threading. I want to be able to write a Rust application, compile to wasm and load it with

    <html>
    <body>
        <div id="root"></div>
        <script type="application/wasm" src="./main.wasm"></script>
    </body>
    </html>
Would be great for high performance web applications and for contexts like browser extensions where the memory usage and performance drain is real when multiplied over n open tabs. I'm not sure how code splitting would work in the wasm world, however.

v8 could be optimized to reduce its memory footprint if it detects that no JavaScript is running - or wasm-only applications could use an engine like wasmer and bypass v8 entirely.

Another factor is that web technologies are used to write desktop applications via Electron/similar. This is probably because desktop APIs are terrible and not portable. First class wasm support in the web would translate to more efficient desktop applications (Slack, VSCode, Discord, etc) and perhaps less hate towards memory heavy electron applications.


Replies

kketchtoday at 9:46 AM

You can do all of this using Rust today. Very sane access to multi-threading => writing rust code that runs in parallel and is compiled without you worrying about it to run under several web workers

cesarbyesterday at 10:48 PM

> <script type="application/wasm" src="./main.wasm"></script>

<applet code="./Main.class"></applet>

Plus ça change...

show 1 reply
jesse__yesterday at 11:16 PM

Not sure what the Rust situation is like, but last I checked (and compiled a non-trivial personal application) WASM supported the pthreads API and it seemed to work reasonably well. Have you encountered stumbling points porting a heavily MT Rust program to WASM?

show 3 replies