4 ms·
I'd turn the question around. What does functional programming do better? What would you miss about not having it? I like OOP because it's like boxes where you
by muzani 7y ago
I'd turn the question around. What does functional programming do better? What would you miss about not having it?
I like OOP because it's like boxes where you can just plug one cable from one part into another. It's easy to write "contracts" in, as in assigning what object does what.
There are definitely flaws with this, in that it can get messy, but does FP solve it better? What exactly does FP do better?
- valand 7y agoMight be a little out of topic, but in this video there are some FP concepts being applied to DOD. https://m.youtube.com/watch?v=g1TsP60z2OQ https://m.youtube.com/watch?v=g1TsP60z2OQ
- Joof 7y agoFP (specifically the Haskell / Scala style) is easier to reason about in large scale applications. In particular, when using distributed systems. Two reasons: Immutability guarentees that the variable name changes when the underlying data is changed. Therefore, we don't have to track complicated state through the program or in other threads and processes. The type system catches many errors at compiletime. Fewer tests and easier to test. The trade-off is that the type system is slightly more complicated. Yes, it does have to be FP to handle this properly (type inference and higher order functions make it manageable).
- 0_gravitas 7y agoImmutability is a big one, and I absolutely love things like Elixir's pattern matching and pipe operator, I'll never program the same after coming into contact with them. And I love never really needing to write a loop or to have a "counter" variable, the declarative style just makes things much easier to read, write, and understand imho.