Update - One year and a half later : I love Scala, therefore I declare this blog post deprecated. I just gave it a week more and I totally fell in love with it. And no, java 8 cannot weaken scala :-)
I spent an entire weekend trying to break through Scala. The amplitude of interest was increasing at first but suddenly rapidly decreased until I lost patience for good. I barely finished 10 projectEuler's problems except for reading up documentation. The more experience I had the more unhappy I was about the complexity of the language and mainly the abstraction layer. Considering the fact that Java 8 is "almost" here and it comes with closures, I said to myself that it was going to make Scala's existence and popularity much weaker. And this reason was strong enough for me to give up on Scala. It was like redemption for me. Scala is so different from imperative languages like Java that for a Java developer it is more effort to learn it on the production level than there is to gain and a non-Java developer would have to learn Java no matter what if he is going to become a professional Scala programmer. At least I think he would probably have to because of the nature of the environment.
Now, I'm aware of the fact that learning a new language (at least to be able of doing the basic things and truly understand its paradigms) is huge benefit for improving logic and getting oneself out of the box a little, but learning Scala to become proficient would make such a madness in my head and it would take so long to get used to it, that I find my life too short for that. It seems to me that Java and imperative algorithms consequently are readable and edible by other language programmers, but Scala algorithms give everybody feeling that they might know what it is about, but only Scala developer knows what it is doing (because he knows the abstraction layer underneath).
Sometimes I was under the impression that Scala is so popular because programmers needed to prove themselves as smart asses. Except for those that were really learning Scala for some heavy multi concurrency data or message processing. Things like : weird compiler and classloading quirks (that some Scala *.class is broken for instance), still quite inadequate eclipse ide to the language and constant impression that Scala is not an improvement on complexity would discourage me sooner or later anyway. So far I think of Scala that it is improvement on scalability only. After all it is Scalable language, huh ?
Java developers tend to have problems to master even all types of java.util data structures and java.lang primitive wrappers properly and Scala puts heavy abstraction on top of it. Cool, why not ?
To make it easier, right? To get rid of primitives in fully OO style, also autoboxing disappears from your sight, no BigInteger.ZERO anymore. To accommodate the functional style, because it kinda implicitly requires a lot of methods and overloaded operators.
Consider Stream interface for instance. Stream helps to realize laziness, one of the fundamental concepts of Functional Programming. Stream is "infinite", it's like a collection that goes on and on and it is evaluated on an as-needed basis and only up to the point that you need it. There are more than 200 methods together and you often cannot even find a method because it actually sits somewhere in a companion object ( compiler resolves the lack of method by implicit conversion to that companion object because it actually has it) and after you find it you realize that it returns something you wouldn't expect. Which is correct at the end, because it is passed the "by-name" parameter that is actually not invoked until it is used and it doesn't directly return that type.
For every Object declaration in the code an anonymous class is created which inherits from whatever classes it extends. If a class shares the same name with the Object, the Object become a companion object of that class. The object cannot have more than one instance ( which is what Classes are for ), in fact it is practically a substitution for static fields and methods in Java. That is to say, if you define an Object in Scala, it would be like defining a Java Class with static methods and fields only. However Object can extend another Class, implement interfaces, and be passed around as an instance of a class. If you gave this to Macgyver he would end up dead, reading up on inverse associative order :-)
I don't want to discourage anybody from giving it a shot. I gave it just 2 days and I'm sure now that this is not my cup of coffee. Not the functional style, I like that one in Scala and I also like closures in Groovy and ease of Javascript callbacks in NodeJS. Of course in Scala it is much more fancy, that one cannot even compare that to closures in Groovy.
In fact, there are many sweet things, who wouldn't like Scala's comprehensions, Generators, Guards, all those filters, placeholder syntax or a little controversial inverse associative order (if you type '1 :: 2 :: 3', you get a List(1, 2, 3) back - if the method name ends with colon, the method is invoked on the right operand.
But for what price? I rather won't be able to use it than getting familiarized with what I wrote in the previous paragraph. And I certainly won't learn Scala because of it's Actor concurrency framework which others sometimes do.
Maybe I gave up too early, maybe I didn't have the correct motivation for learning Scala. I might not be smart enough. Who knows, I will stick with Java only. I started to have doubts, but now I'm sure of that.
No comments:
Post a Comment