An Empathetic Functional Language

I've been writing Elixir code for over a year. Never have I been more excited about the prospects of the language and its community. The language is young but very promising. Many smart people are getting involved. There's a hell of a trajectory here for a language that released 1.0 merely 6 months ago.

I've been wondering what is it specifically about Elixir that has pulled me in and prompted my involvement in the community. In a word, it's empathy. More specifically, empathy for the user.

This empathy is demonstrated in a variety of ways. Many have been extensively discussed: the natural syntax, the inviting community, the extraordinarily involved creator and the tooling. I'd like to discuss something different that's only becoming apparent to me now, after significant time using the language.

Peeling the Onion

One of the most powerful ways Elixir shows empathy to the user is by creating layers of abstraction. A natural path for learning the language emerges via these layers, which slowly introduces the new user to increasingly different, challenging and powerful concepts.

Why is this interesting? After all, many languages succeed at teaching newcomers and guiding them through the learning process. I believe it is interesting because Elixir also possesses many characteristics that are traditionally thought of as challenging. Elixir is a functional language; there is no state (though there are patterns for representing state-like things). It is a concurrent language that uses the actor model and message passing. It is homoiconic. And yet, even with these "difficult" and "advanced" features, the language manages to make the learning process feel natural. Let's talk about a concrete example -- me.

I dove into Elixir the way many do, via its interactive shell iex. This allowed me to toy around with the syntax, call some functions and define simple modules.

Next, I created some standalone files. Elixir conveniently provides the *.exs extension for scripts to be run directly (compilation happens inline). This let me try more complex ideas and even build some little scripts to do real jobs.

After this, I created a project with the standard directory structure and used some dependencies (provided by mix and hex). All this time, I had yet to dip my toes into the terrifying water known as OTP.

Finally, with confidence from my earlier successes, I started reading about and working with the OTP concepts that Elixir provides (borrowing or wrapping the same concepts from Erlang). I was successful here even though I had failed in my previous attempt to learn OTP in Erlang. Why? As my confidence grew with Elixir I had more tools and support to remain steadfast in the face of truly new concepts.

I still don't write many macros, but luckily there's a great book available.

The empathy of the language was ever-present with me through my learning process. Standard libraries were clear and well documented, the community was helpful and there were many great learning resources. But, more fundamentally, the language never seemed to force me to learn too many new things at once. Each time I pushed further with the language, it asked an appropriate amount from me in return. These small challenges always seemed to give me more in return than the investment I put into learning them. This positive reinforcement cycle is both exhilarating and empowering. What a ride.

Rubber Meets the Road

This empathetic reinforcement cycle manifests itself in the Elixir community in many ways. The language and project structure allow individuals to participate in a project that heavily relies on OTP without knowing a single thing about it. Elixir projects tend to use OTP as the backbone for building more familiar abstractions that are easier for the broad spectrum of developers to comprehend and work with. They provide patterns that newcomers can comprehend quickly and use to make meaningful contributions to exciting tools for the community.

It's hard not to be positive about a language when you're helping to push it forward within weeks of getting involved.

I built a small internal application at work in Elixir and I've been surprised by the number of contributions from my teammates. Some have deep experience with functional languages while others have never used a functional language before.

Elixir allowed me to provide simple, clear and familiar patterns that willing contributors could follow regardless of their prior programming paradigm experiences.

The best part, though, is that once the hook is set it becomes exciting and challenging to learn about the more complex and powerful aspects of functional programming. Elixir is not a watered-down functional programming language, quite the opposite. Its focus on empathy in concert with these attributes, however, feels unique and wonderful to me.

Update: I removed references to Elixir being a "pure" functional language.