Hacker News new | ask | show | jobs
by xupybd 1222 days ago
Would you recommend someone currently using F# to try out Scala?
4 comments

I don't have any experience with F#, so it's hard for me to say, but I love Scala. I think JVM is the best probably and could be worth your effort hard to say
F# does not really support pure functional programming in the sense that Scala does, so yeah. Use Scala ZIO and you will see what I mean.

It also has some other nice features that F# lacks. But F# also has some nice things that Scala lacks. Overall I think it's worth to learn it for learning new concepts, but F# is already great, so don't expect Scala to be way ahead and even worse in some ways (syntax, no type providers, ...)

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.
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.
Scala is also an FP language that places emphasis on types, but it does so in a way very different from F#, which is still based on Hindley–Milner. I think Scala is worth checking out for a different perspective.