Has learning a functional language changed the way you use or think about OOP languages?

My biggest takeaways while learning and now preferring FP that have changed my perspective on OOP languages is the following (some of them are not good):

  1. Quarantine side effects. This has help a lot with reducing bugs and making unit testing easier since it means that my pure functions aren’t intermingled with all of the effectful code.
  2. It made me realize how much harder OOP is to get the same result. Mutability adds complexity that most of us don’t even notice: Time. When a value changes over time you pretty much have to us a debugger to see it change and why it’s changing. In FP it’s just a new binding. Also, coupling behavior with data makes it even harder to manage because you end up with temporal coupling when one property or method changes a value and a method was depending on the value of a member var to be in a certain state. In FP, new state changes are very explicit (and far simpler). State (data) goes in… and new state comes out.
  3. The bad part is that FP has made me realize that is so much simpler to program in so I get annoyed in OOP languages when I have to do something simple like create a class just to add behavior to my program when a simple function will do.
6 Likes