NEWS & EVENT
お知らせ・イベント情報
Summary of programming languages that can develop WebAssembly
2023年04月11日
WebAssembly (WASM) is an execution environment that is guaranteed to work in the browser, with the exception of JavaScript, which is an execution environment, not a programming language. Therefore, there are several languages that can be converted to WASM binaries.
By using such languages, you can generate WASM binaries from your usual programming language, making it possible to develop Web applications using languages other than JavaScript.
This article introduces major programming languages and their usage.
Rust
Rust is a programming language developed by Mozilla and is the most recommended language if you are developing for WebAssembly. Since Rust, C, and C++ were originally the languages that could be developed for WebAssembly, it will be the fastest to implement the latest features.
Rust was originally developed as a replacement for C and C++ and is often used for more modern and memory-safe programming than C and C++.
C/C++
C and C++ are also recommended languages for WebAssembly development. Many attempts have been made to convert software already developed in C or C++ to WebAssembly, including SQLite3 WASM/JS, which converts SQLite3 to WASM.
Emscripten is used to convert C/C++ to WASM binaries. When converting, it also generates HTML files to use it. Of course, not all APIs work, so code modification is necessary, but the advantage of being able to use existing assets is great.
Go
Go officially supports WebAssembly as a language. Therefore, it has an image of being well-informed. Compiling with GOARCH=wasm GOOS=js will generate a WASM binary.
However, the drawback is that it is still an experimental feature and the size of the generated binary file is large.
Java
In Java, a library called TeaVM generates WASM binaries from Java intermediate files. The interesting thing is that since it is an intermediate file, it does not require the original source code.
In other words, technically speaking, it can be used not only with Java, but also with Scala, Kotlin, and other intermediate files that run in the JVM.
Kotlin
Kotlin/Wasm is being developed by JetBrains, the developer of Kotlin. It is still experimental, but it is a function that generates WASM binaries from Kotlin.
Because it requires WASM GC, it needs special flags for Chrome and Firefox.
AssemblyScript
AssemblyScript is a subset language of TypeScript. The language system is TypeScript, but not all functions are available.
AssemblyScript can then be converted to WebAssembly. The great advantage is that you don’t have to learn a new language, just TypeScript.
.NET
.NET, you can generate WASM binaries by using a framework called Blazor. NET-based languages, such as C# and VB.NET.
It is still a relatively new framework, but as it matures, it will be available for use when developing with .NET.
Conclusion
In this article, we have introduced programming languages that can generate WebAssembly binaries, and WebAssembly can be developed in languages other than Rust, C, and C++. Please try it in your favorite language.
WebAssembly is often faster than JavaScript. It can be used in many situations, such as machine learning, which requires more computation on the client side, and games.