#285 Scala vs Fan, which is better?

philip142au Sun 13 Jul 2008

Hi,

So I've been reading about Scala and about Fan. Which is better and why?

I need to make a decision on which one to use for upcoming project.

Philip

brian Sun 13 Jul 2008

Philip,

I don't think one is "better", but rather I think each has different design goals. So it depends on what you want from a language. Couple differences to consider:

At the core Scala has a very strong and powerful type system. Fan has a very simple type system, but allows you to drop into dynamic mode using the "->" operator. I would say Scala starts at Java and moves towards Haskell. Fan starts at Java also, but moves towards Ruby/Groovy/Python. If you really like strong typing, Scala is probably better. If you mostly want a statically typed language, but you also dig dynamic languages you'll probably like Fan.

Fan is designed from the ground up to run on both the JVM and .NET CLR. We've spent a great deal of time on a portable library. For example we wrote our own timezone support (since .NET lacks that library). I think Scala will run on .NET, but they haven't really solved the library problem (yet at least).

Scala will work with existing Java libraries better than Fan does today. Since our focus is on portability we've focused on writing new libraries, not letting you call down to Java or .NET libraries. Something we'll solve sooner or later, but not a priority now (edit: Fan now works easily with Java librarys via Java FFI)

Both Fan and Scala provide an actor model for message passing between threads. But Fan enforces no shared state at the language level, where Scala makes it a convention.

I would say Scala has more power to build DSLs. But Fan has put a huge emphasis on serialization and declarative programming. Just about everything is easily serialized in a human friendly JSON like format. You can use serialized objects as expressions within the language itself.

We've also built a lot of things into Fan which I don't think are built into Scala:

  • module management via pods
  • type database for auto-indexing all your installed types and meta-data
  • build system
  • unit testing
  • widget toolkit (wraps SWT)

And of course one huge difference is that Scala is released. Fan is still in development. Fan will likely be making some breaking changes over the next few months. I hope to gets things stable and fairly locked down by the end of the year (since I'll be using it in production code myself).

Since I haven't used Scala, I'm not the best person to compare. There are several people on this forum who can probably compare the two much better than I.

Brian

cbeust Sun 13 Jul 2008

Brian, I have to say that for someone who has a clear stake in the debate, your summary is remarkably fair and objective. Hat's off to you.

I have used (admittedly not much) and studied extensively both languages (including, reading the great "Programming in Scala" book, which I recommend), and my personal opinion is that while Scala is more mature and has more tool support than Fan as of today, it's also passed Java in complexity, both syntactically and semantically.

I also find some of the features added in Scala questionable, especially case classes (see links at the bottom). While Scala is solid overall, I think it has a slight academic slant that makes me think that it will not become mainstream because some of the implemented concepts will be hard to understand for typical teams.

I am excited about Fan because it hits the 80%/20% mark: it's still fairly young and thanks to its benevolent leadership, it's not overreaching. I don't agree with all the decisions that Brian and Andy make, but I totally respect their attempts at keeping the language simple.

Having said that, Fan's youth would probably be a concern to me to pick it as a "real" project. I enjoy dabbling in it, but choosing it for a real project would probably depend a lot on the team. I would certainly make sure I get buy-in for all team members before making such a risky choice (Scala is a similarly risky choice, because both languages are not mainstream).

Here are a few links about an article I wrote questioning the purpose of "case classes" in Scala. I have similar doubts about a few other features:

tompalmer Mon 14 Jul 2008

In Ruby land, Matz likes to make releases as Christmas presents. Whether or not the same style will work here, I think a "1.0" release by the end of the year would be great. (And I know I've been among the destabilizing influences.) Something guaranteed backwards compatible and stable is needed within this time frame, I think. So thanks for having that general goal.

Maybe some of us who hover the forums need to try out using Fan where possible to see how it works out in practice a bit more. I did write one script in it at work recently, but I haven't done anything big yet (at work or at home). And at work, most of us obviously have constraints, but there might be occasional possibilities.

Login or Signup to reply.