Ask HN: Languages Designed for WASM?
Hi everyone. I'm on a hunt to find all languages that are designed specifically to compile to WASM. I have a project (hram.dev -- hand-rolled assembly machine) that I want to build to share the joy of unwrapping a new computer in the 80s/90s that boots up with an editor so that you can program it directly in assembly, and I plan to use wamr+llvm for near-native performance while still having isolation so that you can mess things up. Obviously the ability to write WAT directly will be fundamental and certainly fun, but I am looking for higher level languages that make it slightly less convenient to write, to bundle with it internally so that users have at least two choices of how to write code. Do you know of any other languages designed specifically for wasm? These are all I could find:
Most likely:
curlywas (https://github.com/exoticorn/curlywas) -- c-like but very low-level; seems very complete; rust impl; mit license; short but seemingly thorough docs?
wa (https://github.com/wa-lang/wa) -- go-like, not clear how high/low level it is, thorough docs, seems promising, agpl license, lots of mandarin in docs
virgil (https://github.com/titzer/virgil) -- ruby-like? gc; cant find license; last commit 3 hours ago; thorough docs but all in md files in repo
assemblyscript (https://github.com/AssemblyScript/assemblyscript) -- typescript-like; apache 2 license, minimal runtime with gc; implemented in js
walt (https://github.com/ballercat/walt) -- JavaScript-like made for wasm, 25 contributors! decent looking docs, might actually be usable! most commits 7 years ago but last commit 3 years ago though, mit license
onyx (https://wasmer.io/posts/onyxlang-powered-by-wasmer, https://github.com/onyx-lang/onyx) -- ocaml-like? recent activity, full docs, bsd license, not sure if it has lower level capabilities or how much the higher level features cost at runtime or build time
waforth (https://github.com/remko/waforth) -- forth for wasm! upside is that its forth, downside is that its forth; mit license; great docs; seemingly inefficient due to constant lookups?
Less likely:
thinscript (https://github.com/evanw/thinscript) -- js-like with macros; abandoned 9 years ago; not yet licensed
wase (https://github.com/area9innovation/wase) -- C-like syntax but still wasm-like, not super recent but not super old, only a few contributors, not sure how complete it is but its docs give a feeling of being mostly-complete, MIT license
wam (https://github.com/kanaka/wam) -- wasm macro preprocessor, just one guy, last commit 7 years ago, very few built in macros, mozilla license (???)
wah (https://github.com/tmcw/wah) -- wasm but with infix, doesn't seem extensible with macros, two contributors, last commit 8 years ago, eclipse license (???)
Honorable mentions:
mini-c (https://github.com/maierfelix/mini-c) -- C to wasm compiler, seemingly abandoned 8 years ago, not sure how complete it is
c4wa (https://github.com/kign/c4wa) -- c to wasm compiler, no activity in 3 years, no license, written in java
This looks fun. I don't have any specific suggestions - I've always used WASM with Rust - but I wish you luck with your project!
P.S. You might have more success with replies on Reddit. HN is very all-or-nothing.
Thanks I'll give it a try.
Zig.
Zig produces extremely small, optimized WebAssembly modules. The language includes WebAssembly-specific built-ins like @wasmMemoryGrow, and its entire standard library offers first-class support for WebAssembly.
Zig can also optimize code for specific WebAssembly runtimes, making it, in my opinion, the most efficient WebAssembly compiler available today.
I forgot to mention that I'd like it to be embeddable. I was in the zig subreddit and asked about that, they said basically no it's not possible to embed it, the best that can be done is bundle zig with my app and run it as a subproc to compile zig code, but then I have to do ipc and shared memory and it's a whole other bundle of worms.
I am leaning towards curlywas strangely enough. It just feels like the right language somehow. Not too low level to be boring to write, not too high level to take the fun out of writing low level code, not too old to consider it abandoned, docs relatively thorough and thoughtful, just enough syntax to make it familiar to C programmers and become a good stepping stone into writing C (maybe).
One thing it's missing is arrays/structs as a way to access memory more conveniently, which I think is probably a must-have, though I bet I could add them on top of this language with how small it looks. Well, except that it's written in Rust and I don't understand Rust despite trying many times.