top | item 47167944

Making WebAssembly a first-class language on the Web

44 points| mikece | 3 days ago |hacks.mozilla.org

12 comments

order

dfabulich|3 days ago

Today, the entire Web API is defined in WebIDL, a specification-only interface-definition language that inherently assumes you have access to JavaScript strings, objects, exceptions, promises, etc. None of those are available in WASM.

WebAssembly Components aren't nearly enough to accomplish what this article offers to accomplish. Even once components are a thing, you'd then have to restandardize the entire Web API in their new IDL, WIT.

The WebIDL specifications have taken decades to standardize. It requires Apple, Mozilla, Google, and Microsoft to agree on everything. Getting all of them to agree to restandardize on a new IDL is not going to happen this decade.

eqrio|2 days ago

The article was too long already to get into this, but it's a good question. Getting browser vendors to standardize a new IDL is a non-starter. My personal preference is to derive WIT/component interfaces from WebIDL, and I've done enough research to believe it's feasible. I'll talk about that more in the future. There are some other options too if that is a dead end.

mendyberger|3 days ago

Is `component {}` valid wit syntax? I've never seen that before

thesmart|3 days ago

WebAssembly is amazing, but I don't think making it a DOM controller is where the action is. What specific scenarios do you aspire to unlock and why would those scenarios lead to broader adoption?

bvisness|3 days ago

> I don't think making it a DOM controller is where the action is

Why not? I feel like people have gotten so used to the limitations of WebAssembly today that they've internalized JS as the only answer. But I don't really like JS, and would love to build web apps in other languages, and I totally would if it wasn't a huge pain (and slower too!)

justinclift|2 days ago

Being able to program modern websites without having to learn javascript/typescript in any way? :)

mendyberger|3 days ago

> What specific scenarios do you aspire to unlock

Modern languages come with lots of interesting features like better dev ex, null safety, etc. Js is a fine language, but there are other languages that bring unique advantages, the web shouldn't block developers from using better tools. The web is best off when developers have freedom.

yoshuaw|3 days ago

I think it's less about unlocking new scenarios per se, and more about making existing scenarios better. If given the choice I'll generally prefer to write my code in Rust. But with native Wasm Component-based DOM bindings that same code will now run twice as fast.

nilslice|3 days ago

providing <script type="module" src="component.wasm"></script>

and the import loader to just put .wasm in an import and get to call functions are the actual useful things in this post

component model is trash