Orthogonality in Programming: Why Elm Gets It Right

nickciolpan

Nick Ciolpan

Posted on September 11, 2024

Orthogonality in Programming: Why Elm Gets It Right

The debate over the perfect language syntax is far from over—in fact, it’s constantly diverging. And I believe the mainstream is heading in the wrong direction.

When evaluating a language, we typically look at factors like expressiveness, readability, abstraction, and consistency—familiar metrics.

JavaScript, on its own, isn’t perfect, but it’s not terrible either.

The real issue isn’t just JavaScript—it’s the language of the web. To deliver a complete web experience, you need to juggle multiple languages and syntaxes and up with a chimera. Modern tooling leads to something like this (React devs will know this well):

<div 
    className="..." 
    style={{...}} 
    onClick={()=>...} 
    data-testid="...">
    {....}
</div>

Enter fullscreen mode Exit fullscreen mode

In order to cover all the constructs that can be expressed in a web interface, the language expands its domain to cover all possible meaning and interaction. This is the equivalent of writing 100 branching if-else statements to account for every condition.

But if you’ve grown up with this syntax, you’re likely blind to it—and that’s completely normal.

What’s missing is orthogonality— being the ability to express a large set of concepts with a small set of constructs.

Now, Elm gets it:

div
    [ class ...
    , style [color: ...] 
    , onClick ...
    , attribute "data-testid" ...
    ]
    [ text ... ]

Enter fullscreen mode Exit fullscreen mode

In Elm, everything revolves around functions and lists—lists of values, lists of functions, and functions that operate on lists.

Why is this important? Combined with type safety, it provides both predictability AND flexibility—two concepts that may seem contradictory to the uninitiated.

💖 💪 🙅 🚩
nickciolpan
Nick Ciolpan

Posted on September 11, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related