Why are we not using Elm?

Why are we not using Elm_

Too often we forget that quantity is not quality, especially when it comes to hours used in debugging software or the amount of code, and especially in frontend development with untyped JavaScript. You can’t just always hire more developers to add speed or fix a problem, because speed is not dependent on the number of developers, but how much of the code one developer can hold in his head at any given time. Lack of types greatly reduces this mental capacity.

Written by 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. 

Elm is a language that compiles to JavaScript. And the JavaScript that Elm produces outperforms many other web development frameworks. I am using the word framework because that's what Elm is besides being a language. 

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.  

Conclusion 

I think the future of frontend development should be less raw JavaScript and more typed languages. Typescript only gets you a mile. Elm gets you home and back again. Start using Elm and you will see how it will free you from the horrors of “modern” web development. I have made several apps in Elm, my own blog is made in Elm, from the frontend serving the blog to the frontend where I manage my posts. It's an understatement that I really enjoy programming frontend applications in Elm. 

Jarl André Hübenthal

Jarl André Hübenthal

Senior Architect

jarl.andre.hubenthal@itera.no