Making WebAssembly a first-class language on the Web

(hacks.mozilla.org)

41 points | by mikece a day ago ago

12 comments

  • dfabulich 18 hours ago 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 9 hours ago 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 11 hours ago ago

      There can be an automated way of translating WebIDL to wit.

      I've actually tried to do that the past and got pretty far. https://github.com/wasi-gfx/webidl2wit

      And here's the generated wit https://github.com/mendyberger/brow

  • mendyberger a day ago ago

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

  • thesmart a day ago 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?

    • justinclift 13 hours ago ago

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

    • bvisness a day ago 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!)

    • mendyberger a day ago 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 a day ago 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.

      • yoshuaw a day ago ago

        The other side of the story here is also worth considering: native support in browsers provides a stable compile target for language toolchains. It'd be really nice if targeting the web from e.g. Kotlin, Swift, or Rust becomes just a matter of passing the right flag to the compiler.

  • nilslice a day ago 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