Hacker News new | ask | show | jobs
by depressed 2631 days ago
If functional programming were implemented as widely and abused as much as OOP is, would it really fare any better?
2 comments

You can already see examples of this.

Take callback hell. Opaque callbacks are the functional equivalent of goto statements.

Also, many functional programmers, particularly Haskell programmers, seem not to care about readability and maintainability. They're focused on maximizing their own productivity as an individual coder, and writing cool concise and abstracted code that might not actually be easy for another engineer to understand and modify.

The difference though is that good functional programming is still quite common whereas good object oriented programming seems to be rare (the one exception being microservices).

> Opaque callbacks are the functional equivalent of goto statements

in some sense they are worse because you can't just grep for the call site of an anonymous closure, like you can for a goto, it could be almost anywhere in the code base

>particularly Haskell programmers, seem not to care about readability and maintainability

Say what you want about the foreign-ness of the syntax, but Haskell code is some of the most maintainable code out there. I can often times dive into another person's haskell code and grok it more easily than the equivalent code in a "friendlier" language like python or ruby, nevermind a more comparable language like scala. Haskell is also a breeze to refactor, the compiler and type system make changing and moving arbitrary chunks of code around pretty straight-forward, even when the code is using abstractions you're not familiar with; something which cannot be said for many other languages. The biggest downside to haskell (apart from the learning curve) is having to deal with cabal+stack.

exactly, I feel the same way. OOP is often criticised from functional programming, but also from data-driven programming, for example. You never hear functional programming advocates criticise data-driven programming. The use cases are so different that it wouldn't make sense.

To use OOP properly is probably as complicated as doing functional programming or data-driven programming properly. The "problem" is that the learning curve is much less steep and the use-cases more extense, so obviously there's a lot more people misusing it.

I've seen data-driven code and it is full of OOP. Those are hardly orthogonal concepts. Arguably DD (on the pedal to the metal C/C++ level) doesn't quite match the OOP choir in terms of looks.
I totally agree, and I believe any serious programmer should have at least some basic knowledge of the three "paradigms", as the core concepts are relevant in all cases, and there are many techniques that can be applied in different "paradigms". I didn't start talking about it in order to keep the comment short, but maybe it was a bit confusing.