axelerator.de

Discover Functional Programming with Elm

4 minutes
#elm
9 December 2023

If you’ve been eyeing functional programming or diving into Single Page Application (SPA) development I think no other tool is better suited for you than Elm. It stands out as a language that not only makes development delightful but also serves as the perfect gateway to the world of functional programming.


Statically Typed Bliss

One of Elm’s key charms is, believe it or not, its static typing, a game-changer when compared to JavaScript. The compiler acts as your trusty sidekick, catching errors before they wreak havoc at runtime. What sets Elm apart is not just the typing but the incredible clarity of compiler messages.

Elm isn’t just another functional language; it’s a dedicated tool for building SPAs. If you think in “React terms” it combines

  • TypeScript (language)
  • NPM (package manager)
  • React (rendering)
  • Redux (state management)

all in one single tool.

Haskell logo was created as a research langugage and as such was explicitly designed to contain experimental features and syntax.
That leads to many different “styles” which make it hard to learn fast.

The focus on a single target platform (the browser) allows Elm to be simpler than its general-purpose functional counterparts like Haskell.

Compared to other languages offering functional features additionally to imperative and/or object oriented patters, Lanugages like Ruby and JavaScript also allow but don’t enforce the functional style. Leading to the majority of code in these languages being in imperative.

Elm stands out by staying true to the functional programming style throughout. This makes it an ideal candidate for developers who are already familiar with more conventional programming languages and want to focus on learning the functional approach.

Simplicity

Elm’s elegance lies in its simplicity. It is a comparatively small language. Concretely that means there are less keywords and less concepts (no object orientation). That results just in general in less ways to achieve the same thing.

Of course this comes at a cost and there are certain “meta concepts” that cannot be abstracted away as elegantly as in for example Haskell (Elm has no type classes for example).

But in return it is just easier to learn “the whole” language than other languages like TspeScript logo
TypeScript’s claim is “TypeScript” is JavaScript with syntax for types. So you have to master JavaScript and then learn some more to benefit from the additional features of TypeScript.

TypeScript.

I do believe that “frontend code” should stay simple and stupid. Especially in web apps most of the complicated number wrangling should be done in the backend anyway. And there you are free to use any language you want.

(I do think the idea that having the same language is highly overrated, but that topic makes for a complete separate blog post).

Instant gratification

Another reason why I love to protoype experiments in Elm is that it easy to produce something anyone can interact with. The usual way to learn general purpose languages is to start with command line applications, which are not accessible to regular users. By targeting the browser you can create something that’s colorful and/or interactive with only a few lines of code.

A Tour of Elm

I’m thrilled to share “A Tour of Elm,” a beginner course tailored for those with no prior experience in functional programming or SPAs. In this journey, we’ll first quickly go over with the basics, covering essential concepts like HTML, CSS, and JavaScript that lay the foundation for SPA development. The course seamlessly progresses with interactive lessons, providing a hands-on Elm experience in digestible portions. What’s even better? You can dive right in without the hassle of installing any software – it’s all accessible directly in your browser.

Conclusion

Elm isn’t just a language; it’s a delightful experience waiting to be explored. Whether you’re new to functional programming or eager to master SPAs, Elm’s simplicity and focus make it the perfect companion. Embrace the joy of coding with Elm today!

Check out “A Tour of Elm” and start building SPAs with confidence.