Re:Functional programming is not popular because it is weird...
by ladyattis on Tuesday September 14, 2021 @09:29AM
(#28524480)
I tend to mix OOP and functional together as I use objects as a way to relate functionality or steps within the process. I almost never use objects as a means to model the actual data. At most, I use objects in this instance as glorified structs. The only real benefit that OOP as implemented in most languages has is the ability to write to an interface whether you use an explicit interface type or an abstract class which concrete implementations derive from. Like Bob C Martin said in many lectures the inversion of control is really where OOP shines. Anything else most other paradigms do it better.
[ Parent
| on HN ]
Re:Functional programming is not popular because it is weird...
by Tainnor on Tuesday September 14, 2021 @10:01AM
(#28524937)
I find that OOP languages (as long as they support FP and immutability) have the benefit of using classes as nothing more that first-class parameterised modules (without any mutable state) so I don't have to repeatedly pass arguments from one function to the next but can look them up from a shared context. Haskell doesn't really have that option, although people have told me that OCaml can do that.
Re:Functional programming is not popular because it is weird...
by playing_colours on Tuesday September 14, 2021 @02:56PM
(#28529296)
You are describing the way I wrote in Scala, and now in Python: using class instances as that are initialised shared contexts like shared database connections, serialisers, etc.
Re:Functional programming is not popular because it is weird...
by sfvisser on Wednesday September 15, 2021 @03:02AM
(#28536105)
Yes, classes as glorified Reader monads :)
Re:Functional programming is not popular because it is weird...
by adverbly on Tuesday September 14, 2021 @07:22PM
(#28532891)
This is exactly how I roll these days! Avoid classes until I find myself doing too much argument plumbing, or having too many arguments to a function. Also love me some memoization. If I'm honest, I haven't tried aggressively using closures, but I suppose that would have been another way to do it...