How to turn your brain sideways

July 17, 2015

If you think in OOP, as I do, then functional programming is a great way to shake your neurons out of their complacency. If you already know FP, you may be smiling a little. Maybe you learned it a long time ago. Maybe it's natural to you. To me, it isn't.

The three basic stumbling blocks for me are:

The concept that all data are immutable

The concept of tail recursion as opposed to looping

The concept of pattern matching as opposed to traditional assignment

Yet, of course, those are perhaps the very foundations of functional programming. In theory, it all makes sense to me; but it doesn't yet stick to my brain.

In many ways, it is literally like learning a foreign language. Not just varying syntax and slightly different semantics. If you know C++, Java, Object Pascal, or any host of other languages, then you know that these feel "similar" in some ways.

Here's an analogy for you. If you have studied French, Spanish, and Italian, you have noticed they are of the same "family." They're not identical by any means, but you can often transfer knowledge from one area to another. That's how OOP languages feel to me.

On the other hand, functional languages feel to me as if I were trying to learn an Asian tongue like Japanese or Korean. The differences are not just fairly minor differences in syntax and semantics, but a difference in paradigm.

Learning Elixir is making me feel young and incompetent again. This is a nice break from feeling old and incompetent.