The Artima Developer Community
Sponsored Link

Artima Developer Spotlight Forum
Brian Frank on Fan versus Scala

5 replies on 1 page. Most recent reply: Jul 28, 2009 12:11 PM by Carson Gross

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 5 replies on 1 page
Frank Sommers

Posts: 2642
Nickname: fsommers
Registered: Jan, 2002

Brian Frank on Fan versus Scala Posted: Jul 23, 2009 7:39 PM
Reply to this message Reply
Advertisement

While most alternative languages on the JVM sport dynamic type systems, Fan and Scala both provide static typing. The two languages share other similarities, too, although their design centers are quite far apart, writes Fan language creator Brian Frank in Fan vs Scala: Different Trade-offs:

I think Scala is a really great language and I'm always on the lookout of good stuff to steal from it. But I do believe there are some key philosophical differences which I haven't really seen talked about...

A lot of it boils down to Scala's focus on its static type system versus Fan's focus on modularity and meta-programming. There is no right or wrong, just different trade-offs that will suit different tastes. There is also definitely an element of cathedral versus bazaar - Fan is trying to bake more into a unified whole (which is something I can understand might not appeal to those who favor the bazaar model of gluing lots of pieces together)...

Both Fan and Scala are trying to take software scalability to the next level, but I think we are taking different paths to get there. Scala's focus is clearly on a sophisticated type system which can catch as many errors as possible at compile time. It is also focused on mixing functional style with OO style (more so than Fan which only uses functional programming primarily as an enabler of better APIs).

Frank notes that the two languages differ in how they approach "scalable" software:

If I were to pick the absolute most important feature required for scalable software, I personally would pick a first class module system. I think this is a key difference between Fan and Scala. Scala follows more of the Java model of packages, with an unspecified module system. From what I can tell, OSGi seems to be the preferred Scala solution for modularity, but it isn't integrated tightly into the language like Fan...

Fan has a built-in module system called "pods" that is seriously baked into the core... Pods are intertwined into Fan's reflection APIs to enable all sorts of things that are impossible to do in Java (and I assume Scala) such iterate all the installed types... Because Fan knows about all the installed modules and each module's types, we can index the installed types to provide a unified solution for reflecting things like plugins...

Fan's strong focus on metaprogramming is also a difference from Scala, according to Frank:

Fan's type system makes a trade-off towards a weaker static type system, but easier for meta-programming and reflection... This sort of meta-programming style does not lend itself to static type checking. This is why Fan will let you use Obj as a wildcard whenever a more explicit type is expected. Note the wildcard feature does not really weaken the static type system much, because it typically only kicks in with reflection APIs (which would have have required an explicit cast anyways)...

Fan uses a static type system also - but as just one tool in the toolbox. Rather much of Fan's effort has been focused on overall architecture - more of a "cathedral" approach to providing a unified solution for all the different pieces required to build, test, and deploy software (yes I know IDE solutions are lacking, but I think this will take care of itself with time). This philosophy on the entire platform and the end-to-end programming experience versus just the language is reflected in Fan's features and even this site itself...

Fan's type system is by no means as flexible as Scala's. But I do think the notion of immutability is more hardwired into Fan via the notion of const types and const fields. The notion of immutability is also baked into all the reflection and concurrency code. This makes it almost impossible to share mutable state between actors (threads). The only way to share mutable state is via the Unsafe class which exists only as an escape hatch.

Other points of comparison included in the article are serialization, Fan's built-in build engine, as well as differences in how the two languages interoperate with existing Java and .NET libraries.

What do you think of Frank's comparison of Fan and Scala?


Otengi Miloskov

Posts: 2
Nickname: otengim
Registered: Jul, 2009

Re: Brian Frank on Fan versus Scala Posted: Jul 23, 2009 11:16 PM
Reply to this message Reply
What Im so sure is also that Fan is an easy language to learn compared to the complexity of Scala.

