The other side of the coin:
I don't have an extensive experience with Scala; I have written approximately 10,000 lines of Scala code. However, consider that Scala code is often much shorter than its rough equivalent of 40,000 lines of Java.
On short I don't like Scala at all. I love it's goals, it's ideas but for production use I consider the implementation of those ideas too bold and sometimes even foolish. My belief is that Scala code is hard to write in a robust and crystal clear fashion. There are too many concepts which often overlaps by their side effects which can make your life really hard if you are not an expert. There is an opinion that one can avoid those problems by simply not using those constructs. I reject this opinion since if you want to avoid problematic things you would have to know that you do not understand completely those features, which would require an expert knowledge. My belief is that Scala language implementation is proper for an university where new concepts should be tested, which is exactly what happens with Scala.
There are many examples, I will give some reasons which can sustain what I say:
- Java generics are incomplete mostly because of type erasure, everybody agrees on that. Scala "solved" that problems using a public API in at least three ways: Manifest, TypeTag, ClassTag. In my opinion this means that the problem is simply not solved or if it's solved some of the solutions are wrong enough.
- converters are an example of a feature which I consider problematic: one simply removes the strong connection between types with something soft, very easy to be missed. After I started to use a third party library where some courageous guy used plenty of them and my code started to behave weird. I typed something wrong which happened to be covered by a converter and spent hours debugging.
- parameters with default values: one can define methods with parameters with default values; this is useful mostly because using named parameters you avoid writing many methods... until the moment when you discover that you cannot have two methods both with a default valued parameter with the same name.
Now I don't want to flame a war, far from it. Scala has many wonderful ideas, Java is old and lacks many things. But for production I would always chose Java.
Later edit:
For more details on Scala type erasure there is a short review here.
In order to clarify what I stated about parameter with values I just give an hypothetical example (so objections like Array and List implements some traversable interface does not count):
class Plot {
def histogram(x: Array[Double], bins: Int = 30): String = "test1"
def histogram(x: List[Double], bins: Int = 30): String = "test2"
}
The above code does not compile: error: in class Plot, multiple overloaded alternatives of method f define default arguments.
type-erasure-manifest-and-typetag/
Another later edit
I received an edit proposal and since I do not know how to message the contributor I will answer here. His idea is that the code is not right and it should look like the following.
def histogram(x: Array[Double], bins: Int = 30): String = {
var r = "test1"
return r;
}
As far as I know this is the same as above, since my version is a shortcut. The point is that the code does not compile because you have a parameter with default values with the same name in two methods, not because methods are not declared correctly. Obviously, like in many other languages, one can find other ways to overpass this problem.
The whole idea is that to me Scala looks like a too generous language, with many ways of doing many things, which as a side effect creates a complexity burden. In the context, having features like the one I mentioned, it makes things even harder. Obviously I do not own the truth, so I take the liberty to avoid the language complexity and concentrate my effort on solving real problems, and anybody else can have the liberty to solve its problems with this language. With all due respect.