Back to Home

Scala Days 2012 / Tinkoff.ru Blog

scala days · barbican · scala · London

Scala Days 2012

    I really love Scala, largely thanks to my love, we use this language in our projects: it is a great pleasure to write on it. For a couple of years I watched and considered going to  Scala Days . They were in California last year: a great place, but I couldn't go far enough. In the same year, Scala Days was held in London (April 17-18), it was a great opportunity, London is much closer to Moscow than Stanford, I shortened my short vacation and went.



    Below is a review of the reports that I got, and general impressions of the event with photos.

    Scala Days was held in  Barbican  - a large complex of buildings where many cultural events are held, mainly related to art.





    After registration, there was a small opening speech, after which the reports began.

    Pragmatic Testing Nirvana with ScalaTest, ScalaMock and SubCut


    Bill Winners (right), the author of Programming in Scala, spoke about ScalaTest , how to write tests in BDD-style, about integration with developer tools (using Eclipse as an example, although I personally tried IntelliJ IDEA, everything is very level).

    Dick Wall talks about SubCut  - Google Guice porton Scala. The methodology and terms used are completely identical, but improvements have been made to make the code on Scala cleaner. Just like in Guice, you can bind an implementation by class name (and optionally by identifier) ​​or make your own provider, which will completely control the creation of objects. The only thing I heard is that there is no full support for Scopes, so you have to emulate Scopes through providers.



    Concurrent Programming With Futures, Offers, and Brokers


    Twitter Marius Ericksen spoke of synchronization primitives. Started with the canonical "Communicating sequential processes" , moved on to the basic objects: Sync and Channel.

    From them he moved on to Futures and Promises. Briefly, Future allows you to return the result of a calculation, with the caveat that it may not yet exist or that an error may occur in the calculation. However, based on such a “future” result, it is possible to create calculations that obtain the following “future” results. That is, a composition is defined for them and, therefore, they are a monad . Promise is a reverse object, it allows the client to invoke the operation that will be performed.

    When he reached the end, he remembered Offers and Brokers: “Well, Offer is Promise, and Broker is Channel, that's what we call them on Twitter,” he says. Gave a link to open source on  GitHub .



    The Future I was Promised


    In the last report, Marius mentioned many times that Victor Klang would further talk about Futures and Promises.

    Victor Klang talked about the fact that these are very common objects and hitherto they were not standardized in any way: there is an implementation in Scala, Java (for Future),  akka, and a few other libraries that he used. The  Scala 2.10 is the standard Futures / Promises library (scala.concurrent), which gradually smigriruet akka. The new standard Futures / Promises are good for everyone, they are composable, many useful methods are defined for them, there is support in the standard library.



    Coffee break


    All breaks and lunch took place in the tropical garden. You could find interesting interlocutors, recharge your coffee, climb from your laptop to work on a VPN or play a game of jenga:











    Towards Haskell in the Cloud


    After the break, Simon Peyton-Jones , the creator of Haskell, was put on the scene . Simon's speech was not about Scala itself, but about the benefits of functional programming for parallel computing. Specifically, Simon talked about how to organize the program and what language tools are needed for this (for example, Haskell), so that it runs on the cloud, and the necessary calculations could be freely circulated and performed on different nodes. Moreover, the source code initially does not have to be on all nodes of the cloud. In particular, he cited as an example the project of his student, whose system overtook a similar one deployed on Hadoop with a lot of data.



    I would especially like to note the extravaganza that accompanied Simon's performance. Simon rushed around the stage, articulated, presented his theses in bright colors and occasionally teased the community that Haskell was better and cleaner than the Rocks in something. I was sincerely surprised how he could tell all this at such a speed. I will give you the pleasure of admiring a small fraction of its expression:



    Async & Non-Blocking Scala for Fun And Profit


    Brendan McAdams (author of the MongoDB driver for Scala) described, using his driver as an example, how to correctly write code for asynchronous non-blocking operation using Netty or pure Raw NIO. Separately, he told how functional techniques can help to streamline code and handle errors.



    It’s so bad to write code blocking the stream for each request:



    Generic Numeric Programming Through Specialized Type Classes


    Eric Osheim talked about his library on working with numbers, where he ordered all operations and selected properties exactly as it does in mathematics. That is, when the program requires it, with its library you can get to the semigroups, rings and monoids, which are separated into separate Type Classes .



    Lightweight Polytypic Staging: a new approach to Nested Data Parallelism in Scala


    Our compatriot Alexander Slesarenko had a rather complicated report on how, using his DSLs (suitable, in general, for any program), it would be possible to execute programs written on them with the maximum degree of parallelism, by dividing them into sections of work (unit of work) and dependency analysis. If I understood everything correctly.



    Asymmetric senses in scala


    Runar Bjarnson ( Apocalisp ), one of my favorite authors writing about Scala, made an article by Tony Morris about asymmetric lenses. Asymmetric lenses are objects that provide access or modify the properties of other objects, since in purely functional languages ​​all objects are immutable. The lens defines two methods similar to getter and setter:

    case class Lens[R,F] (
      get: R => F
      set: (R,F) => R
    )

    Here R  is the type of the object from which we are reading the property, and  F  is the type of this property itself. Runar displays a composition for these lenses as a series of object changes and says that such complex modifications can then be transferred, more complex operations can be defined over them (product or “choice”), and other objects and operations can be expressed with their help. In the end, everything comes to the point that you can write programs in an almost imperative style, while maintaining functional cleanliness and immutability. For working with lenses, there is even a special plug-in for the Lensed compiler , which allows you to use lenses immediately, as part of the language.



    London tour and dinner


    When the speeches ended, we arranged a trip around London on the famous red double-decker buses. After the trip, we were brought to Lincoln's Inn , whose ancient atmosphere did not leave anyone indifferent. Almost everything assembled:



    Bill Winners personally sells Programming in Scala .



    Sometimes the dinner was interrupted, Martin thanked the speakers and the audience, especially the organizers from Skills Matter , noticed that for the very first time 12 people gathered at a similar meeting :)



    The next day began with a general report by Martin himself.

    Where is Scala going?


    Martin Odersky said what will be new in Scala 2.10: futures / promises, Scala's own reflection / reification, macros and many compiler optimizations.



    The focus was on reflection / reification and macros. Reflection will be built in the form of a pie of pies :) Each module is based on the notorious cake pattern . One pie is the model of the program in the compiler, the second is a mirror for display, the general code is placed in the third pie (above them) and, finally, on top of these pies there is one beautiful facade pie, which will be convenient to use and which will hide the features of the underlying implementation pies.



    Macros allow access to ASTthe program itself. That is, it will be possible, like reflection, to walk through the body of the method line by line and find out in which line which code is executed. Such an addition should make it possible (according to one of the interlocutors) to carry 90% of the compiler into these macros, clearing the kernel and making it possible to write language extensions without expensive development of support for each of them in all tools.

    Introduction to Scala-IO


    Jess Eyshar is developing an IO library for Scala . His library has one set of abstractions, which is convenient and allows beginners to not get confused, makes better use of the expressive capabilities of the language, while it pays a lot of attention to performance, its code checks 3000 tests, of which 300 tests performance. It is too early to talk about this, but in the future there is a chance that it will be his library that will become standard for organizing I / O in Scala, so now it makes sense to take a closer look.



    Binary resilience


    Josh Suereth (Josh Suereth) told how to write and update libraries so that they work with older versions of the software, without breaking compatibility. Particular attention was paid to what trait is converted to bytecode when compiling and what it is equivalent to in Java.



    Remixing the Abstraction Compromise


    Nathan Hamblen shared his thoughts on the idea that in the future we will have to interact with higher-level abstractions, which, at the same time, will provide access to lower-level mechanisms, which will give us optimization of work and increase productivity. Nathan also shared his experience implementing unfiltered and netty in his company to replace traditional Java servlets. It showed how much more requests it allowed to process and how the response time was reduced.



    Afterparty


    When it was over, everyone was invited to a pub nearby. We are in the company of Russian participants in the conference, we are discussing what has been heard, plans for further cooperation are being made:



    Video from the conference is gradually becoming available at: http://skillsmatter.com/event/scala/scala-days-2012 . So, if you wanted to, but failed to go, you can already start viewing the reports you are interested in.

    See you at the next Scala Days! The next time they were again promised to be held in Europe.

    Read Next