My experience as a beginner in Elixir. And why you should try it too…
Juan Pablo Yamamoto Jul 25
Lately, I’ve been using Elixir, an incredible programming language. You might not have heard about it, since it is not that popular right now. However, in just the few months I’ve been learning and playing with it, I have been able to realize how the future of software development looks like.
How it all started.
I became interested in Elixir not due to its performance or the functional paradigm; in fact it was the pattern matching part that got me interested. It’s a topic that I found a bit difficult to grasp in the beginning: ‘How could this make sense in a large codebase? How will people not get confused about the params that should go into functions?’. Those sort of questions arise when you first encounter Elixir’s pattern matching, but it was a challenge for me and I had to tackle it.
So I kept on trying, reading examples, practicing on my own, and eventually everything just made sense. Looking back, I think that it was just my unwillingness to think outside the familiar syntax that languages such as Python and JS had stamped in my memory what kept me from having a smoother learning curve.
Then, I was suggested to read ‘Programming Elixir’, and it was mind-blowing. All important topics you need to understand how to work with Elixir are comprised into a single book. After that, I felt way more confident when writing and reading Elixir code. And please don’t get me wrong, you won’t become a master of the language with that one book, but trust me when I tell you that you will be able to understand the syntax, the flow of execution of an Elixir program, and you will be capable of finding your way around to get the help you need in the documentation.
But, why do you like it so much?
So it started like a challenge as I already told you. However, after immersing myself into this language, now I’m engaged to the way things work with Elixir.
And I don’t want to dive way too deep into this because, if you’ve ever read another article about this language, I’m pretty sure that you already know how badly we, Elixir supporters, love the functional model, the million advantages of pattern matching, the beauty in passing messages, and the joy of having immutable data.
Also, just to make this list a bit longer, I should mention that it feels super cool to have meta-programming capabilities, just as it is easy to create supervisors and workers that will allow you to build complex systems without a hassle.
And if there’s something you didn’t understand about the previous list, there’s another reason to learn Elixir. 😉
So, is it just another eccentric new language?
Some of those do what they promise, some of those don’t. However, the importance in all this, is the fact that programming is going through a phase of transition.
Don’t get me wrong. No one can call into doubt the widespread demand for both interpreted languages and the old-fashioned compiled C or C++. Yet, it’s more and more clear that we’re going back to those times when compiling was the norm, and when developers used to craft their code in order to take advantage of every single bit of hardware resources they could to get the best performance. Some examples of this are Go, Rust, Haskell, among a lot of new languages.
However, times have changed, and most people won’t make the sacrifice of having the benefits of compiled programs, by leaving aside the so-comfy garbage collector or even the exception handling which, as basic as the feature may seem to some of us, at one point in time it didn’t exist. Sometimes it’s just easier to invest in better hardware resources, and let the coders develop and deploy faster by not paying too much attention to the little details. And that’s where modern languages enter the scene: to provide us with a proper balance between compilation powers and interpreted syntax.
A language for the problems of the modern internet.
As web applications become more common, and more users do their tasks online rather than having a program for every job they perform locally installed, internet services are demanding highly performant and reliable systems.
And that’s what Elixir does best. It is a language that’s suitable for concurrent and robust back-ends. That’s done by taking advantage of the functional paradigm while making the most of the asynchronous tools that the language has.
You might be wondering why you should give Elixir a try, while you can have a good enough back-end in basically all programming languages. And the reason lies on the fact that Elixir has been planned to be used in web services ever since it was created. Even though you can have a very good codebase in Spring, Rails, or Express, few of them will have the potential to escalate as well as the Elixir environment will allow.
Standing on the shoulders of giants.
Elixir had its first appearance in 2011, so it’s a relatively new language. Most people wouldn’t think of building large systems with a language in such an early stage, however, Elixir devs do. But why is that? And how dare we say it’s so great at hosting internet services?
- Despite Elixir being so young, Erlang is not. In fact, Erlang has been behind the scenes, powering the internet and telecoms for over 30 years (since 1986), making it one of the most reliable and mature languages by now. Elixir took all of that field experience, and unleashed it by compiling to the same bytecode that Erlang’s virtual machine runs. If Erlang is suitable and reliable enough for the Ericsson telecom network, it will surely handle without a problem the sort of critic systems of today’s internet.
- Ruby is another language which had a high influence in the language. José Valim, creator of Elixir, once used to be member of the core team of Ruby. All of his experience in that language, allowed him to create another programming language that resembles Ruby syntax, which is famous for its expressiveness and friendly-looking style.
If you think about it for a minute, the internet is way behind telecommunications systems such as mobile networks when it comes to being able to handle multiple connections throughout distributed systems. But how have phone companies been doing this for so many years? Erlang has been an important player in making this possible, and now, Elixir comes to give us that same power with a syntax that’s just eye-candy.
So… a one-trick pony?
Well, not really. In fact, despite Elixir’s reputation among web developers, it is also an excellent choice for other sort of tasks.
A project that has caught my attention is Nerves, which aims to provide an interface for using Elixir in embedded systems, making it a suitable choice if your target is to develop systems that run on devices such as the Raspberry Pi.
Also, in recent years we’ve been hearing about a library for using OpenGL with Elixir, which (when released) will open up a whole new world of opportunities for the creation of user interfaces, which is a topic that hasn’t really been exploited in this language so far.
Now, you might be expecting me to tell you about the great frameworks that you’ll find in this language for creating videogames, super complex computer learning, hacking tools, and so on, and so forth. But to be honest, they don’t exist.
Elixir is definitely worth it for other than implementing it on the server side, however, it isn’t either a jack-of-all-trades. This could be due to the little time it has been around, but I would also attribute its narrow variety of use cases to the specific characteristics of the language.
The language does an excellent job at running reliably and without downtime, however, that isn’t exactly something you will be looking for when creating a computer game. Most people think ‘Why would I choose such an eccentric language when something I already know will do?’, and in fact, they might be right; but always remember to use the right tool for the job.
However, this shouldn’t get you discouraged, and you should give Elixir a try anyway. In fact, the community will be glad to listen to all the ideas you could bring into the language to take advantage of it in whichever task you can think of.
Now that you mention it, what about the community?
I’m pretty sure that there are a lot of people out there who know way more languages than I do, however, out of the not-so-large number of languages I know, I have to say that the Elixir community is the most welcoming group of developers I’ve ran into.
In fact, it was surprising to see the core developers being so approachable. Not a lot of languages have that sort of close relationship among developers. And that is something that truly encourages the whole community to have an active involvement in the future of Elixir.
So, will you give it a try?
If you liked this article, don’t forget to share it so that I can reach more people, and maybe turn them into Elixir lovers too ❤️🖥️
If you have any question, or you just want to chat 💬 you can PM me, here’s my twitter (@JPYamamoto9).
Also, if you’re a Spanish speaker, consider checking out my website (https://jpyamamoto.com/), you will find interesting articles about a variety of topics.