My functional path

Kamil Tałanda
3 min readSep 11, 2022

I started my functional programming journey a while ago. For a couple of years, I’ve had quite a few aha moments discovering new concepts that drastically changed my way of thinking and looking at the code.

First, I saw the power of immutability and how important state management is. Of course, you can happily change everything around using mutable variables, but eventually, you will pay the price. I learned this the hard way, and thanks to my functional programming exposure, I finally understood where the pain comes from.

Next on the list were the higher order and curried functions. I remember my confusion when I first encountered something like function sum = a => b => a + b in JS. What is this for? And most importantly, how could it ever be helpful? It took me a while to get used to the fact that functions can be passed around, used, and partially applied to help build a robust, flexible code.

Once I saw the power of functions, the map, filterand reduce came into the picture. I saw them and kind of understood them much earlier, but I was missing the power that comes with those simple methods. They introduced me to the streams and finally started getting what rxJava is all about. Thinking about the data in the manner of flows was another eye-opener that changed my way of coding. I started being allergic to the for-loops and mapped whenever I could.

Composition over inheritance. I knew it early on from Effective Java written by Joshua Bloch. I got it in the OOP context, as I thought, but looking at it from the functional perspective was another milestone in my coding career. As Brian Beckman said in one of his lectures Composition is THE way to control complexity. At the moment, I think it is the only right way if you build something that you want to maintain in the future. Building small blocks that are very simple, easy to verify and mix helps me every day since I understand the power of composability.

I was astonished once I finally understood what referential transparency and function purity could offer. Everything is so much simpler once you can entirely rely on your functions and be sure that if you call it twice with the same parameters, it will produce the same results. The composition finally becomes simple, and there are fewer nasty surprises. Leaving the side effects to the edges and coding as much as I can without it is the goal I’m chasing now, and with every feature I release, I’m getting better at it.

Now I’m discovering the fascinating realm of Functors, Applicatives and Monads, but I barely grasped the surface of the topic. I start getting the idea of computational context, but I see a long way in front of me to finally understand and consciously use it. I know that Monad is just the monoid in the category of endofunctors, but it will take a while before I understand something from this sentence. Once I know it, I will write a blog post about it. Let’s see if the Monad cursethat says Once you understand it you will loose the ability to explain it is true.

Functional programming changed my coding, and I’m happy that I took some time to see where rxJava came from a few years ago. I know I started a lifelong journey. There is much to understand in programming by learning languages such as Haskell, Scala, Clojure and beyond with all the mathematical foundations, including Category theory, Type theory etc., and I’m glad I’m on this path.