Monday, June 4, 2012

First thoughts on Scala

Well, the initial "warmup" period of GSoC 2012 ended two weeks ago, but unfortuntely I didn't have any time to summarize my first impressions.

I like to think myself as an experienced and enthusiastic Java programmer. I kept hearing from Scala quite a time, so I wanted to take a look on it - for which the GSoC project was an exceptional opportunity.

As a first step, I subscribed several mailing lists that I think might be useful for the project (scala-lang, specs2, scala-ide, scala-ide-dev and scala-ide-user). Before I forgot to mention, I have to state that the Scala community is great! You can learn quite a lot of simply by joining the conversations at the different mailing lists. Everybody is so motivated and trying to push forward the language in several ways. It is great to be the part of it, I was missing such a enthusiasm for a long time.

I read a few books on Scala for a start, I chose Scala for the Impatient and Programming Scala, both because they were free and accessible online. The language basics are easy to understand, but I think several features that was dropped from Java (compared to for instance C++) because of simplicity is re-introduced into the language (like multiple inheritance), so I believe it is going to take ages to master it. To be honest I'm not a big fan of multiple inharitance, because I believe features that require a pen, a paper and about 15 minutes to prove how they work and in which order are the members initialized (i.e., the linearization algorithm) shouldn't be enforced to programmers. But it seems I'll have to get used to it :-)

I have also took a look on the ScalaDays2012 videos, Bill Venners's and Dick Wall's presentation was extremely useful for me since there was a minor twist in my project. The ScalaTest team created a quite extensive and generic testing framework that allows the interaction of different testing tools (even within one project). They also integrate it into various IDEs, and actually, the integration with the Scala IDE is almost done and scheduled to July. So I can utilize all of these features by simply using the ScalaTest API.

Building is somewhat complicated, requires using several different build tools simultaneously (Maven/Tychoo, Sbt, Ivy). Also, I find Scala's binary compatibility a bit fragile.

On one hand, it is causing me quite a headache (the libraries depending on the version of Scala compiler and sometimes even the version of the build tool you are using!), and it wasn't trivial to put all the things together (even if there were quite an extensive documentation for a start). But now its working and all is fine. It was just strange for me at first for the Java developer in me, because literally speaking you can still run a Java bytecode that was compiled on Java 1.0 about ten years ago without any problems.

On the other hand, programmers always argue of the replacement or removal of bad design decisions that was made for a programming language (do you recall SwingUtilities2 and the SwingUtilities3 classes?). Now, here's a language that takes the initiative and isn't afraid of dropping out things that simply wasn't working. Kinda cool.

Another issue I found a bit disturbing is that there's always something new showing up on the road, but that's simply because I shifted into a direction of another language. I had to read a lot about common tools (scalaz, sbt, different language constructs that wasn't trivial for the first sight, IDEs, ScalaTest, etc.), but I believe now I know enough to start producing real code.

I also have to tell that one of the most valuable features of Scala at the moment for me is that I can use any code I wrote before, any Java-based library, which is great. One of my greatest arguments against functional languages was that there was practically no available 3rd party libraries before. But hey, here's a language that can run on any machine and you can use any Java or .Net library out there - and I'm sold! As an example, here's the GSoC project: I'm writing Eclipse plugins for the Scala IDE in pure Scala, doesn't it sound mature enough?

Btw I was able to create a first implementation for Specs2 support in the Scala IDE, you can find it in the specs2-runner project at Github. Eric helped me a lot and reviewed the code, so now I'm completely rewriting it :-) Anyway, here's a screenshot of the application at the current state:


Feel free to have any comments, suggestions or recommenadtions.

No comments:

Post a Comment