I really enjoy Elm’s simplicity, and I would love to write applications outside of the browser in it. For example, many Node.js libraries just have simple functions that would be really nice to write in Elm. Or maybe even CLIs, that could be distributed via npm.
I totally understand why Elm does not support these environments. It clearly states that it is developed to be used for browser apps. That is one of its greatest advantages: it is very focused on that task, which streamlines everything and makes much of it look simple.
My idea would be to decouple the runtime from the language. How about having a functional language similar to Elm that would have a bunch of different runtimes available: One for the browser, one for Node.js, maybe one for LLVM. Of course, code would not be easily sharable between runtimes, and I think that’s ok. Node.js’s runtime might be modeled incompatibly, even for fundamental things like HTTP requests.
So I could imagine renaming the language to Forest and having tree names for the ecosystems around each runtime: Elm for the browser, Acacia for Node.js, Mangrove for LVVM… The language family, Forest, would ideally be exactly like Elm. Functional, type-safe, simple. Each runtime would provide a library that interfaces with its environment, just as the packages elm/http
and elm/browser
do. Acacia, for Node.js, could provide acacia/http
, acacia/console
, etc.
What this would necessitate is to decouple the language from the runtime and target language. I could imagine having a sort of intermediary, bytecode-like language that is passed to a dialect’s compiler for further processing, such as linking with the provided standard libraries and compiling to the target language. However, I have never touched compiler code, so I’m not sure how feasible this is and if it even is the right approach.
Forest as an “umbrella” language would bring Elm’s powerful simplicity to more domains than just the browser, while leaving Elm’s valuable focus on being a browser app language intact.
What do you think of this idea? Do you see any downsides or improvements? Do you think such a thing is feasible?