3 ms·
I would advocate for making browsers run Typescript, but WASM is just another compiler, just like Typescript. Whatever you're afraid of by using transpilers is
by jeroenhd 3y ago
I would advocate for making browsers run Typescript, but WASM is just another compiler, just like Typescript. Whatever you're afraid of by using transpilers is much worse to debug and resolve once you've compiled it to a blob of binary code. If you can trust the Python interpreter, you can trust the Typescript transpiler. Things become a little complicated to debug when you're stuck dealing with crap like IE11 or various older Safari versions, but we're not living in 2010 anymore.
Javascript is terribly inconvenient and has tons of weird edge cases ("semicolons are optional except for these three edge cases", scope switching through using, the unpredictable type conversions) but the rules aren't that hard to write a transpiler for. Transpiling another language into JS will probably leave some optimisations on the table (by reimplementating methods in a way another language expects rather than calling the native Javascript API) but at least it has the normal API to rely on.
WASM is like Docker; it works on my machine, I can't get it to work on your machine, so we'll ship half of my machine and call it even. You're shipping standard libraries and JSON parsers to a browser as if you're pushing code to a bare metal server.
Javascript isn't a hard language to learn and neither are HTML or CSS. What I see many WASM people want to do is write browser code without ever needing to learn how the browser works. That's a terrible idea that will only end in either bloat or broken abstractions. "Let's make backend devs do frontend" is how we ended up with Java applets everywhere, which barely worked inside the context of a desktop browser, let alone on touch screens and phones.
There's a reason "native" desktop development has become "run an outdated copy of Chrome with some OS glue", and it's that web development is easy compared to native frontend development, especially if you target multiple platforms. WASM isn't going to turn backend developers into frontend developers overnight, you'll be stuck learning new frameworks and barely usable tooling regardless.
Just use JS, it's inconvenient but much a much better option than the proposed alternatives.