Skrevet av Jarl André Hübenthal, Senior Architect
So, what is Elm?
What is this Elm I am talking about? Besides being a tree type, it’s the following:
"Elm is a domain-specific programming language for declaratively creating web browser-based graphical user interfaces. Elm is purely functional, and is developed with emphasis on usability, performance, and robustness. It advertises "no runtime exceptions in practice", made possible by the "Elm compiler's static type checking." - shameless Wikipedia rip-off.
There’s only under a handful known corner cases for runtime exceptions caused by Elm. And you almost never have to think about runtime exceptions again. It's a shift of focus from getting stuff to run, to getting it work properly according to what you are making. The compiler will help you get it running. You have to get it working the way you want.
The Power of Elm!
Elm’s superpower is its architecture combined with its strong type system. The type system somewhat resembles Haskell, but Elm is its own language. The Elm compiler is coded in Haskell though. Some might say that Elm could be a steppingstone to learn Haskell, but I do not agree. Do we want side effects? Yes, we do! Do we want them now and not after studying a language for a year? Of course, we do! Elm gets you up and running blazingly fast.
Similarity to Redux
The Elm architecture is very similar to Redux, because, Redux is inspired by Elm. So, as a frontend developer working with React and unidirectional data flow architectures, Elm will feel like home.
The most difficult thing about Elm, if there is any, is that you need to learn the building blocks of each Elm program and how to stitch them together. Every Elm program contains at least an init function, update function and a view function. These three functions are combined with a helper method inside the main function. When you get to understand this initial setup and how these functions cooperate you have come a long way. Then everything else is like the unidirectional data flow you have always worked with.
Could it replace React?
Elm can be used in conjunction with React. In fact, it can be used with or within most frontend apps. You can make elm widgets that only control a single element on the page. So, Elm and React can live side by side. And in some cases, they do solve different problems.