WASI language support (part 1)
Support for WebAssembly (and WASI) is advancing well across all major programming languages. Assessing how well a language supports WebAssembly/WASI is important because it allows us to understand what's possible with wasmtime and Enarx.
Enarx uses wasmtime as a runtime for WebAssembly, and if a Wasm application runs well on wasmtime, it should work equally well on Enarx. Good support in a given language means a whole developer community/ecosystem is able to take advantage of Enarx.
One important study that helps us assess WebAssembly support is the The State of WebAssembly, an annual survey that provides an overview of the Wasm landscape, including language popularity (current usage) and desirability (future).
Popularity/Desirability among wasmtime users
The Enarx team has analysed the data specifically for survey respondents who are using wasmtime (the runtime used by Enarx). Here are some key findings:
1) Rust is the most popular language (up to 44% frequently used among wasmtime users from 28% in the original survey) and desirable language (up to 68% from 55%). Popularity jumps to an outstanding 85% when considering frequent, sometimes, or occasional usage. Desirability jumps to a staggering 95% when considering wanting a lot or a little.
2) JavaScript is still popular (down to 13% frequently used among wasmtime users from 18%, as expected) and very desirable (up to 25% from 21%, surprisingly). Interest is not just in JavaScript and Wasm in the browser, although current usage is low in the server side.
3) Go / TinyGo is also gaining popularity (up to 8% frequently used among wasmtime users from 4%) and very desirable (up to 32% from 19%).
4) Another language that is very desirable is Python (up to 22% from 16%).
The chart below highlights Wasm language usage among wasmtime users, ranked by "frequently":
The chart below is the WebAssembly language usage from The State of WebAssembly annual survey, but we display usage from frequently to occasionally from bottom to top so that it's easier to visualize the level of adoption:
The chart below highlights the desired language support for WebAssembly among users of wasmtime, ranked by "a lot":
The chart below is the original one from The State of WebAssembly annual survey, but displaying desirability from bottom to top:
Overall language popularity
In the table below, we present the Wasm/WASI popularity/desirability along with the overall popularity of each language according to the RedMonk Programming Language Rankings. The most popular languages overall are, in order: JavaScript, Python, Java, PHP, C#, C++, TypeScript, Ruby, C, Swift, C, Swift, R, Objective-C, Shell, Scala, Go, PowerShell, Kotlin, Rust, and Dart.
Language | Popularity (wasmtime) | Desirability (wasmtime) | Overall Popularity |
---|---|---|---|
Rust | 44% use frequently | 68% are a lot interested | #19 in RedMonk |
C++ | 10% | 17% | #7 |
C | 10% | 17% | #10 |
Golang | 7% | 32% | #16 |
JavaScript | 13% | 25% | #1 |
TypeScript | 13% | 25% | #7 |
Python | 3% | 22% | #2 |
.NET | 2% | 13% | #5 |
Java | 2% | 9% | #3 |
Zig | 2% | 12% | - |
Ruby | 1% | 9% | #9 |
Swift | 2% | 9% | #11 |
AssemblyScript | 7% | 19% | - |
Grain | 1% | 9% | - |
Popularity/Desirability and the feedback loop
It's important to note the positive feedback loop created by WebAssembly support by a language. Better support will drive up its popularity and desirability, which in turn will spur better support.
This is also related to the chicken/egg problem. Languages that have poor support for WebAssembly will continue to languish until the cycle is broken.
In the latest Wasm Days in Europe and North America, we've observed communities from languages like Go/TinyGo, JavaScript, Java, Python, and C# investing on providing better support for WebAssembly. These advancements will unlock huge ecosystems and allow large developer communities to make use of WebAssembly (and Enarx).
While it's still early days for WebAssembly in the server-side, below we provide a brief summary of the current status for each language:
WebAssembly with Rust
- WebAssembly support for Rust is excellent.
- Rust is the most popular and desirable language to work with WebAssembly.
- Both Enarx and wasmtime (Enarx's runtime) are written in Rust.
- The Enarx team has contributed upstream to WASI sockets, threads, and crypto.
WebAssembly with C++
- WebAssembly support for C++ is excellent.
- C/C++ are among the most popular languages to work with WebAssembly.
- The WASI SDK toolchain is maintained by the Bytecode Alliance.
- WASI SDK pulls upstream projects Clang and LLVM, as well as wasi-libc.
WebAssembly with C
- WebAssembly support for C is excellent.
- C/C++ are among the most popular languages to work with WebAssembly.
- The WASI SDK toolchain is maintained by the Bytecode Alliance.
- WASI SDK pulls upstream projects Clang and LLVM, as well as wasi-libc.
WebAssembly with Golang
- WebAssembly support for Go is excellent thanks to TinyGo.
- TinyGo provides a compiler based on LLVM.
- Go is among the most popular and the second most desirable language to work with WebAssembly (using wasmtime).
WebAssembly with JavaScript
- WebAssembly support for JavaScript is good thanks to Javy.
- Javy compiles QuickJS, a tiny JavaScript runtime, to Wasm along with the script to be executed.
- JavaScript is the second most popular and desirable language to work with WebAssembly.
- TypeScript, a superset of JavaScript, can be transpiled into JavaScript before being compiled to Wasm.
WebAssembly with TypeScript
- TypeScript is a superset of JavaScript. Therefore, the best approach to using TypeScript with WebAssembly is to transpile it into JavaScript.
- WebAssembly support for JavaScript is good thanks to Javy.
- Javy compiles QuickJS, a tiny JavaScript runtime, to Wasm along with the script to be executed.
- JavaScript is the second most popular and desirable language to work with WebAssembly.
WebAssembly with Python
- WebAssembly support for Python is good thanks to CPython on wasm32-wasi.
- CPython on wasm32-wasi consists of utilities and libraries for building CPython sources for the WebAssembly platform using the WASI SDK and wasix.
- Python is one of the most desirable languages to work with WebAssembly.
- The Python interpreter needs to be compiled to Wasm, and Python libraries should be available from the VFS (virtual filesystem).
- Currently Python works with wasmtime, and should work with Enarx once it has VFS support.
WebAssembly With .NET
- WebAssembly support for .NET is good thanks to the dotnet WASI SDK.
- dotnet WASI SDK is an experimental package that can build .NET Core projects (including whole ASP.NET Core applications) into standalone WASI-compliant .wasm files.
WebAssembly with Java
- WebAssembly support for Java is good thanks to a friendly fork of TeaVM, modified to support WASI and the WebAssembly Component Model proposal.
WebAssembly with Zig
- WebAssembly support for Zig is excellent.
- Zig uses LLVM, thus it provides wasm32 target architecture.
WebAssembly with Ruby
- WebAssembly support for Ruby is good thanks to ruby.wasm.
- ruby.wasm is a collection of WebAssembly ports of the CRuby. It enables running Ruby applications on WASI compatible WebAssembly runtimes.
- It uses wasi-vfs to create a virtual filesystem layer for WASI.
- Sockets and threads are not supported yet.
WebAssembly with Swift
- WebAssembly support for Swift is good thanks to SwiftWasm.
- SwiftWasm compiles Swift code to WebAssembly.
WebAssembly with AssemblyScript
- AssemblyScript was designed for WebAssembly and has a syntax similar to TypeScript.
- Support for WASI is uncertain, given that the AssemblyScript team has criticized the WASI standardization process.
WebAssembly with Grain
- Grain is a functional programming language designed for WebAssembly.
This blog post is part 1 of WASI language support. Be sure to subscribe to receive updates.