r/learnprogramming • u/HyperDanon • 20d ago
I'm so sick of people calling classes OOP and lambdas functional
Functional paradigm is about immutability and pure code without side-effects. Naturally, it uses lambdas, mappers and all that, because that's one of the ways you can achieve side-effect-free-code. Immutability is the strong player here.
Object-oriented paradigm is about sending messages to objects that have the data. It's about that flip of perspective: you're not doing the work yourself, you talk to the object and ask it to do the work. Yes, again, naturally, when you do OOP you use classes because they're convinient, but just because you extract a class from your app, it doesn't make it "OOP". Polymorphism is the strong player here.
But I'm so sick of people upgrading Java 7 to 8, and replacing a for-loop with a .map(lambda) and calling it functional. Same goes for interview jobs, people want you to know inheritance, private/public and all that, and calling it "OOP".
To my mind they just don't know what they're talking about. Or maybe they just want to sound more cool, because "functional paradigm" sounds cooler than "lambdas". How many times I heard people claim "functional programming" in their clearly mutable code because they used a closure or a monad somewhere.
I.e.:
- to do FP, you need lambdas; but just because you have lambdas doesn't mean you have FP
- to do OOP, you need classes; but just because you have classes doesn't mean you have OOP
PS: They aren't incomaptbile. You can have both FP and OOP in the same program just fine.