📜 ⬆️ ⬇️

Scala Days 2012

I love Scala very much, thanks in large part to my love, we use this language in our projects: writing great fun on it. For a couple of years I have been looking and thinking about going to Scala Days . Last year they were in California: a beautiful place, but far enough and I could not go. 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 a 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 introductory speech, after which reports began.

Pragmatic Testing Nirvana with ScalaTest, ScalaMock and SubCut


Bill Winners (right), the author of “Programming in Scala”, told 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 much on the level).

Dick Wall talked about SubCut - the Google Guice port on Scala. The method of work and the terms used are completely identical, but improvements have been made to make the Scala code cleaner. Also, as in Guice, you can bind an implementation by the class name (and optionally an identifier) ​​or make your provider that will fully control the creation of objects. The only thing, as I heard, is that Scopes doesn’t have full support yet, so you’ll have to emulate Scopes through providers.



Concurrent Programming With Futures, Offers, and Brokers


Marius Eriksen from Twitter talked about synchronization primitives. I started with the canonical “Communicating sequential processes” , moved to the basic objects: Sync and Channel.

From them he moved to Futures and Promises. In short, Future allows you to return the result of a calculation, with the proviso that it may not yet exist or an error may occur during the calculation. However, on the basis of 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 to 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 many times made a reservation that Victor Klang would tell further about Futures and Promises.

Victor Klang told about the fact that these are very common objects and until now they were not standardized in any way: there is an implementation in Scala, Java (for Future), in akka and in several other libraries that he used. In Scala 2.10 there will be a standard Futures / Promises library (scala.concurrent), which aka will gradually migrate to. New standard Futures / Promises are all good, are composited, many useful methods are defined for them, there is support in the standard library.



Coffee break


All breaks and lunch were held in a tropical garden. It was possible to find interesting interlocutors, to charge coffee, to get from a laptop to work on a VPN or play dzhengu:











Towards Haskell in the Cloud


After the break, Simon Peyton-Jones , one might say, the creator of Haskell, took the stage. 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 (using Haskel’s example) so that it runs on the cloud, and the necessary calculations can freely circulate and run on different nodes. Moreover, the source code does not initially need 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 large amount of data.



I especially want to mention the extravaganza that accompanied Simon's performance. Simon rushed around the stage, articulated, presented his theses in bright colors and occasionally teased the community with the fact that Haskell was better and cleaner than anything in the Rock. I was genuinely surprised how he can tell all this with such speed. I will give you the pleasure to admire a small fraction of its expression:



Async & Non-Blocking Scala for Fun And Profit


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



It is so bad to write code that blocks the flow for each request:



Generic Numeric Programming Through Specialized Type Classes


Eric Osheim told about his library on working with numbers, where he streamlined all operations and singled out properties exactly as it does in mathematics. That is, when the program requires it, with its library you can get to semigroups, rings and monoids, which are allocated in 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 splitting them into sections of work (unit of work) and addiction analysis. If I understood everything correctly.



Asymmetric Lenses in Scala


Runar Bjarnson ( Apocalisp ), one of my favorite authors writing about Scala, wrote a Tony Morris article on asymmetrical lenses. Asymmetric lenses are objects that provide access to or modify the properties of other objects, because in purely functional languages ​​all objects are immutable. The lens defines two methods similar to getters and setters:

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

Here R is the type of the object from which we read 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 (product or “choice”) can be defined on them, and other objects and operations can be expressed with their help. In the end, everything comes to the fact that you can write programs in an almost imperative style, while maintaining functional cleanliness and immutability. To work with lenses, there is even a special plug-in for the Lensed compiler that allows you to use lenses right away as part of the tongue.



London excursion 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 the Lincoln's Inn , the ancient atmosphere of which left no one indifferent. Almost everything in the collection:



Bill Winners personally sells Programming in Scala .



Sometimes dinner was interrupted, Martin thanked the speakers and those who had gathered, especially the organizers of 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 Oderski told what's 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 pie :) Each module is based on the well-known cake pattern . One cake is the program model in the compiler, the second is a mirror for display, the common code is put into the third cake (above them) and, finally, on top of these pies is one beautiful pie facade that will be convenient to use and that will hide the implementation features of the underlying pies.



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

Introduction to Scala-IO


Jess Eyshar is developing an IO library for Scala . Its library has one set of abstractions, which is convenient and allows not to be confused by beginners, uses the expressive capabilities of the language better, while he pays a lot of attention to performance, his code checks 3000 tests, of which 300 tests performance. It’s too early to talk about it, but in the future there is a chance that it is his library that will become standard for the organization of input-output in Scala, so now it makes sense to take a closer look.



Binary resilience


Josh Suereth explained how to write and update libraries so that they work with older versions of software without breaking compatibility. Special attention was focused on what the trait converts to when compiling into bytecode, and what it is equivalent to in Java.



Remixing the Abstraction Compromise


Nathan Hamblen shared general considerations that in the future we will have to interact with higher-level abstractions, which, at the same time, will have to give access to lower-level mechanisms, which will give us optimization of work and increased productivity. Nathan also shared his experience of unfiltered and netty implementation in his company to replace traditional Java servlets. Showed how much more requests this allowed to handle and how the response time was reduced.



Afterparty


When it was over, everyone was invited to the pub nearby. We are in the company of the Russian participants of the conference, we hear what we hear, we make plans for further cooperation:



Conference videos are gradually becoming available at: http://skillsmatter.com/event/scala/scala-days-2012 . So, if you wanted to, but did not manage to go, you can already start looking through reports that are interesting to you.

See you on the next Scala Days! The next time they were promised again in Europe.

Source: https://habr.com/ru/post/142546/


All Articles