Tuesday, November 30, 2010

Scala Pros & Cons

Here's a quick list of things that Scala does right and wrong.

And I'm just making this list for myself.

Pros
1. Brings together the OO and Functional realms.  Sure other languages have done it before.  But probably not as well and seamlessly as Scala.
2. Actors.  Great concept.  Also, not original.  But it works and is easy to implement.
3. Operator overloading.  This is definitely one this that makes code read easier to read.
var thirdList = firstList + secondList ;
How hard is that Java guys?
List thirdList = new List( firstList );
thirdList.addAll( secondList );

4. Traits.  Seems pretty simple after you use it once or twice.  Makes you wonder what all the fuss was about in Java banning multiple inheritance.

5. The type system.  In some cases it makes life a lot easier.
I can pass in a List of Dogs into a function that takes a List of Mammals.  Just seems natural.
More on the type system below.

6. Runs on the JVM.  I almost didn't mention it.  I don't think its really that big of a deal.  People have been able to solve all kinds of problems with plain old java.  Scala needs to give the world a compelling reason to not use java.

I'm almost reminded here of the days when o/s 2 ran windows apps.  Super, if I can develop apps that run on windows, why should I bother writing apps specifically for o/s 2?  And hence everyone sticks with windows.  Its not quite an analogy, just a similarity.

Cons
1. Irregular syntax.  And this is a biggie.  A regular syntax makes code easy to read and pick up from project to project.  The philosophy of flexible syntax is nice, but in practice its a bad idea.  In general, I'm not a fan of lisp.  However, the simplicity and regularity of lisp syntax is one of the major reasons its hung around for so long.

If I pick up a new piece of code that I am supposed to maintain or debug, I don't want to follow the guy who thought
x | y -> z -> a
is easy to understand.  Was this guy a Haskell coder?  Which one is the object? which one is the function?  What does | do again?  And why the heck is anyone in this day and age using one character variable names?  Unless this is 3d geometry.

2. The type system.  Sure its powerful.  But I cant really think of too many times in the last twenty years where I needed a full blown type calculus system to solve a problem.  And this seems to be one area where people like to gravitate towards when they take a shot as Scala.

Thats it for now.  More to come.  Notice there are only two Cons.  Yes, I'm a fan of the language.