Live data from Hacker News

Making WebAssembly a first-class language on the Web

hacks.mozilla.org

121–130 of 287 posts

Re: Making WebAssembly a first-class language on the Web

#121

I'd really like to be able to run _any_ language in the browser. WASM is a great first step.

Internet Explorer used to support any language that Windows Script Host could run. By default, that was JScript and VBScript, but there were third-party engines for Python, Perl, Ruby, Lua, and many others. Possibly disabled now as they announced VBScript would be disabled in 2019.

This is exactly what we need!

Re: Making WebAssembly a first-class language on the Web

#122

Earlier quoted context omitted.

I really want stringref to make a comeback.

My god yes. I'm building a new Wasm GC-based language and I'm trying to make as small as binaries as possible to target use cases like a module-per-UI-component, and strings are the biggest hinderance to that. Both for the code size and the slow JS interop.

Yeah it's really frustrating and JS string builtins are not a good fit for me as I do not want to deal with 16-bit code units.

Re: Making WebAssembly a first-class language on the Web

#123
post #61

Earlier quoted context omitted.

What makes WASM execution riskier than JS?

Novelty - JS has had more time and effort spent in hardening it, across the browsers, WASM isn't as thoroughly battle-tested, so there will be novel attacks and exploits.

> JS has had more time and effort spent in hardening it

JS required the time and effort because it's a clown-car nightmare of a design from top to bottom. How many person-hours and CPU cycles were spent on papering over and fixing things that never should have existed in the first place?

This doesn't even count as a sunk cost fallacy, because the cost is still being paid by everyone who can't even get upgraded to the current "better" version of everything.

The sooner JavaScript falls out of favor the better.

Re: Making WebAssembly a first-class language on the Web

#124

Earlier quoted context omitted.

I don't think it's "much smaller" once you aim for feature parity (DOM). It might be more regular than an implementation of a higher-level language, but we're not getting rid of JS. By the same token, was Java or Flash more dangerous than JS? On paper, no - all the same, just three virtual machines. But having all three in a browser made things fun back in the early 2000s.

It is much smaller. WASM today has no access to anything that isn't given to it from JS. That means that the only possible places to exploit are bugs in the JIT, something that exists as well for JavaScript. Even WASM gets bindings to the DOM, it's surface area is still smaller as Javascript has access to a bunch more APIs that aren't the DOM. For example, WebUSB. And even if WASM gets feature parity with Javascript,…

I think even when WebAssembly has access to every API that JavaScript does, it's still architected in a way that I think is less likely to lead to sandbox escapes. The thing doing the sandboxing doesn't have the full complexity of a programming language; some of that complexity lives either in the compiler or inside the sandbox. Some things that would be vulnerabilities in JavaScript become "it rather involved being on the other side of this airtight hatchway" problems in WebAssembly.

Re: Making WebAssembly a first-class language on the Web

#125

Earlier quoted context omitted.

Probably needs to be fixed by bundling runtimes for things like Go, or bringing back cross-website caching in some secure way if that's possible

That's an orthogonal problem. First it needs to be possible and straightforward to write GCed languages in the sandbox. Second, GCed languages need to be willing to fit with the web/WASM GC model, which may not exactly match their own GC and which won't use their own GC. And after that, languages with runtimes could start trying to figure out how they might reduce the overhead of having a runtime.

> Second, GCed languages need to be willing to fit with the web/WASM GC model

Suppose the Go people make a special version of Go for Wasm. What do you think are the chances of that being supported in 5 years time?

Re: Making WebAssembly a first-class language on the Web

#126
post #116

Earlier quoted context omitted.

> Second, GCed languages need to be willing to fit with the web/WASM GC model I think most languages could pretty easily use WASM GC. The main issue comes around FFI. That's where things get nasty.

WasmGC doesn't support interior pointers, and is quite primitive in available set of operations, this is quite relevant if you care about performance, as it would be a regression in many languages, hence why it has largely been ignored, other than the runtimes that were part of the announcement.

Oh interesting.

In java land the fact that you effectively don't have pointers but rather everything is an object reference, this ends up not being an issue.

I wonder if the WASM limitation is related to the fact that JavaScript has pretty similar semantics with no real concept of a "pointer". It means to get that interior pointer, you'd need to also introduce that concept into the GC of browsers which might be a bit harder since it'd only be for WASM.

Re: Making WebAssembly a first-class language on the Web

#127

Do programmers actually write in wasm or automatic tools port/compile other languages to wasm?

It's mostly Rust compiled to wasm binaries. There's also TinyGo and you could use C/C++ as well, but those 3 are a lot less common as far as I can tell.

Re: Making WebAssembly a first-class language on the Web

#128

Do programmers actually write in wasm or automatic tools port/compile other languages to wasm?

I wouldn't generally use hand coded WASM in production, but I've used it for educational purposes [1], and just because I'm perhaps a bit perverse [2][3] (3 includes some helper utilities in Common.ts).

[1] https://exercism.org/profiles/mikestaas/solutions

[2] https://github.com/mikestaas/wasmfizzbuzz/blob/main/fizzbuzz...

[3] https://github.com/mikestaas/walox/tree/main/src

Re: Making WebAssembly a first-class language on the Web

#129

Earlier quoted context omitted.

That's an orthogonal problem. First it needs to be possible and straightforward to write GCed languages in the sandbox. Second, GCed languages need to be willing to fit with the web/WASM GC model, which may not exactly match their own GC and which won't use their own GC. And after that, languages with runtimes could start trying to figure out how they might reduce the overhead of having a runtime.

> Second, GCed languages need to be willing to fit with the web/WASM GC model Suppose the Go people make a special version of Go for Wasm. What do you think are the chances of that being supported in 5 years time?

I think it'd be supported by them the moment they ship it. Whether others will be excited to use it is an open question. There's no central registry of "languages supported for WebAssembly", by design; it supports any language that can compile to standards-compliant WebAssembly.

Re: Making WebAssembly a first-class language on the Web

#130
post #63

Earlier quoted context omitted.

You can already compile malware to obfuscated asm.js. If anything, WASM blobs are easier to reverse engineer than obfuscated JS - good luck writing a ghidra plugin for JS source.

What about obfuscated WASM blobs? At least obfuscated JS is still basically source code being interpreted, with WASM we will be running proprietary obfuscated binaries in the browser.

Obfuscated javascript could still import a WebAssembly polyfill, if there really was any advantage in doing so: https://github.com/evanw/polywasm

Since WebAssembly instructions are much easier to reason about, you could probably auto-optimize away a lot of the obfuscation, like "this is a silly way to do X, so we can just do X directly".

Post reply on HN