A Gentle Introduction
In this post we’ll explore what WebAssembly is, and why we want to bring Haskell to it.
Except everything isn’t really fantastic. Our developer accomplished what was needed, but the final outcome was not what our developer really wanted. Our developer really wanted to make a more graphically intensive games, and have snappier client-side calculations. The dev team is great, but (as with many enterprise web applications) the codebase has grown large, and with that size has come a certain unwieldiness that our developer didn’t expect. Our developer is plagued by some recurring thoughts.
“It’s hard to reason about the behavior of much of the codebase. New features, and even bug fixes, have unexpected effects on the system and often cause issues.”
“At this point, I’m really only comfortable making changes to code that I wrote, or writing new code that heavily relates to what I’ve already written.”
“Bug fixes and features seem to be taking longer and longer to implement. Development really is getting expensive.”
“Now that the codebase is so large, dynamic typing is more of a curse than a blessing. A statically typed language with a fully-featured type system would be enormously helpful”
“Sending my computational logic to the client as text feels wasteful. I wish I could send it in a form closer to machine code. This would definitely help load times.”
“I wish I could just write my front-end logic in a different language.”
Bring on the WASM
So WebAssembly is a fast, low-level standard. Great! This means it’s perfect for building new, higher level languages on. Even better, it’s a great compilation target for current high-level languages. We only need to find a suitable high-level language, and put in the necessary work to get it to compile to WebAssembly.
Haskell to the rescue
So Haskell is a fantastic language that is built for handling heavy-duty work and is designed to produce more reasonable code. Awesome. We’ve got Haskell and we’ve got WebAssembly. We just need a way to compile Haskell to WebAssembly. That is the goal of the WebGHC project.