Rust isn’t strictly functional? Do you mean you’d like a language with garbage collection?
post
I find Zig a language wuth very good WASM support out of the box and it is mostly imperative in nature.
It is currently pre 1.0 and has some rough edges.
You can use Go and compile with TinyGo.
I haven't done too much work with WASM myself, but when I did, the only languages I saw recommended were Rust, C++, or TinyGo. From what I've heard, Rust and C++ are smoother than TinyGo. Garbage collected languages usually aren't great choices for compiling to wasm because wasm doesn't have any native garbage collection support. That limits your selection down a lot.
But another option you may want to consider is Nim. As I understand, it compiles to C, so any C->Wasm compiler should theoretically work for you as well. I did a quick search and wasn't able to find any great resources on how to do this, but you might get a bit more lucky. Good luck!
Swift could be a good choice.
Ive done C++ and C# before. Both work but it still feels very experimental in browser support. Ive put lisp in the browser through wasm with C++. Its was a fun novelty.
I have not used this but Moonbit "looks" good https://www.moonbitlang.com/
Scala-js is working on it - as its compiler design may facilitate this.
I haven't yet tried (on todo list) and am not an expert, but bookmarked in passing:
recent github implementation, some history, following older discussion
What are you building, it depends a bit on your usecase
Otherwise c# Blazor compiles to WASM
Late here, but if you want the easy route then there is always Unity (C#) if it fits for your use case in game dev and the license isn't a problem for you.
all 26 comments