Live data from Hacker News

Making WebAssembly a first-class language on the Web

hacks.mozilla.org

241–250 of 287 posts

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

#241

The WASM cliff is very real. Every time I go to use it, because of the complexity of the tool chain and process of going from zero to anything at all, I feel like I'm already paying a cognitive tax. I worry that I should update my tooling, look into the latest and greatest, understand the tooling better, etc... It would be incredible to see that improved. The difference in perf without glue is crazy. But not surprisi…

The whole WASM thing just went sideways from the start. It feels like the property of being practically unreadable and unwritable for humans was a design criterium, it is certainly the primary "feature" enabled by the stack approach.

Then there is the single array of memory that makes modern memory allocators not really work, resulting in every WASM compiler scrounging up something that mashes the assumptions of the source language into a single array.

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

#242
post #235

This was supposed to happen already in the 2000s. JVM in everywhere, especially in the browser. There was Java rings you could wear, Java Card VM (JCVM), Squawk VM, Java ME. "Java the language is almost irrelevant. It's the design of the Java Virtual Machine. And I've seen compilers for ML, compilers for Scheme, compilers for Ada, and they all work. Not many people use them, but it doesn't matter: they all work." --J…

Java failed because of its security model - trying to run trusted and untrusted code in the same VM without a hard boundary - a given call is trusted if every call stack entry at the time of the call is in a trusted class. There were too many confused deputies - if you can set up a trusted object to make a call that requires trust later on without your involvement, then you have privilege escalation. The solution was…

Again: Microsoft. Microsoft actually promoted their own version of "fine-grained permissions" before Sun released JDK 1.2 just to make it incompatible. Customers did not care abut security. Microsoft provided shortcut to speed. Sun already lost.

Don't be surprised if Google adds something similar to Chrome for WASM.

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

#243

This (appears as though it) all could have happened half a decade ago had the interface-types people not abandoned[1,2] their initial problem statement of WebIDL support in WebAssembly in favour of building Yet Another IDL while declaring[3] the lack of DOM access a non-issue. (I understand the market realities that led to this, I think. This wasn’t a whim or pure NIH. Yet I still cannot help but lament the lost time…

The lack of DOM access IS a non issue. Nobody who uses webassembly wants anything to do with the web. The web is a pile of garbage.

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

#244

Earlier quoted context omitted.

Object references are pointers. WasmGC only supports pointers which point to the start of an object. However, some languages have features which require pointers that point inside of an object while still keeping that object alive. Limiting WASM to what is capable in JavaScript is quite a silly thing to do. But at the same time there are vastly different GC requirements between runtimes so it's a challenging issue. I…

> Object references are pointers I know this is pedantic, but they aren't. At least not in the sense of what it means for something to be a pointer. Object references are an identifier of an object and not a memory pointer. The runtime takes those object references and converts them into actual memory addresses. It has to do that because the position of the object in memory (potentially) changes every time a GC runs.…

> I'm not sure about C# (the only other language I saw with interior pointers). I think C# semi-recently switched over to a moving collector. In which case, I'm curious to know how they solved the interior pointer problem.

Objects references are just pointers in .NET. See the JIT disassembly below. It's been using a moving GC for a long time, too.

https://sharplab.io/#v2:C4LghgzgtgNAJiA1AHwAICYCMBYAUKgZgAIM...

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

#245
post #203

Say goodbye to writing multiple kinds of plugins and userscripts for random websites I guess. I don't want the transition to wasm because it looks like it will make most things unchangeable binary blobs

I don't follow? when you write userscripts you modify the dom not the already running scripts usually, no?

Wouldn't there be a point where the mainstream approach is to just have compiled blobs write directly to the canvas, say a point where someone compiles a qt application and hosts it on their website.

What can you even modify there, when all the structure is flattened into a single layer

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

#246

The web is fascinating: we started with a seemingly insane proposition that we could let anyone run complex programs on your machine without causing profound security issues. And it turned out that this was insane: we endured 20 years of serious browser security bugs caused chiefly by JavaScript. I'm not saying it wasn't worth it, but it was also crazy. And now that we're getting close to have the right design princi…

0-days mostly got expensive from compiler optimizations and other security guarantees that carry over to webassembly, like ASLR and pointer authentication, as well as sandboxes and multi-process architectures. It's not all thrown away here.

Browsers are millions of lines of code, the amount of UAFs, overflows, etc so far is not the bottleneck.

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

#247

Earlier quoted context omitted.

webassembly components use a borrow checking model[1], so I assume that would be used to manage DOM components? I'm not exactly sure how this works when binding it to GC languages. [1] https://component-model.bytecodealliance.org/design/wit.html...

This is my main confusion, too! I have an existing Wasm GC language implementation and I'm not sure how to reconcile it with the component model.

I would think you could treat it as a normal GC reference and then just drop the resource when the GC collects the object.

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

#248

Earlier quoted context omitted.

iirc webassembly components need to explicitly import anything they use, so it should be transparent which dependencies something has by just grepping its WIT for `import`

I wonder what a 'mixed model' would look like (e.g. is it even possible), e.g. an application which wants to call into component model APIs, but at the same time also needs to call into JS code which then accesses the same APIs. This hybrid model will definitely be needed for any non-trivial web application.

you can just expose javascript functionality as a component, if need be

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

#249

Earlier quoted context omitted.

> Object references are pointers I know this is pedantic, but they aren't. At least not in the sense of what it means for something to be a pointer. Object references are an identifier of an object and not a memory pointer. The runtime takes those object references and converts them into actual memory addresses. It has to do that because the position of the object in memory (potentially) changes every time a GC runs.…

> I'm not sure about C# (the only other language I saw with interior pointers). I think C# semi-recently switched over to a moving collector. In which case, I'm curious to know how they solved the interior pointer problem. Objects references are just pointers in .NET. See the JIT disassembly below. It's been using a moving GC for a long time, too. https://sharplab.io/#v2:C4LghgzgtgNAJiA1AHwAICYCMBYAUKgZgAIM...

Interesting. I wonder how C# handles the moving. I'm guessing it has to go in and fix up the pointers in the stack after a gc run? Or is this some OS level virtual pointer weirdness going on? How does C# guard against someone doing something silly like turning a pointer into a long and then back into a pointer again later?

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

#250

Earlier quoted context omitted.

I for one am thankful to them for it. I think we need a return to the real native. The JS/Web-slop has gone too far.

But the app-slop is totally fine right? Apple controlling every piece of software on my phone hasn't gone too far? Empowering the web to compete with Apple and Google's native locked down options is the only viable alternative I see.

Problem, as I see it, is that these "native locked down options" are very often just webpages in disguise, which is also webslop imo
Post reply on HN