Hacker News new | ask | show | jobs
by pharmakom 1221 days ago
Scala is both more functional than F# (type system has more features) and less functional (more emphasis on OOP). I don’t think it’s a net improvement tbh. Better JVM access is nice though.
1 comments

Why would OOP and functional programming be at opposite ends of a spectrum?
A 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

[2] https://reasonablypolymorphic.com/blog/higher-kinded-data/

They aren't diametrically opposed, though OO methods obscure function composition (point-free style).
Minimising state vs hiding state behind interfaces / methods

The two can coexist in one code base but they are fundamentally opposed.

A 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.