Functional Programming: The Road Not Taken

As a programmer, Object Oriented Programming (OOP) was the first paradigm that I learned. It’s principles helped me structure my code and manage my code base. Now let’s take a different turn. In comes functional programming!

It started with spaghetti code

When I was about 8 or 9 years old, I stumbled upon QuickBASIC on the second hand (or maybe third, fourth…) 286 PC I had in my bedroom. Ever since there was a PC in our house, I was intrigued by how it works. And here I find a piece of software that allows me to add my own functionality to my own PC. Magic! At the time, I was writing programs using the procedural programming paradigm. Back then I had no idea about different paradigms. I just made some humble spaghetti code in my free time.

Learning OOP solved many problems

Fast forward to when internet became mainstream. With a few buddies of mine, I was writing simple, procedural PHP scripts to make websites a little more dynamic. There was a MySQL database involved, but nothing was to complex or fancy yet. But once I tried to create larger programs, I felt like I hit a ceiling. Projects became hard to work in. I didn’t know how to structure projects or how to write maintainable code. I already learned a little object oriented programming, I used classes in my projects. But it was when I found out about web frameworks (like CodeIgniter, CakePHP and later Symfony and Laravel) where I learned how you can use OOP principles to manage a larger project. Essentially, I learned how to write code that I could still understand a few months later.

Shifting to a different paradigm: functional programming

I want to learn functional programming so I can learn a different paradigm. I believe that everything that turns your world upside down a little, makes you better at what you do. You learn looking at programming problems from a different angle. Even if I never solve a problem using a functional programming language ever again, I will benefit from learning different solutions to the same problem. Will I shift forever and never look back? Who knows? Probably not, though. But it will definitely be another tool in my problem solving toolbox.

In the introduction post for my new blog, I already mentioned that I’ve started learning Elixir programming language. It’s quite a different mindset, but I had a blast so far. I’ll write about why I picked Elixir in stead of other languages (like Clojure, OCaml or Haskell) and my experiences with it in the coming days.