It’s not a secret that Programmers like a great holy war. The echos of passionate programmers shouting with their banners high live on Stack Overflow for eternity.

The editor wars rage on. Like many other holy wars, object-oriented vs. functional programming is an ongoing saga. Most programmers use functional programming even if they consider themselves object-oriented programmers. Many languages have become pragmatic and support object-oriented and functional programming language paradigms.

I’ve enjoyed using the functional features of C# in the past and dabbled a bit with F#. I’ve never dove headfirst into a functional language like Elixir. I picked it up because I like The Pragmatic Programmer book and Dave Thomas as an author. I’m also interested in being able to do [concurrent programming with less hassle].

Workflow

My workflow is a split window with the book and my IDE side by side on my MacBook. I’m trying things out as the material progresses and am running through the exercises.


Programming Elixir

As I traverse the Programming Elixir book, I feel like I’m learning regular expressions. These terse expressions are power-packed; look at this beauty.

# The long way
add_one = fn (n) -> n + 1 end
IO.puts add_one.(1)
# The short way
add_one = &(&1 + 1)
IO.puts add_one.(1)

Building quick little inline functions will take little effort. It’s a bit cryptic for my tastes, but this is good if you’re doing quick and dirty code for a single task.

Look at that; with a few regular expressions and concise syntax, this code returns true.

match_end = & ~r/.*#{&1}$/
IO.puts "cat" =~ match_end.("t")

This code boggles my mind. I can have a set of regex libraries that are named appropriately. I can chain those expressions; what?!

I just convinced myself that learning Elixir is worth the investment.

Learning Elixir - Beyond the Basics