DEV Community

Juan Pablo Yamamoto
Juan Pablo Yamamoto

Posted on

My experience as a beginner in Elixir. And why you should try it too…

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.

Last but not least, it is quite easy to run asynchronous code without the callback hell of JavaScript, and having your code take advantage of all of your computer’s cores without much delicate effort is a delight.

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?

There has been a growing trend in the last couple of years around modern and exotic programming languages. People seem to be moving on from the hype that interpreted languages such as Ruby, Python and PHP brought to the software scene; even JavaScript is (less drastically) being replaced by a set of languages (supersets, transpilers, and some more fancy names) that promise to provide every single feature you could ever need.

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?

  1. 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.
  2. 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.

It’s really easy and quick to get help in the Elixir forums, or to get into an interesting chat about the latest Elixir feature in their Slack group.

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.

Latest comments (13)

Collapse
 
kasvith profile image
Kasun Vithanage

Excellent article, I was taking an intro to Elixir after seen its capabilities. We are forced to learn OOP and we think its a holy grail. With elixir, I feel I've missed many things in my life and I want to learn something from it as well. To have a paradigm shift towards the functional world.

If you have any beginner projects to kickstart when learning, please mention so others can try to build something cool while learning

Collapse
 
devjoseweb profile image
Junior

Work market in Elixir in the world?

Collapse
 
jpyamamoto profile image
Juan Pablo Yamamoto

The market is not as large as those of other languages, but the demand is growing rapidly and it is generally very well paid

Collapse
 
devjoseweb profile image
Junior

Tanks Juan Pablo !

Collapse
 
cotcotcoder profile image
JeffD

Do you need some functionnal knowledge to start with Elixir or it's ok for a classic Python/PHP developper ? There some difficulty to learn fonctionnal programming for a object oriented programmer?

Collapse
 
jpyamamoto profile image
Juan Pablo Yamamoto

You'll certainly have to learn functional programming. However, I suggest you do it on the go as you learn Elixir. In fact, I strongly believe that the functional approach will most of the times be easier than Object Oriented Programming. Something that a lot of people do when they're just starting with Elixir (myself included) is trying to simulate what they would do in OOP, in functional code, and that's just a bad idea. But once you get used to thinking functional, your code will be easier to understand and debug. And the best way to achieve that is by practicing 🤓

Collapse
 
giovannicodes profile image
Giovanni Cortés

Actually I am working in Elixir Projects about 3 years. I love the language and I have replaced all my freelance and hobby projects from Python to Elixir.

Now I am working in a transportation app with Elixir using GraphQL as API interface and is delicious

Collapse
 
kasvith profile image
Kasun Vithanage

Are you using phoenix ?

Collapse
 
giovannicodes profile image
Giovanni Cortés

Yes! I'm still using phoenix for API (Rest and GraphQL)

Collapse
 
jpyamamoto profile image
Juan Pablo Yamamoto

That's great! I've been through that Python to Elixir transition too, as I used to work most of the time with that language. But now I realize, Elixir's the way to go!

Collapse
 
dance2die profile image
Sung M. Kim

I gotta admit, I've been slow on learning Elixir 🤔 because I couldn't vision myself using it for any projects right now 😅.

I kind of have an idea (although a bit vague) on why and where to use Elixir, which will push me to learn Elixir more 😎

Collapse
 
jpyamamoto profile image
Juan Pablo Yamamoto

That's something that happens to a lot of people. But trust me, once you learn Elixir your whole mindset changes, and you start noticing the advantages that Elixir could bring into different scenarios. Keep going and remember that there's a big community of devs who will support you in your learning path, myself included.

Collapse
 
dance2die profile image
Sung M. Kim

Thanks Juan. I will keep going and throw myself out there 🏊