Elixir: my nerdy, misunderstood friend

I met Elixir in 2017. Elixir was the quiet, unassuming type. Polite, a bit nerdy, and intelligent. We had a few brief, albeit meaningful conversations. Elixir talked about its interest in telecom/VOIP/OTP. This wasn’t my current interest at the time. I had been working in BI/Analytics for nearly 7 years. But I appreciated the need for things like fault tolerance in telecom.

Elixir droned on a little too much for my taste about telecom, as well as its process-oriented paradigm. I zoned out between phrases like “process trees” and “gen servers”. However, I did enjoy hearing about Elixir’s functional paradigm. With functional programming, I believe we are seeing the next “big” disruption in software engineering, and one of the biggest since OOP’s emergence.

Elixir reminds me of my childhood friend, Justin. Quiet, yet deceptively strong. Justin was vigilant about his tae kwon do training. He was tall, pretty nerdy, and often picked on by others. He always wore baggy clothes, so we never knew how strong he really was. Fast forward to college, we are at the student gym. You know the type. Where most of the guys are there to pick up women–stacking the most weight they can for a single rep of the bench press. And where most of the women are trying to avoid the creepy guys. We saw these two guys stacking as much weight as they could on the leg press. I count it up. 625lbs. Holy hell. They each complete a single press, and then high five each other and give that creepy “Did you see that, ladies” stare at the women on the treadmills. “Do you mind if I jump in on the leg press?”, asks Justin. The guys snicker at this tall, skinny, nerdy, African-American kid. Justin gets in position. I’m a bit nervous for him, because I can feel the kind of jeers he’ll get if he fails. Justin does 20 reps. Gets up, quietly thanks the two guys, and walks away.

That’s Elixir. Back in 2011, Elixir, like many functional languages, was not well-known and not really respected. 7 years later, Elixir has quietly crept into our minds. Elixir goes about its daily business, with no need to flex. Yet, when necessary, Elixir can provide a ton of extra power.

Up until yesterday, I believed Elixir was suited mostly for telecom/VOIP/OTP applications, and was overkill for something like say, a web API. Then I heard this phrase:

Elixir is not necessarily built for telecom; it’s built for concurrency. And high-traffic web apps benefit from concurrency.

High-traffic web APIs need to be concurrent–and fault-tolerant. Elixir’s strength is that it manages concurrent processes much like your CPU does. For simplicity sake, let’s say you have a single-core CPU and you kick off 3 things on your laptop all at once: (1) you run a complex statistical analysis function in R that takes 90 seconds, (2) you open a text file that takes 1 second, and (3) you open Spotify, which takes 2 seconds. If your CPU only processed these serially, then you’re waiting 93 seconds just to open Spotify. But your CPU is intelligent, so it’ll process a little of your R script, then switch to process the opening of your text file, etc. The switching of processing has some overhead, so your text file may take 1.3 seconds to open instead of 1 second if it was processed in a vacuum.

Give Elixir a shot. If you’re expecting high traffic for your web app–even if it’s not a telecom app–use Elixir.

Your Thoughts?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s