Lunatech

Reflections on Scala Days 2012

By Erik Bakker on 20 April 2012  Scala  playframework

This week was the week of Scala Days 2012. Rainy London was the stage for almost two full days of Scala talks, discussions, meets and greets with the people you know mostly by their Twitter name and chats with other Scala developers.

Or daytime Java developers doing Scala for personal projects, because it turns out that a fair chunk of the attendees can’t use Scala (yet) in their daily work. Especially consultants that join teams on existing projects often can’t use Scala there. Luckily, coders thrive at night so all is not lost, although people seem eager to apply more Scala during the job.

My flight was a bit delayed and combined with needing a few minutes to grasp and fully appreciate the London tube network which caused me to walk in near the end of the first talk. Guy Steele was comparing Scala and Fortress. I knew Fortress only from it’s connections to Fortran, which I came into contact with at University - I don’t want to talk about it. Next stop was Jonas Bonér with a short talk about Akka 2.0. It’s really nice to see how the Akka team built upon the concepts of Akka 1 but generalized and simplified things. Global state exchanged for an explicit Actor System of which multiple can co-exist, no more distinction between local and remote actors, scaling up and out through configuration only, ActorPaths to lookup actors in the hierarchy and many more cool things.

Marius Eriksen from Twitter held an inspirational talk about their use of Futures, Offers and Brokers. Futures are probably known, and Offers and Brokers are part of a Twitter standard library named Offer/Broker and can be used as a synchronization mechanism and communications composition.

Typesafe’s Viktor Klang told us about the upcoming Futures and Promises API in Scala, as outlined in SIP-14, and determined it awesome that what he was saying made sense to the audience. And make sense it did, because Klang is an enthusiastic and organized speaker. He was also neatly done in the short amount of time he had.

You may start to see two patterns emerge here: Concurrency and short talks. The first one is explained by the ‘Concurrency’ track that I was following, the second one a complaint often heard in the Barbican’s corridors. The consensus seemed to be that the 30 minutes that speakers had was a bit short. I guess it is a necessary tradeoff with so many good speakers and only two Scala Days.

The former black art of testing Akka actors and FSM’s was made into an understandable regular practice by Roland Kuhn. With the Akka TestKit, you can do various ways of testing your actors and complete actor systems. Intercepting and inspecting messages between actors, running the actor system on a single thread to make the behavior deterministic and even - if you really must - inspecting the internal state of an actor using a TestActorRef. Maybe not as inspiring as other subjects, but certainly assuring that testing is not an afterthought for the Akka team.

The Barbican provided a fine lunch of mini-sandwiches, fruit and crisps - as the locals would call them - during the one-and-a-half hour lunch break. This gave plenty of time to exchange ideas with people, arguably the most important aspect of such a conference.

After Lunch, Haskell-hero Simon Peyton Jones from Microsoft Research provided a keynote about Haskell in the Cloud, where serializing and transfering program code plays a big role. Brendan McAdams - maintainer of the Java driver for MongoDB and the Casbah Scala toolkit on top of it - did a broad talk about asynchronous IO and some usable patterns and concepts for dealing with it.

After an extended coffee break - where the attacks on the cookies may have been an indication of the nutritional value of the sandwiches from the lunch - the last session started for me with the second talk in the session, about the developments on the Eclipse Scala IDE. Iulian Dragos concurrently adjusted his microphone for 30 minutes, and demonstrated the new features of the upcoming 2.1 version of the Scala IDE. This release is marking the shift from building towards a stable but not very feature rich Scala IDE in the 2.0 release, and really powerful Scala features in 2.1 onwards. A really nice job from Dragos and the rest of the ScalaIDE team. Mirco Dotta distributed some Scala IDE t-shirts, of which I (as single ScalaIDE user) will be wearing one purely as a provocation in the IntelliJ stronghold that is called Lunatech.

After absorbing all these facts, opinions and ideas about Scala and Scala tech, it was time for a London site-seeing tour with a typical red double-decker bus and dinner at Lincoln’s Inn.

