2HAASStart a project
All posts

Tech News

The WebAssembly Component Model, explained

Core WebAssembly modules can only exchange numbers. The Component Model adds typed interfaces, so code written in Rust, Go, Python or JavaScript can be combined safely.

The 2HAAS team2 min read

WebAssembly promised that code from any language could run anywhere. One practical gap remained. A core WebAssembly function can only take and return numbers. Passing a string, a list or a record means agreeing by hand on how those bytes are laid out in memory, and writing glue code for every pair of languages.

The Component Model closes that gap.

Interfaces described in WIT

A component declares what it offers and what it needs in WIT, a small interface language.

package acme:images;

interface resize {
  record size {
    width: u32,
    height: u32,
  }

  resize: func(image: list<u8>, target: size) -> result<list<u8>, string>;
}

world image-service {
  export resize;
}

This says: the component exports a resize function that takes image bytes and a target size, and returns either the new image or an error message. Nothing in it mentions a programming language.

What you get from it

Rich types across languages. Strings, lists, records, variants, options and results are part of the model. The tooling generates the conversion code on both sides.

Generated bindings. From one WIT file, tools produce the matching code for each language. In Rust the interface becomes a trait to implement. In JavaScript it becomes functions to call.

Composition. Components are linked through their interfaces. A validation component written in Rust, an image component written in Go and a small piece of routing logic in JavaScript can be combined into one deployable unit.

Isolation between parts. Components do not share memory. One component cannot read or corrupt the data of another. That is a strong guarantee to have between your own code and a third party library.

Why it matters

Think of how plugins, shared libraries and microservices are used today:

Approach Cost
Shared library Same language, same process, no isolation
Microservice Isolation, but a network call and a deployment for each piece
Wasm component Isolation and typed calls, inside one process

Components offer a middle path: the separation of a service with the speed of a function call.

Where things stand

  • WASI, the standard system interface for WebAssembly, is defined in WIT and built on the Component Model.
  • Wasmtime runs components natively. Tooling exists for Rust, JavaScript, Python, Go and C, at varying levels of maturity.
  • Browsers run core modules, not components. A tool called jco converts a component into a core module plus JavaScript so it can run there.
  • Native async support arrives with WASI 0.3.

Should you use it now?

If you are building a plugin system, a platform that runs customer code or an edge product, it deserves a prototype today. For ordinary application code the ecosystem is still young, and containers remain the simpler choice. It is worth understanding either way, because it shapes how portable, sandboxed software will be assembled.

For the server-side background, read WebAssembly beyond the browser.

Keep reading

  1. Tech News2 min read

    WebAssembly beyond the browser: what WASI enables

    WebAssembly began as a way to run fast code in browsers. With WASI it runs on servers, at the edge and inside plugins: sandboxed, portable and quick to start.

  2. Tech News4 min read

    GitHub Copilot Workspace Transforms Developer Workflow

    Explore GitHub Copilot Workspace, a new AI-powered development environment that streamlines coding from issue to pull request. Learn its features and impact.

  3. Tech News2 min read

    React Compiler: memoization without useMemo

    React Compiler memoizes components and values at build time, so most useMemo, useCallback and React.memo calls become unnecessary. What it does and how to adopt it.

Tell us what’s in the way.

A few lines is enough. You get a candid yes, a candid no, or a sharper question.

  • Working software in week four
  • A reply in one business day
  • Handover is the deliverable

Prefer email? [email protected]

The problem, who it is for, and what is in the way right now.

One business day to a real reply. No sales sequence, no call required.