There is a lot of talking about the interoperability between Scala and Java or Fan and Java and Scala wins in that case but Fan Java FFI is not so bad. If you just need to reuse Java API libraries with Fan is enough but if is to integrate to a existing Java system maybe Scala is better match.

Me I liked Fan because is simple and easy language as a dynamic language but statically typed and keeps Java syntax and have the features that the modern Java is missing as closures, type inference, actors, etc.

Carson Gross

Posts: 153
Nickname: cgross
Registered: Oct, 2006

Re: Brian Frank on Fan versus Scala Posted: Jul 24, 2009 12:41 PM
Reply to this message Reply
Any language sensible enough to kick method overloading to the curb and then head stomp it repeatedly can't be all bad.

http://guidewiredevelopment.wordpress.com/2009/05/22/i-am-hate-method-overloading-and-so-can-you/

Cheers,
Carson

Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: Brian Frank on Fan versus Scala Posted: Jul 28, 2009 6:31 AM
Reply to this message Reply
> Any language sensible enough to kick method overloading to
> the curb and then head stomp it repeatedly can't be all
> bad.
>
> http://guidewiredevelopment.wordpress.com/2009/05/22/i-am-h
> ate-method-overloading-and-so-can-you/
>
> Cheers,
> Carson

Sorry man, don't quite share your enthusiastic hatred of overloading - in fact I agree with x in your post. I think it makes code more readable. Even from a problem solving scenario (language aside) it makes absolute sense - E.g. Ape being Abstract, Man and Gorilla being extended classes, method slap passing in parameter hand have different effects coz Gorilla is supposedly stronger - that's plain common sense. Probably a poor example but it's getting the point across - clarifies things from a problem solving angle (well at least to me). I also disagree that it is used infrequently - in fact if you're a framework writer as well as application developer, if your code is actually "clean" you use it very often.

James Watson

Posts: 2024
Nickname: watson
Registered: Sep, 2005

Re: Brian Frank on Fan versus Scala Posted: Jul 28, 2009 10:05 AM
Reply to this message Reply
> Sorry man, don't quite share your enthusiastic hatred of
> overloading - in fact I agree with x in your post. I
> think it makes code more readable. Even from a problem
> solving scenario (language aside) it makes absolute sense
> - E.g. Ape being Abstract, Man and Gorilla being extended
> classes, method slap passing in parameter hand have
> different effects coz Gorilla is supposedly stronger -
> that's plain common sense.

That sounds like polymorphism to me, not method overloading. In any case, in a single-dispatch language like Java, method overloading is a poor to unworkable solution for this kind of problem.

> Probably a poor example but
> it's getting the point across - clarifies things from a
> problem solving angle (well at least to me). I also
> disagree that it is used infrequently - in fact if you're
> a framework writer as well as application developer, if
> your code is actually "clean" you use it very often.

In Java, method overloading acts (mostly) just like having two different methods with no relationship. The only times this isn't the case is in the JVM and the rules are complex and unintuitive. There is no real value in method overloading with single dispatch language. It's a best aesthetic and at worst the cause of many hours of debugging.

Carson Gross

Posts: 153
Nickname: cgross
Registered: Oct, 2006

Re: Brian Frank on Fan versus Scala Posted: Jul 28, 2009 12:11 PM
Reply to this message Reply
Would it really kill you to write slapMan() and slapGorilla()?

One of the insidious features of static method overloading is that it reminds people of polymorphism, which is very useful, even though it behaves totally differently.

Things should have decent, unique, human understandable names. I assert that the fully qualified types of all the parameters of a function should not figure in the name of that function. From first principals I think most people would come to a similar conclusion, but we've been poisoned by decades of exposure the feature.

If it makes you feel better, any language that wants to transparently integrate with java has to implement overloading, so Gosu nee GScript has it. Ugh.

Cheers,
Carson

Flat View: This topic has 5 replies on 1 page
Topic: The Removal of Concepts From C++0x Previous Topic   Next Topic Topic: Ed Ort Explains invokedynamic


Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2014 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us