A few days ago, we tweeted telling people to ask us any questions they have about Elm.
We got a few questions, and we tried to answer them all on Twitter. This blog post will summarize those questions, to hopefully help other people that had the same questions. If you are starting with Elm or if you haven’t heard of Elm, follow along and we hope some of your questions will be answered too.
Marcelo wanted to know if he could use Elm on the server. Elm is designed for client-side use, and that’s where the majority of people use it. However, there are some people hacking their way into using Elm on the server-side.
- You can write a Node.js app that handles server requests and passes data over to an Elm app that’s running a
- You can use elm-serverless to run an Elm app on AWS Lambda.
Building Mobile apps with Elm
Santiago asked about the state of Elm for mobile development. I’ve built a couple of mobile Elm apps. Here are some resources:
Neither of these are labeled as production ready, but where there’s a will there’s a way! There’s also some work being done on proper Elm Native, focusing initially on iOS, as a part of the Google Summer of Code. Here’s the latest update on that work.
Elm and React
Smeevil asked about using Elm as a component in a React app. There are two paths to this.
- First, you can use react-elm-components to trivially mount an Elm app as a React Component.
- If that’s not really what you’re after, you can make Elm web components (custom elements) with elm-ement.
Testing Elm Code
Rodrigo wanted to know if you can use JS testing tools for your Elm apps.
- You should probably check out elm-test - it’s super easy to pick up.
- If you want to use your existing JS knowledge of building browser-driving testing tools, of course that will still work - just point the browser at your elm app!
Advantages over React-Redux
Lucas asks what advantages Elm has over using React and Redux. This may be a bit opinionated, but here goes:
- Elm is a million times easier to set up than a new React app.
- Redux was inspired by Elm in the first place.
- If you don’t use Elm you miss out on the compiler, which John Carmack says should be an inspiration when it comes to error messages.
- Flow and TypeScript are alright, but they don’t hold a candle to Elm’s type system and compiler support.
- With Elm, you cannot mix stateful operations and side effects. In a React app, you can try for this, but in my experience people don’t really give much thought to it.
On the con side:
- Elm makes it harder to “just drop in” some random JS library that you want to include, because if they manipulate the DOM they’ll interfere with Elm’s virtualdom. In those cases, there are a few tricks you can use to make sure Elm doesn’t override their elements, but in general I’ve not needed to care about this - just write the thing in Elm, it’ll go surprisingly fast :)
Examples in Real life
Santiago wanted to see the biggest, most complete open source Elm app. This was a good question.
If you want to know more about Elm, check out these videos and blog posts:
It was fun spending a day answering questions about Elm. If you have any other question, just mention us on Twitter or ask in the comments and we will glad to reply it!