Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login

I worked quite a bit with F# and Scala.

I really like F# pipelines and function declaration syntax.

On the other hand I've found Scala's case classes cleaner than F#'s (maybe that's because I am coming from an OOP world).

Additionally F# has a cleaner pattern matching compared to Scala.

Both languages have very good support for actor model concurrency (love akka actors and .net agents)

I think that if F# would have had a rich ecosystem the way Scala has, it could become a real contender.

(my 2 cents on F#)



sort by: page size:

F# would probably be a better comparison peer to Scala than C# would IMHO

I have a special place in my heart for F#. While I do a lot of Scala these days, professionally and open source, F# was my first introduction to functional programming that eventually got me into Scala.

F# and Scala are extremely similar languages: garbage collected, hybrid OO/FP guest languages hosted on a widely-used runtime. Even though the superficial syntax is very different, and the advanced language features they provide are pretty different, the core experience of modelling your data as "dumb" data structures and transforming collections of data using higher-order functions is almost identical.

Scala ended up winning out for me due to a broader ecosystem (Much more OSS Java than OSS C# out there), better tooling (Visual Studio's F# support was always disappointing...), and easier interop (F# <-> C# feels a lot more clunky than Scala <-> Java). But I can easily imagine an alternate universe where I'm happily writing F# all day, and almost nothing would be different from my current work writing Scala.


I've previously used Ocaml at my last job and use Scala at my current one, it's interesting that F# (just judging from this blog post) looks more similar to Ocaml than to Scala - like they've more aggressively pulled out syntax and embraced partial application etc.

I'd always assumed F# was to C# what Scala is to Java - and I think that probably does represent their design goals, so I wonder what the different considerations were that led to them being relatively quite far apart.


Disagree as someone who has programmed in both Scala and F#; I found F# pretty much could do the same things just in different ways. In F# I found more ways to squeeze performance than in Scala which by comparison is bloated. For the data applications ive written F# wins usually especially with ad-hoc tactical apps and in my experience was easier to teach than Scala which is not as coherent of a language.

In what way do you consider F# better than scala? Especially with the recently released, revamped Scala 3?

are there features that F# has that scala is missing (aside from reified generics)? Because there are at least a few critical features scala has that F# is missing that influenced my decision on preferred language.

I've only used F#; have looked at Scala a bit but haven't used it. I find F# feels fairly natural and pleasant if you know C# and like ML-like languages. I've mostly treated it as a nicer C# rather than a true functional language, though; features like sequence expressions (generate an anonymous IEnumerable with yields without having to declare and define a function etc.) and object expressions (generate an instance of an anonymous class that inherits from some interface) let you write imperative code in a more "value-oriented" fashion and with less ceremony. Algebraic data types and pattern-matching are also nice to have, of course. My impression is that Scala is much more conceptually interesting.

The type inference is much better in F#, the syntax is much terser, discriminated unions are much cleaner than case classes.

Also .NET/Mono benefit from a VM with much better performance characteristics (tail calls, value types).

Scala has its own set of benefits too (incredibly powerful type system, Scalaz, bigger community).

F# is primarily a functional language with some OOP bits tacked on. Scala is the opposite.


F# is more of a .NET analogue to Scala.

F# is the Scala for .NET.

What about it is lacking?

I'm asking because at one time I was weighing moving to Scala, but the F# algebraic types and compiler seemed more complete.

Is it syntax? that does take some getting used to.


The design approaches for Scala and F# are different though: F# is mostly FP with some OO tackled on - mainly influenced by OCaml. Scala unifies both OO and FP.

> If you know f#, you practically know Scala - well, enough to be instantly productive.

Sure, but actually you can say the same about knowing Java/C# and then moving to Scala. But in that case you're missing a whole lot of features that Scala offers that F# does not: typeclasses, traits, implicits, etc.


I really wish F# was as approachable as Scala is. Every time I consider it I see no strong selling point. Loosing ReSharper + a steep learning curve make it too much for me.

I've spent a fair bit of time with both. Personally, I don't find the two to be all that comparable -- they're fairly distant cousins.

F# tends to stick much more closely to its ML roots, and fairly scrupulously retains a more ML flavor except when necessary to achieve good interop with the .NET ecosystem.

Scala, on the other hand feels less to me like a dialect of ML and more like an ML-flavored object-oriented language, because it mixes in OOP-style features much more freely. Its algebraic data types, for example, are explicitly implemented as class clusters. A lot of people like this, others see it as an anti-feature. Where you fall probably depends on how you feel about the relative merits of OOP and FP.

It's also, for better or worse, less concerned with maintaining good interop with the rest of the ecosystem. Consuming F# modules from C# isn't always pretty, but it's always possible. There will be C#-friendly wrappers, but creating them is a matter of aesthetics rather than necessity. Consuming Scala modules from Java, though, frequently requires creating wrapper libraries. On the upside, this does mean that Scala gets to have things like typeclasses, which the F# team has kept out of the language due to concern about how they would impact interoperability with the rest of .NET.

Last but not least: F# has type providers. Scala has implicits. F# has quotations. Scala has more stuff that's also called implicits.


Why would you compare C# (although they keep adding functional programming concepts to it) to Scala, instead of comparing F# (which can commingle with C# wherever you need it) with Scala?

I haven't looked into F# or Scala too much, but I bet F# comes out looking far better, because it was so deeply inspired by Haskell (but made practical).


F# started out as integrating much better and being very selective of features, whereas Scala has been happy to add all sorts of features, to my understanding. F# has been feature complete for a while, mainly getting quality of life improvements and updating to maintain C# compatibility.

I have been debating whether to learn Scala or F# in my spare time. F# seems to be the more pragmatic choice. Doesn't go the insane way of FP that Scala does with complicated libraries or convoluted inheritance hierarchies. The Scala community seems more divided than the F# one with multiple competing ecosystems/libraries for achieving the same thing. My interest lies in webdev/backend and F# seems to be an obvious choice with asp.net and it's supplanting libraries. Not sure how Scala fares, but i guess it's not the primary use case for it. On the surface I kind of like the syntax of Scala, it's very familiar but I fear that I would get more frustrated the deeper I would dig because eventually you have to integrate other people's code and the way most of it is written looks to be like haskell in disguise. Not really sure about the pros/cons.

True. I was referring to similarities in things like higher-order functions, tail-recursion support, pattern matching, option types and so on.

I feel the intersection of FP features between F# and Scala is much greater than C#/Java.


I also find F# a joy to work with. Not only because it's .NET which I find nicer to work with than the JVM, but also because it feels more well thought out and less every feature except the kitchen sink, like Scala. They're both great languages though. Scala >> Java, and F# > C# (more due to C# already being better than Java).

F# is a remarkably less powerful language than scala. Along with the cost of Visual Studio + windows licenses, the Scala/open source ecosystem is just a better choice.
next

Legal | privacy