Universal packages, powered by WebAssembly Interfaces - WAI
10-27, 16:20–16:45 (Europe/Berlin), Main stage

WebAssembly Interfaces (WAI) is a project associated with Wasmer that functions as a bindings generator framework for WebAssembly programs and their embeddings. WAI is poised to play a pivotal role in creating universal packages, as it bridges the gap between various languages and runtimes. Its capacity to generate language-agnostic interface types allows WebAssembly modules to be written and consumed across a diverse array of languages and environments.

  • WAI
  • integration with npm, pip for automatically publishing to other registries.

We will start the session by discussing the list of topics that we would go through in this presentation. This includes:

  1. Problems with libraries
  2. Solving the problem using WAI
  3. Publishing these libraries for multiple ecosystems at once using wasmer registry

We progress our presentation to the topic of Problems with libraries; like the turf which doesn’t exists for languages such as Rust or Scala as an example but if somebody wants to use that library they have to write their own wrapper implementation. This creates a situation where good libraries can’t be shared across multiple ecosystems but WebAssembly Interfaces solves this problem.

Then we lead our discussion on WAI. WebAssembly Interfaces (WAI) is a project associated with Wasmer that functions as a bindings generator framework for WebAssembly programs and their embeddings. Denoted with .wai extension WAI facilitates the following features:

  1. For languages compiled to WebAssembly (e.g., Rust), WAI enables the generation of bindings to import APIs such as WASI described using .wai.
  2. For runtime environments like Wasmer, WAI aids in producing a Rust trait that can be implemented for a given interface, such as the WASI interface.
  3. For scenarios where a WebAssembly module is consumed (e.g., in browsers), WAI can be employed to generate JavaScript bindings, providing a TypeScript interface that handles native JS types for the WebAssembly module described by .wai.

This presentation only deals with the 1st & 3rd use case for node/python environments and for browsers respectively. The generated language bindings universally employ a canonical ABI (Application Binary Interface) for communication. This ensures that WebAssembly modules, irrespective of their source language, can be consumed in any environment supporting the necessary language bindings. Thus, it simplifies the process of interfacing between different programming languages and WebAssembly, fostering the development of more universal and accessible packages. Moreover, WebAssembly compiled libraries provide faster compute times than native written javascript or python libraries.

[Demo]

We then show how to create a basic package using WAI’s Rust bindings that can be used across both javascript and python locally. (Making a basic calculator.)

This leads us to the discussion that for a wide use of our universal calculator we need to deliver it to users and developers. For this we use wasmer registry.

Before going into the details of publishing this calculator we give some briefings about wasmer registry. We tell the story about how our founder Syrus Akbary thought of universal libraries even before the runtime and lead the team that brought the fastest and most favourite webassembly runtime to the market.

[Demo]

Going further we publish our calculator to Wasmer Registry and use it in different ecosystems such as python’s pip and javascript/typescript’s yarn. And use it in a browser.

A real world example of this is the sgp4 library which is a Celestrak implementation ported to rust. But this library with the speeds of WASM was ported to both javascript/typescript and python using WAI.

I'm a Software Engineer and Devrel at Wasmer.io . I help around the WASIX ecosystem and promote WebAssembly. I recently graduated from Trinity College Dublin. I love cooking, culture exploration, reading history and playing guitar whenever I find the time.