4 ms·
Why would OOP and functional programming be at opposite ends of a spectrum?
by cbeach 4y ago
Why would OOP and functional programming be at opposite ends of a spectrum?
- pharmakom 4y agoMinimising state vs hiding state behind interfaces / methods The two can coexist in one code base but they are fundamentally opposed.
- SOLAR_FIELDS 4y agoA common joke in my previous org that heavily used Scala with functional paradigms is that an engineer’s first few PR’s were often implemented in “Scava” since Scala lets you lean into OO paradigms. It kind of means that there are two (or more) “right” ways to do things in Scala which IMO is a detriment to the language. This is where other languages like Python got it right by introducing the concept of “Pythonic”. You can do weird stuff, but it won’t be accepted into the zeitgeist that was defined by the benevolent dictator.
- theCodeStig 4y agoThey aren't diametrically opposed, though OO methods obscure function composition (point-free style).
- ghostwriter 4y agoA good example would be [1], where covariance and contra-variance are offered to you by the language due to its relation to OOP and the need for subtyping for it, whereas you'd probably be better off if you forgot about their existence (most of the times) and designed everything with Invariance and higher-kinded data [2]. [1] https://docs.scala-lang.org/tour/variances.html https://docs.scala-lang.org/tour/variances.html [2] https://reasonablypolymorphic.com/blog/higher-kinded-data/ https://reasonablypolymorphic.com/blog/higher-kinded-data/