This week I visited the stronghold of Scala, EPFL, in order to certify as 'official' Scala Trainer. It was an impressive visit, whose highlights I have transformed into this blog.
This week I spent two days at EPF in Lausanne (EPFL), where I taught a module of Martin Odersky’s Scala course in order to certify for ‘official’ Scala trainer. My teaching was followed and evaluated by the master himself, which was a unique experience. It definitely sounds more scary than it actually was. Nevertheless, it certainly was a once in a lifetime opportunity, great fun to do and fortunately with a positive outcome.
Being within the walls where Scala first has seen the light had more impact on me than I initially imagined. Realizing that all the highly modular and extendable building blocks of Scala were invented within these walls I started to grasp that this was just the beginning. Martin directs a great deal of research on new features for Scala, where he has the powerful position to cherry-pick the best of breed and integrate it into new versions of Scala.
While talking I learned that just some blocks away there was the research group who was porting Scala to the .Net platform. Martin’s assistant, Iulian Dragos, who taught another module of the Scala course wrote his thesis a.o. about the @specialized annotation, which is now part of Scala 2.8. Whereas parallel collections planned for 2.9 reached already an advanced stage I heard him talking about language virtualization (using the Scala compiler to compile to other languages), a ‘certified’ enterprise Scala stack, comparable to what RedHat does with JBoss, to ease the adoption for the enterprise, the beta eclipse Scala IDE, which is about to be released and so on, and so on.
However, what I found most interesting to hear - being a consultant – is that many major Banks mostly in the States and Europe have started to embrace Scala, so far mostly for their business critical trading platforms. When besides innovative startups like Twitter and LinkedIn rather conservative enterprises dare to make such a move, I can hear a bell ring.
During the course it also became evident, that really a lot is going on. Martin had to delegate parts of the course to his assistant Iulian because of his myriads of current activities. Most of his free time during the course he spent mailing, reviewing papers etc. to manage the increasingly demanding Scala empire. He told me that because of lack of time he will delegate the Scala trainings to an associate, so that he can focus on the direction Scala is heading to. It became evident to me that Scala has grown far beyond the academic walls and is gaining serious ground in the industry. So all in all that is REALLY good news.
At the end of the first day there was another pleasing surprise waiting for me. Two local participants of the Scala course told me that at this very evening there is a meeting of the Scala user group of Lausanne and they asked me to join. Half an hour later I stood face to face with Ceki Gülcü, the inventor of log4j and other logging frameworks who is leading the Scala user group in Lausanne. Needless to say that it was a great evening, with lots of Scala live coding and geeky discussions. The next day we told Martin Odersky about our whereabouts, and because I mentioned that the amount of people joining the user group meeting wasn’t that impressive he answered: “Right, I think I should send them some Scala people from EPFL, to help them start up”. I wish our Scala user group in the Netherlands had such a highly elaborate Scala resource pool within reach…
There is another noteworthy anecdote. After lunch at the canteen of the EPFL Iulian pointed me to the other end of the aula, asking me whether I recognize ‘it’. What I saw was a fancy designed stairway, which triggered me at second glance. Have a look by yourself:
So far this blog has revealed everything else than fancy nuts and bolts of Scala. So to round up lets look at a neat little expression, which might find its way to Scala 2.9:
def ??? = throw new IllegalArgumentException(“Not implemented yet”)
What we’ve defined is a method with the name ??? which throws an IllegalArgumentException. What’s so special about it? The interesting thing is that you can use the ??? method for all methods you have not implemented yet, no matter what type they return (a value type, Unit, a Function, Nothing etc.). Handy for prototyping:
def myMethod(i:Int):String = ??? def myMethod(s:String, i:Int):Unit = ??? def myMethod:Int => Int= ???
So why does that compile? Because of Scala’s fundamental OO nature every method returns something. In case of void the returntype is Unit, in case a method only throws an exception the returntype is Nothing. Therefore, the returntype of the ??? method is of type Nothing. Without making use of Scala’s type inference I would have to write:
def ???():Nothing = throw new IllegalArgumentException(“not implemented yet”)
When you look at the class hierarchy of Scala you see that Nothing is the sub type of every type. Since you always can return a sub type of the actually defined type you return in a method, the Nothing type is a valid return type for anything. As you probably assumed, the Nothing type is added by the compiler. There is no way and need to deal with the Nothing type explicitly. Personally, I find this a smart and powerful construct, stressing once more Scala’s flawless class hierarchy setup.
All in all, it was a great and special experience to visit the breeding grounds of Scala, whose gifted creator is leading this impressive language to new heights, for years of fun and productivity to come for all daring to step over the threshold.