Building Spin components in other languages
This document is continuously evolving as we improve language SDKs and add more examples on how to build Spin components in various programming languages.
WebAssembly is becoming a popular compilation target for programming languages, and as language toolchains add support for the WebAssembly component model, building Spin components will also become supported.
As a general rule:
- if your language supports the
WebAssembly component model,
you can build Spin components either through an official Spin SDK
(such as the Spin SDK for Rust), or through using
bindings generators like
wit-bindgen(for languages such as C and C++)
- if your language compiles to WASI, but doesn’t have support for the component model, you can build Spin HTTP components that use the Wagi executor — for example in languages such as Grain or Swift.
- if your language doesn’t currently compile to WASI, there is no way to build and run Spin components in that programming language
C and C++ are both broadly supported in the WebAssembly ecosystem. WASI/Wagi support means that both can be used to write Spin apps.
- The C entry in the Wasm Language Guide has examples.
- The C++ entry in the Wasm Language Guide has specific caveats for writing C++ (like exception handling)
- The yo-wasm project makes setting up C easier.
C# and .NET Languages
.NET has experimental support for WASI, so many (if not all) .NET languages, including C# and F#, can be used to write Spin applications.
- The C# entry in the Wasm Language Guide has a full example.
Grain, a new functional programming language, has WASI/Wagi support and can be used to write Spin apps.
- The Grain entry in the Wasm Language Guide has details
- A simple Hello World example shows how to use Grain
- For a production-quality example. the Wagi Fileserver is written in Grain
Upstream Ruby officially supports WebAssembly and WASI, and we here at Fermyon have successfully run Ruby apps in Spin.
- The Ruby entry in the Wasm Language Guide has the latest information
- Ruby’s 3.2.0 Preview 1 release notes detail WASI support
Zig is a low-level systems language that has support for Wasm and WASI, and can be used to write Spin apps.
- The Zig entry in the Wasm Language Guide covers the basics
- Zig’s 0.4 release notes explain WebAssembly support