The next day was supposed to start with a fifteen minute welcome talk, but since no-one seemed to know who was supposed to give that, Martin Odersky started and finished the formalities with a “So, welcome!” and added the remainder of time to his presentation about the current status and future of Scala. Cakes are no longer served by the Bakery of Doom, instead unification of the compiler and the new reflections API give rise to supercakes: cakes on top of cakes, and this unification paves the path for Macros, which is a great new experimental feature in 2.10. Macros can do some of the things only compiler plugins could do until now, but this time we get a stable API for it and no longer have to expect breakage with new compiler as is the case with compiler plugins. The new reflections API is based on mirrors.

Immediately after Odersky, scalac wizard Paul Phillips’ talk “inside the sausage factory” about the internals of the Scala compiler made us realize that if Paul gets hit by a bus, we are screwed. In this light, these have been two risky days, given the much higher likelihood of such an event happening in London compared to anywhere else. The Scala compiler turns out to be a piece of software where many best-practices had to be disregarded in favor of performance. When a member of the audience noted that all could not be that bad - with 27-ish compilation phases, each phase probably does something that is fairly small and hopefully isolated, right? - Paul’s reaction “Muhahaha” removed all doubt of those thinking some exaggeration was going on.

After the coffee break, I went to the “Scala-bility on the Web and Elsewhere” to see Lift committer Indrajit Raychaudhuri tell us about the new things in Lift 2.4. He assured us that while Lift has a steep learning curve, there is a point where you get to the plateau and “it’s cruising from there”. They have a nice templating system based on CSS selectors: "#name *" #> userName replaces the content of the element with id “name” with the contents of the userName value.

Peter Hausel presented Play 2.0 with a focus on streamlining developer experience, and the efforts that the Play team is making on error reporting for front-end technologies like LESS, CSS, CoffeeScript and JavaScript. Afterwards, I bugged him with what I think are some of the issues with Play 2.0, of which composability of Forms is probably the biggest one.

Finally, Nathan Hamblen from Meetup made us realize that if you value the cost of a simple while loop with a counter variable that loops Int.MaxValue times at 5 pence, you’ll be paying 1200 pounds for the same result if you use a for-comprehension. And that is with compiler optimizations enabled, without, it’s even worse. He then continued with an impressive overview of the building of a very high performance service by avoiding the abstractions made by the Servlet API and using non abstracted, highly tuned Netty handlers instead, that was feasible to this specific situation since the backend didn’t use any IO.

After lunch, Zeebox co-founder Anthony Rose gave an inspiring talk that had not much to do with Scala - although they have a technically interesting problem and they do use Scala extensively - about the future of television and the media industry.

In the afternoon, Nada Amin presented her academic work on a DSL for Javascript in Scala. Code written in this DSL can either be executed directly on the server, or compiled to Javascript. While at the early stages, this seems very promising. This work was done in collaboration with Gzregorz Kossakowski, who did the next interpretation, about his work on compiling Scala to Javascript using GWT. It was a truly inspirational talk in which Greg - easier to pronounce - explained how he introduced an intermediate format jribble, adapted the Scala compiler to output this format and adapted the GWT compiler to accept this format and to compile it into Javascript. He then only needed about 300 patches to the Scala standard library and the job was done! Succesful compilation of Scala code to Javascript, with only the exception of inherently impossible stuff in Javascript like threads. However, when presented with the question whether he actually preferred this approach or the approach of writing a DSL for Javascript, after some hesitation he admitted that he preferred the DSL for most tasks. Then Odersky got hold of a microphone, and asked the audience whether it would prefer Scala to stay away from Javascript, or to do full compilation of Scala code to Javascript or to introduce a DSL for writing Javascript. The results were roughly 50/50 for the latter two options.

This was the last talk of the day. Martin spoke a few kinds words about the organization and assured us that there is going to be a new edition of the Scala Days next year. This closed the official part of the program. Some of us moved to the Slaughtered Lamb pub for some fish & chips, and a few pints afterwards. There, Martin Zachrison convinced me to try to use proportional fonts for coding for a while, which - at least at that time - seems reasonable if you accept that vertically aligning stuff is bad to begin with.

To wrap up, two succesful Scala days that were inspiring and educational and a good place to put a face to twitter names and speak again with the people you only see at conferences like these.

Erik Bakker is a software developer at Lunatech Research and co-author of the book ‘Play for Scala’