Book reflection: Programming Elm
Another impressive aspect is that the author walks you through practices for refactoring and scaling an app in Chapter 3: Refactor and Enhance Elm Applications and Chapter 6: Build Larger Applications. This information is practical and is clearly demonstrated via examples.
Coding along while reading really allowed me to play around with the language and exercise its features. Following the examples helped me to retain the material but exploring beyond the samples in the book really helped connect the dots. The author does a great job of facilitating this absorption by sprinkling coding challenges along the way with answers available in the book source code materials.
Let's dive into some first impressions of the language.
The Elm Architecture seems well thought-out. Separating the Model, Update, and View logic keeps the code organized, modular, maintainable and easily extensible. Nonetheless, I felt that building upon the architecture became a bit verbose and slightly cumbersome on occasion. I plan to develop more with Elm to further experiment with this hypothesis.
Don't you hate when a compiler yells at you for something and the message is so cryptic that you have no idea where to start? Sure, there are other debugging techniques but the point I'm trying to make is that I've never seen compilation errors as straight-forward and helpful as they are with the Elm compiler.
That being said, at times these straight-forward messages can become quite ubiquitous. This is a net positive characteristic in my opinion. Making significant changes before recompiling can result in a rabbit hole of compilation errors, which is unfortunate. However, this becomes a way to incentivize the developer to compile often following smaller changes. The developer also gets the peace of mind that comes with the satisfaction of the compile-time checklist. Elm makes the promise that the users of an Elm app will experience zero runtime exceptions.
This is a pretty big deal and it's only possible with the help of Elm's type system.
Elm is a strongly-typed language and, so far, the type system gets an A+ from me. Being able to use types like
When starting to code in Elm it quickly becomes apparent that the Elm REPL provides a large productivity boost. There's no need to scaffold code and jump through hoops to make the compiler happy just to test the result of an expression. Fire up the Elm REPL, test away, and move on.
Using only pure functions and being side-effect-free comes with a great deal of benefits. Tests become easy to write, logic becomes easily composable, cognitive overhead is reduced, etc. If interested, check out more thoughts on functional programming here.
Overall, Programming Elm is a worth-while read.