DEV Community

Discussion on: Elm functions in WebAssembly

Collapse
briancarroll profile image
Brian Carroll Author

Hi, glad you liked the post!

I actually started off this project using the direct-to-Wasm approach. I even got a toy example Elm program to compile.

But I quickly decided it wasn't worth it.

C is really not that much of a "layer" on top of assembly performance-wise, but it's massively easier to work with.

All the low level runtime stuff would have to be written in WebAssembly. The first-class function stuff mentioned in this article, plus all the "kernel code" in the core libraries, plus perhaps a Garbage Collector. It's a huge project, and not feasible for one guy's hobby project. It would need a proper team in a big company.

Plus, C compilers produce extremely good assembly code. A lot of smart people have spent 50 years making sure of that!

As far as I know, lots of languages use C as an intermediate language, including Haskell. I think OCaml might do it this way too but I'm not 100% sure.

Having said all that, if you're curious, here's the fork of the Elm compiler where I tried it:
github.com/brian-carroll/elm-compi...