views:

4205

answers:

5

Could someone describe what are the differences between those two languages? Other that they target different VM of course ;)

+8  A: 

Here's a decent blog article on the subject

JaredPar
@Downvoter, really? Care to add a reason?
JaredPar
+12  A: 

F# is a variant of ML -- as such it's very close to OCaml or SML. Scala is intended to be a new interface to java VM that has some features of ML, but has more of a concentration on supporting traditional OO in a way that F# doesn't.

Denis Bueno
What exactly does Scala support that F# does not?
Jon Harrop
I don't think it's a matter of support, Jon (obviously you can model pretty much anything pretty much anywhere), but F# focusses more on the functional aspect than Scala, and Scala focusses more on the OO aspect than F#. It's just a different approach.
Calum
@Calum: I agree with you but Denis wrote "has more of a concentration on supporting traditional OO in a way that F# doesn't" so I'm asking him to elaborate on what traditional OO Scala supports that F# does not.
Jon Harrop
Fair enough point, Jon, although I still think that "supporting" doesn't necessarily just refer to making the features available; reducing the difficulties in using a paradigm is a form of support too.
Calum
+9  A: 

I've haven't used Scala, but from what I've seen, one major difference is that it has limited support for type inference and will not automatically add generic parameters. Instead, you're forced to calculate and annotate this explicitly, similarly to C# and other languages.

Compare:

F#: 
  let id x = x
Sc: 
  def id[A](x: A) = x
C#: 
  T id<T>(T x) { return x; }
MichaelGG
Actually, ``def id[a] (x : a) = x`` works too, but your sample is basically correct. F# has much more powerful type inference than Scala can ever hope to achieve due to Scala's OO underpinnings.
Daniel Spiewak
Indeed. Scala also has weaker pattern match checking, (almost) no tail calls, poor documentation, no published books and a buggy compiler.
Jon Harrop
I can confirm that. I wrote one program in Scala and ran into 5-6 compiler bugs.
mdm
@mdm: Can you please share that program with us?
missingfaktor
@Rahul G: I have to dig it up in my backups. I will push it to http://github.com/mdm/icfp2006. I don't remember the errors from the top of my hat, but I will look at the source code again. If you want to discuss further, leave me a message on github.
mdm
@mdm: Yeah sure, because I find it quite unusual that someone finds 5-6 compiler bugs with just one program.
missingfaktor
@Rahuλ G: I have also done relatively little Scala programming and ran into compiler bugs almost immediately. That was back in 2007 though...
Jon Harrop
+2  A: 

According to a colleague who's spent some time looking into Scala (with a somewhat jaundiced eye), the first thing that leaps out at you is that you have to read about fifty pages of the reference manual before you are equipped to understand its syntax, let alone its semantics!

Rafe
+6  A: 

One major difference between Scala and F# is in the expressiveness of their respective type systems. Whereas F#'s parametric polymorphism can only abstract over simple types, Scala's type system is able to express higher-kinded types, which is to say that it can abstract over both simple types and type constructors.

Of course this is not to say that Scala's type system is strictly better in all ways; F# has superior type inference.

pelotom