Every developer hits that inevitable itch: what’s next? Or at least I hope they do! I find myself often getting bored at nights after the family goes to bed and on the weekend. Leaving myself looking for something productive to do. Those that know me know that I am a tinkerer. I love to get get my hands dirty and figure out what I don’t know. It is one of the many things I enjoy about being a developer. Fortunately, I am able to do it as a career too.
If you clicked on this article, then you know that I have chosen to explore the Elixir programming language. What you don’t know is that I am doing it to get familiar with the functional programming paradigm.
I’ve worked with many popular languages like Python, C#, Java, JS and they’ve served me well. They’re battle-tested, well-documented, and widely used in both industry and hobby projects. But they after a while they all feel the same just with different quirks. I don’t mean that they are literally the same, but many programming concepts translate between languages.
This led me to exploring functional programming.
Why Elixir?
Now that you made it this far, let me explain why I landed on Elixir. The answer isn’t as straightforward as you think. There are plenty of languages I could have chose to explore. Scala, Ocaml, Haskell - I am totally joking, no one actually considers Haskell. However, I did seriously consider Scala for a few reasons, but mostly due to its interop ability with Java and use with the many Apache products.
But here’s what made Elixir stand out to me:
The Erlang Legacy
Erlang has been powering telecom systems since the 1980s. Powering massive phone networks that demand five-nines uptime (99.999% reliability). If the Erlang VM can keep billions of phone calls alive without dropping, what could it do for modern apps? If you really want an answer to that question take a look at Whatsapp and Discord. It was their language of choice to power their messaging systems.
Concurrency
In other languages, concurrency often feels like a beast to tame. Threads, mutexes, race conditions - it’s enough to scare away anyone. Elixir’s approach, using lightweight processes and supervisors, promised to make concurrency natural and approachable.
Functional Programming
This point makes a lot of sense if you actually read through the beginning part of this article.
The Community
While the ecosystem isn’t the largest or most mature, every post I read, every talk I watched, gave me the sense that the Elixir community is passionate. That felt like the kind of place I wanted to be part of.
Installing Elixir
Now we are getting to the meat and potatoes of this article - the section no one cares about. Let’s see how to set up Elixir. Good news is that it is simple.
On macOS
If you use Homebrew:
brew install elixir
On Ubuntu/Debian Linux
Update your package manager and install Elixir directly:
sudo apt-get update
sudo apt-get install -y elixir
On Windows
You have a few options, but the one that I prefer is to download the official installer from elixir-lang.org.
Verifying the Installation
After installing elixir, verify it installed correctly and are able to run commands from your terminal by:
elixir -v
You will see something like this when you run the above command:
Erlang/OTP 28 [erts-16.0.2] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]
Elixir 1.19.0-rc.0 (ba0f393) (compiled with Erlang/OTP 28)
Note: Your output could look different depending on what version of Erlang and Elixir you downloaded.
Getting Started Coding
By far the easiest way to just get started writing Elixir code is through the iex that ships with Elixir. If you’ve ever used Python’s REPL or Node.js’s console, the iex should feel familiar.
To get started type:
iex
Then you are free to starting exploring the Elixir programming language.
iex(1)> 1 + 1
2
iex(2)> “Hello” <> “ World”
“Hello World”
The example above is simple, but it shows the kind of experimentation you can do right inside the interactive shell. If you’ve worked with languages like Python, Java, or C#, you might stumble when you see the “<>” operator - it looks unusual at first glance. In Elixir, though, “<>” is how you concatenate strings, whereas many other languages use “+” or some sort of concat function. This is, in a way, what I meant earlier when I said that different languages have their quirks.
iex(1)> String.upcase(”hello”)
“HELLO”
iex(2)> h String.upcase
Another wonderful feature of the interactive shell that I discovered is the ability to pull up documentation directly in the shell by using the command “h”.
def upcase(string, mode \\ :default)
@spec upcase(t(), :default | :ascii | :greek | :turkic) :: t()
Converts all characters in the given string to uppercase according to mode.
mode may be :default, :ascii, :greek or :turkic. The :default mode considers
all non-conditional transformations outlined in the Unicode standard. :ascii
uppercases only the letters a to z. :greek includes the context sensitive
mappings found in Greek. :turkic properly handles the letter i with the dotless
variant.
## Examples
iex> String.upcase(”abcd”)
“ABCD”
iex> String.upcase(”ab 123 xpto”)
“AB 123 XPTO”
iex> String.upcase(”olá”)
“OLÁ”
The :ascii mode ignores Unicode characters and provides a more performant
implementation when you know the string contains only ASCII characters:
iex> String.upcase(”olá”, :ascii)
“OLá”
And :turkic properly handles the letter i with the dotless variant:
iex> String.upcase(”ıi”)
“II”
iex> String.upcase(”ıi”, :turkic)
“Iİ”
Also see downcase/2 and capitalize/2 for other conversions.
And it’s not just docs. In iex
you can:
Use
i value
to inspect the type and metadata of any expression.Tab-complete functions inside modules.
Explore your Mix projects interactively once you start building them.
In other words: iex
isn’t just a toy. It’s a core developer tool.
Compared to Python’s REPL or Node’s console, it felt like Elixir assumed I’d spend a lot of time here
Wrapping up Part 0
By the time I was ready to go to bed, I had successfully installed Elixir and explored the language’s basic types and syntax through the interactive shell. On the surface, Elixir is approachable due to it’s simplified syntax (thanks to José Valim’s design choice to model the language after Ruby).
I thoroughly enjoyed what I have explored so far, but I know that I haven’t even gotten into anything complex, or experienced writing anything that the language is known for.
Future parts of this series is going to see me explore functional programming, and some mini-projects. I do have plans to write a larger project in Elixir once I can get a grasp of what I am doing - but do I ever know what I am doing???
Let me know your thoughts on Elixir. Do you think I should have chosen a different functional programming language? Tell me why it shouldn’t have been Haskell.