Scala Days 2012

Just scribbling down some of the things I learned and liked during the Scala days at the Barbican, last week in London. I had a great time, partly because of the talks, but more importantly, because of the talk*ing* to other fellow programmers.

Sheer awesomeness

Guy Steele's Keynote

Guy Steele's talks are like good wine. They get better over time. Parts of his talks continuously keep coming back, and every time it tastes better, and leaves me with a warm and fuzzy feeling. You should really see the talk yourself when it becomes available, but their was one thing that I really really liked.

It was when he introduced one of the most important programming language concepts - and then showed a slide showing nothing at all. (If you fail to see what he was saying: it's whitespace.) It reminded me of the Bellman's map from Lewis Caroll's epic 'Hunting of the Snark':

Other maps are such shapes, with their islands and capes! But we've got our brave Captain to thank: (So the crew would protest) that he's bought us the best - A perfect and absolute blank!

I totally agree with his observation that whitespace is important. In fact, I think it's even more important than he thinks it is. Gerrit Noordzij has argued that the shape of the space between characters has a much bigger impact on the readability of text than the shape of the character itself. I know programmers who think of whitespace as noise, but perhaps - and in some cases most certainly - it's the program code that is the noise, and it's whitespace defining the overarching structure. (Note to the reader, that doesn't mean I feel like doing Python.)


I just can't tell you how much I like macros. I love them! That's not something I ever expected to say for any programming language, but I do! If you're not familiar with the idea, then I suggest that you check it out.

It basically boils down to this. You can write a function whose implementation is prefixed with a macro keyword. If you do that, and if that function would have normally returned an instance of T, then the implementation of that function should return an Expr[T] instead. And the mirror API allows you construct the AST that implements Expr[T].

That way, you're essentially constructing part of the AST that will be inlined at the position where you call that function. The prototypical example is assertions. Before, no matter how you would construct the assertion code, there would always be a runtime check to see if assertions were enabled at all. With this macro facility, that check would no longer be needed; if assertions would be disabled, you would just make sure that no assertion checks would be emitted at all.

However, this is just one of the things it allows you to do. It gets even better when you realize that it actually allows you to inspect by name parameters getting passed in. Look at the AST, that is. And then transform it. Which is essentially what is required to create something like LINQ.

The best part of all is that it supports a way to reify code. So there is a function that takes a normal expression, and then turns it into an Expr[T]. As a consequence, you don't need to construct code yourself using the mirror constructs; instead you can just write an expression as you would normally do, and then lift it into an Expr[T].


Victor Klang presented the current state of SIP-14, the Futures and Promises proposal. I like it.

  • I like that it all starts with the definition of the terms 'Future' and 'Promise'.
  • I like that it's all non-blocking and asynchronous.
  • I like the conciseness of the API, and the amount of goodness provided. I think the API would score a lot better on the 'API in bumper stickers' scale than most of the other APIs. (Admittedly, that tells you something about those other APIs as well.)
  • I like it that there is now a single API that could rule them all.

Less than awesome

JavaFX and Scala

Don't get me wrong. I love the way Scala plays with JavaFX. And the talk was good as well. I just don't think that JavaFX itself will ever go anywhere. It's just too late. I don't think it will ever be able to compete with JavaScript on the client. That makes me weary for two reasons. First of all, that means I will never enjoy the benefits of type safety on the browser. Secondly, it means all of the work being put into this, is mostly likely going to result in very little traction. I don't like being wrong, but I hope to be wrong in this case.

Anti XML

Quite honestly, it must have been that it was the first talk, but I didn't leave the room being confident that now I knew what Anti XML was really about. At the other hand: I did learn what it is not about. It's not about supporting XML 1.1, so kiss your namespaces goodbye.

Quite honestly, I'm also not convinced that baking XPath alike operators into the language is going to make things a lot better than having the ability to use genuine XPath expressions enclosed in double quotes. I think it would make the code much more readable. And with Scala's macro support in the future, we even might be able to implement compile time XPath expression validation.

Blue Eyes, Spray

I'm sure it's good. I'm not so sure it's an order of magnitude better than what we're currently using, which is Unfiltered. The Spray talk with all of the different modules reminded me a lot of SpringSource slides showing a lot of modules and their interdependencies, and even though it was discussed at length, I failed to see why it's necessary to make a distinction between web applications and Restful web services. To me it's all the same, and I'm just glad Unfiltered doesn't make the distinction. (I couldn't help wondering if the whole subject was discussed to avoid questions about Play and Spray.)

Talking about SpringSource: I also witnessed quite some VMWare / SpringSource activity during the entire conference. Also something that made me wonder...