3 ms·
I have programmed in Java for some time now, and I have only recently dabbled in the functional world (Haskell, and still ways to go before getting any better i
by dhab 10y ago
I have programmed in Java for some time now, and I have only recently dabbled in the functional world (Haskell, and still ways to go before getting any better in it). My observations about it is that functional programming in typed and immutable world, provide better composability, reusability, terseness and maintainability. It does have it's drawbacks - Haskell is known to be difficult for estimating complexity, and i think it lags in many benchmarks.
I think OO can be thought of as an extension of functional programming, except it has some fancy names and idioms (single responsibility principle, polymorphism, abstractions ... ), but in the end are incarnations of functions. For example, int String.length(){..} could be thought of as length(char[]):int function, and List.size() as length(List):int. Node Tree.next(DepthFirstStrategy) could be thought of as traverse(Tree, traversalFunction):Node. But because OO languages tend to be mutable, they lose the benefits of the FP world. However, because they are mutable, they tend to perform better in benchmarks. I think OOP implemented in an immutable language would be over-engineered FP, whereas OOP implemented in mutable language is just glorified imperative programming.
With my experience so far learning functional programming, I think it is a better tool: All the things you can do in OO world, you can also do in FP world, mostly better. When performance is of real concern, then those bits could be factored out into some imperative code - whether it's done in OOP or assembly, C is a matter of choice.
In other words, I think in the order of technology preferences, FP should be prioritized higher than others although there seems to be a steeper learning curve. I think FP is not getting the attention it deserves as a better tool.