Last week I started reading Programming Elixir by Dave Thomas. As I like to read every part from the books I get, I discovered a very interesting present at the beginning: a foreword by José Valim about how the way we write code has evolved to take advantage of the underlying hardware, which also made me remember my first days with programming.

When memory was limited

At the beginning memory space was very limited. Programs had to optimize their memory use and computers weren’t fast enough to have Garbage Collection set in place. I remember back in the days when I started programming, when I first confronted myself with C and it’s tedious memory management. It was painful. Using malloc, free, not to mention the asterisks before a variable.

Memory wealth

It was clear to me that I disliked the idea of dealing with memory management. When I discovered Java 1.4 in 2004 I felt in love. Java came to me with two goodies out of the box: Object Orientation and Garbage Collection. The Object Oriented paradigm felt solid for me. At the beginning it wasn’t easy, I had to change my mind coming from procedural languages like Pascal and C, but somehow I embraced the idea of modelling the world with goats, wolves, cabbages and boats. As at that time more powerful computers were available, a language could start affording the luxury of having a Garbage Collection system. It felt like one of those vacuum cleaners robots (Sorry for the geeky comparison). Java let me define whatever I wanted and behind the curtains it’s Garbage Collector came to the rescue and did that malloc-free work for me. Awesome.

Back in those days, computers were doubling its speed in a regular basis. It was crazy. Playing the next Age of Empires implied almost the need of a new computer to run well. Programming languages lived confortable in this scenario where speed was delegated to the machine in most cases. But this tendency came to an end. Speed and small circuits produced a lot of heat that needed to be dissipated. Hardware companies started adding cores to their machines, and we, as programmers, had to take advantage of this new opportunity. Threads gained visibility, but it was awful. The programmer needed to control everything, creating the thread, sending data, processing, synchronizing, closing threads… but that wasn’t the worse. The main problem was the model itself: data was mutable and different processes shared memory, they had to synchronize state, use semaphores, etc. Nobody liked it. Programming languages needed to evolve.

Discovering parallelism and functional programming

I discovered parallel programming already in the university. The idea of sending computations to the different cores caught my attention from the beginning, but the tools weren’t so cool. Taking advantage of all available cores was a must. In 2012 I started using Scala. Scala was inside of the JVM, was object oriented and functional. It also implemented the actor model with Akka for concurrency. Scala had my attention for several years, but I am not sure if it was because I found it too mathematical or what, but that bored me, I didn’t like maths, I like to write software.

Ruby

I like to write programs that read well. with expressive code, like a well told story. I also like to enjoy my daily work. Which language accomplishes that the best? Yes, you got it: Ruby! And it doesn’t come alone, there is Rails, which in my opinion is one of the greatest frameworks in programming history ever. However as you may already know, tests in Rails are a little bit slow to run, parallelism isn’t its strong point and with enough size and traffic performance problems appear. Although a whole ecosystem grew to solve this issues, I don’t enjoy working with cache and this kind of “optimization” stuff, I prefer to focus on building new features.

Elixir

Since 2016 I am looking into Elixir. First I started reading docs and blog posts. Then at a hackathon I joined a team to build a little API. Today I’m thinking about migrating Kobabunga to Phoenix.

The language is great, it may not be as expressive as Ruby is, or maybe I am not so expressive with Elixir yet and everything is a matter of time, but it definitely makes fun to write code in it. If you come from Ruby, it feels like your old friend, but powerful. It somehow also feels as when I discovered Java, at that time it was with memory management, today is about parallelism and out of the box performance: Elixir, written on the Erlang VM, lets you have lots of lightweight processes that perform computations without any extra effort from the programmer. You also never have to worry about side effects in your data, as data in Elixir is immutable by default. Another pretty interesting concept is that you also have to change the way you think again. You abandon objects to see the world as data transformations performed by functions. This matches pretty well with the web development world, in which you invoke a function, with an unique URL, and you get a result.

Dave says you are going to feel like a noob. It is true. It is opportunity and it feels great. Programming has evolved again.