diff --git a/docs/languages.md b/docs/languages.md new file mode 100644 index 0000000..96636df --- /dev/null +++ b/docs/languages.md @@ -0,0 +1,58 @@ +--- +title: "Languages" +sidebar_position: 2.5 +--- +## Language support + +The languages below can be compiled to WebAssembly with WASI support. Some toolchains produce **components** built to the [Component Model](https://component-model.bytecodealliance.org/) (and can use WASI 0.2 or 0.3), while others produce core Wasm **modules** (which can use WASI 0.1). Some languages have first-party support, while others rely on externally maintained tools. + +| Language | Name | Output | WASI Version | Maintained By | Notes | +| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------- | ---------------------- | ---------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| C and C++ | [`wasi-sdk`](https://github.com/WebAssembly/wasi-sdk) | Modules; components via `wasm-tools component new` | 0.1, 0.2 | W3C Wasm CG | 0.3 toolchain support is not yet shipped | +| C# | [`componentize-dotnet`](https://github.com/bytecodealliance/componentize-dotnet) | Components | 0.2 | Bytecode Alliance | Pre-release toolchain | +| Go | Upstream Go (`GOOS=wasip1`) | Modules | 0.1 | Go Project | | +| Go | [`go-modules`](https://github.com/bytecodealliance/go-modules); [TinyGo](https://tinygo.org/) | Components | 0.2 | Bytecode Alliance; TinyGo Project | | +| Java | [GraalVM](https://www.graalvm.org/) | Planned | Planned | Oracle | Planned: see the [tracking issue](https://github.com/oracle/graal/issues/9762), [roadmap](https://github.com/orgs/oracle/projects/21/views/1), and [presentation](https://youtu.be/uefc2t9AmQI?t=1218) | +| JavaScript and TypeScript | [`jco`](https://github.com/bytecodealliance/jco) | Components | 0.2; 0.3 in progress | Bytecode Alliance | The `preview3-shim` package ships P3 host bindings; streams support landed, futures support following | +| Kotlin | [Kotlin](https://kotlinlang.org/docs/wasm-wasi.html) | Modules | 0.2 | JetBrains | Implementation in progress; see the [tracking issue](https://youtrack.jetbrains.com/issue/KT-64568) | +| MoonBit | MoonBit compiler with [`wit-bindgen` MoonBit backend](https://github.com/bytecodealliance/wit-bindgen/tree/main/crates/moonbit) | Modules; components via `wasm-tools component new` | 0.2 | MoonBit | | +| Python | [`componentize-py`](https://github.com/bytecodealliance/componentize-py) | Components | 0.2 | Bytecode Alliance | | +| Python | [`cpython`](https://snarky.ca/state-of-wasi-support-for-cpython-march-2024/) | Modules | 0.2 | Python | Implementation in progress | +| Ruby | [`ruby.wasm`](https://github.com/ruby/ruby.wasm) | Modules | 0.2 | Ruby | Implementation in progress | +| Rust | [`wasm32-wasip2`](https://doc.rust-lang.org/rustc/platform-support/wasm32-wasip2.html) and [`wasm32-wasip3`](https://doc.rust-lang.org/nightly/rustc/platform-support/wasm32-wasip3.html) compiler targets | Modules and components | 0.1, 0.2; 0.3 nightly | Rust Project | `wasm32-wasip2` is Tier 2 on stable; `wasm32-wasip3` is Tier 3, nightly only. See the [0.2 introduction](https://blog.rust-lang.org/2024/04/09/updates-to-rusts-wasi-targets/) and [0.2 stabilization](https://blog.rust-lang.org/2024/11/26/wasip2-tier-2/) | +| Swift | [Swift](https://www.swift.org/) | Planned | Planned | Swift | Planned: see the [accepted roadmap vision](https://forums.swift.org/t/accepted-vision-a-vision-for-webassembly-support-in-swift/80332) | +| Zig | `zig build-exe -target wasm32-wasi` | Modules | 0.1 | Zig | No first-party Zig component toolchain | + +### Notes + +- **Modules vs components.** A Wasm **module** is a single binary in the core WebAssembly format and can use WASI 0.1. A **component** is built to the Component Model and can use WASI 0.2 or 0.3, gaining composability, cross-language interoperability, and richer interface types. See the [Interfaces](interfaces.md) and [Roadmap](roadmap.md) pages for more on the WASI releases. +- **Adapting modules to components.** Several toolchains produce core modules today and wrap them into components using [`wasm-tools component new`](https://github.com/bytecodealliance/wasm-tools) with a P1-to-P2 adapter. This is the path for C/C++ and MoonBit. +- **WASI 0.3 ecosystem state.** Broad language-level P3 support is still landing. The Rust `wasm32-wasip3` target is Tier 3 (nightly only). `jco` ships a `preview3-shim` package with streams support landed and futures support following. Other toolchains have not yet shipped P3 support. +- **Snapshot pinning.** When working with WASI 0.3, all WIT-aware tools must target the same snapshot (currently `0.3.0-rc-2026-03-15`). Mismatches surface as confusing `wrong type` errors at instantiation. + +### Building guides + +For hands-on guides covering setup and a "hello world" per language, see the Component Model documentation: + +- [Rust](https://component-model.bytecodealliance.org/language-support/building-a-simple-component/rust.html) +- [JavaScript](https://component-model.bytecodealliance.org/language-support/building-a-simple-component/javascript.html) +- [Python](https://component-model.bytecodealliance.org/language-support/building-a-simple-component/python.html) +- [Go](https://component-model.bytecodealliance.org/language-support/building-a-simple-component/go.html) +- [C](https://component-model.bytecodealliance.org/language-support/building-a-simple-component/c.html) +- [C#](https://component-model.bytecodealliance.org/language-support/building-a-simple-component/csharp.html) +- [MoonBit](https://component-model.bytecodealliance.org/language-support/building-a-simple-component/moonbit.html) + +### Bindings generators + +The bindings generators below provide a way to make Wasm function calls using [interfaces](interfaces.md) in a given language. + +| From | To | Name | +| -------------------- | -------------------- | ------------------------------------------------------------------------------------------------- | +| Wasm Interface Types | C | [wit-bindgen c](https://github.com/bytecodealliance/wit-bindgen/tree/main/crates/c) | +| Wasm Interface Types | C++ | [wit-bindgen cpp](https://github.com/bytecodealliance/wit-bindgen/tree/main/crates/cpp) | +| Wasm Interface Types | C# | [wit-bindgen csharp](https://github.com/bytecodealliance/wit-bindgen/tree/main/crates/csharp) | +| Wasm Interface Types | JSON Schema | [component2json](https://github.com/microsoft/wassette/tree/main/crates/component2json) | +| Wasm Interface Types | Markdown | [wit-bindgen markdown](https://github.com/bytecodealliance/wit-bindgen/tree/main/crates/markdown) | +| Wasm Interface Types | Moonbit | [wit-bindgen moonbit](https://github.com/bytecodealliance/wit-bindgen/tree/main/crates/moonbit) | +| Wasm Interface Types | Rust | [wit-bindgen rust](https://github.com/bytecodealliance/wit-bindgen/tree/main/crates/guest-rust) | +| WebIDL | Wasm Interface Types | [webidl2wit](https://github.com/wasi-gfx/webidl2wit) |