An overview of Scala World 2016
Once again, 47 Degrees was a Scala World sponsor and we were happy to have two members of our team present on various technologies in the Scala ecosystem. Our CTO, Raul Raja, presented on patterns, anti-patterns, and pitfalls we’ve observed in the wild putting Scala to practice in projects, and Senior Software Engineer Noel Markham went through Practical ScalaCheck. We also sent an entourage to soak up new Scala knowledge and network with the community.
Here are summaries from a few of the presentations we attended:
Jan Christopher Vogt
- CBT - fast, intuitive, convenient Scala Builds
- Review by Diego Alonso
Jan went on to say that he had been using
the major build tool for
Scala projects, for a while, but that he found it to have some shortcomings.
1) The internal model to reprent builds and build tasks is too complex,
and the API contains some too-cryptical operators somewhat difficult to learn.
His main pain-point came at the time of writing an
sbt has a poor command line interoperability, which makes it difficult to
compose it within Unix-like pipelines. This makes configuring
sbt builds too hard.
sbt uses Apache Ivy, for dependency management, which makes makes builds spend too long a time in resolving those dependencies.
These shortcomings prompted him to write an alternative build system,
To simplify the internal model (1)),
cbt relies on a direct use of the linguistic constructs of
Scala. Thus, in
cbt a project build or a configuration is a mere
Scala class; a task of that build is just a
def method definitions in that classes, and build plugins are just
trait to integrate through mixin. This allows, for instance, to separate two project builds for an application and its tests.
To improve dependency management (3)),
cbt handles Maven repositories. Instead of the repository pooling used in
cbt explicitly bounds each dependency to a repository from which to load the files it needs. To improve speed,
cbt uses caching of
.jar files to be faster.
Jan also mentioned some of
cbt features, such as the ability to add dependencies to
source code repositories, or continuous compilation, which automatically recomiles any project after changes into a source file, or changes in the build file, or to changes in cbt itself.
cbt has been tested on small projects and found to work very efficiently. However, it is still a work in progress, and Jan mentioned some of the usability bugs or missing features whose resolution is currently ongoing work.
You can view the slides from the presentations here:
Rob Norris presents Pure Functional Database Programming with Fixpoint Types
- Pure Functional Database Programming with Fixpoint Types
- Review by Diego Alonso
Abstract: by using Fix, Free, and Cofree, you can create load and store recursive data structures in a database.
doobie follows a Functional Programming style, in which operations and their compositions are values instead of actions, and the execution (or interpretation) of operations is separated from their representation and composition.
Rob’s talk centers on recursive data structures, used to represent hierarchies. He uses as an example an academic genealogy, made of advisor-student relations. The problem that he deals with is how to build a generic scala method to read from (or write to) the database of a whole hierarchy. The difficulty is that a database only works with the nodes of the hierarchy.
His solution is based on the use of the generic datatypes
Cofree, and their implementation in
scalaz. With these, one can implement a hierarchy, using a more simple data type (the professor). For these representations, he describes a Scala method to load and store hierarchies, implemented as
Free, that is generic on the particular type of hierarchy.
His presentation shows how the use of these kind of FP patterns and concepts, which in itself are difficult to grasp, allow us to write more simple programs to handle
more complex talks. As a final note, Rob thanked 47 Degrees for designing the
doobie logo. (You’re welcome and thank you!)
You can view the video from his talk here:
Ólafur Páll Geirsson
In his talk, Òlafur gave a small workshop on
scala.meta, a metaprogramming toolkit for Scala. Scala Meta is an important component for future Scala releases, since it is to replace
scala.reflect as the basis for implementing
macros, an advanced feature of
In the first part of his talk, he describes the basic notions of
scala.meta, such as
tokens or abstract syntax trees (as the representation of Scala programas), and quasiquotes for representing scala code withn a Scala program.
In the second part, he presented rewrite rules, and he gave a guided tour for them.
As a motivating example, he chose the bad practice of writing
catch e: Throwable
for handling general exceptions, which can causes problems.
To solve this problem, he uses
scala.meta to implement a Rewrite Rule that replaces
every appearance of that line by the more safe
catch NonFatal(a). He shows how, since these AST transformations are
scala methods within a
scala program, it is possible to write unit tests to check if they work correctly. Once written, such rules are easy to package, redistribute, and integrate into any project’s build. This makes them easier to use than other existing code rewriting solutions, based on
The last part of his talk dwelled on
scala macros. He argued that macros in their current form are regarded as a bit scary and confusing, and they are too tied to the current
scala compiler, so they are to be dropped from
dotty in their present form. He described how
scala.meta provides some features of scala macros as syntactic macros, which are compatible with
dotty. As his guiding example, he showed how to write a macro annotation to measure a procedure’s execution time. A singular moment during this presentation came when he performed for the first time, a macro expansion in
dotty; an operation that he regarded as a “holy grail” in the development of
The talk ended with some discussions among the attendees about ongoing work, the design decisions, and the problems for compatibility.
You can view his tour here:
- Generic Derivation: the hard parts
- Review by Javier de Silóniz
Travis Brown is the author of the Circe JSON encoding/decoding library. In his talk at Scala World, he explained the concept of generic derivation, which allows to perform automatic conversion of case classes and seales families. This is done in compile time and powered by Shapeless. During the talk, Travis went through the Circe implementation history, going from the use of macros to adopting Shapeless, and the different problems they encountered (i.e.: type collisions, keeping priorities among derived instances) and the different routes they took to solve them. He also offered some light on how compilation times can be improved while using Circe. Finally he went through the most requested features for circe, and some possible approaches to achieve those.
Code used throughout the talk can be found at http://www.github.com/travisbrown/circe-derivation
View the slides here:
- Run Wild, Run Free: A team’s journey over Scala’s emerging FP patterns
- Review by Javier de Silóniz
Raul Raja, 47 Degrees CTO, went through several code samples illustrating common issues most people run into when starting developing with Scala, based on his experience working with more than 10 teams and dozens of developers. First he ellaborated on the problems many developers (specially using web frameworks like Play) find working with Futures, specially when handling errors if they’re not specifying exception information in their types. To treat those problems, he showed the uses of Monad Transformers to avoid nested pyramids when using Futures in combination with other monads like Option, and how to better specify error on return types by the use of sealed ADTs and the XOR monad. He also showed how non-determinism can happen when wrongly handling side-effects in dependent Futures running in parallel (including nightmares like wrong order of effects, random deadlocks…).
The talk went further by showing the benefits of abstracting over the return type of our functions, in a way that they end being data-specific and can become behaviour-specific. Furthermore, it was also shown how it’s also possible to abstract over implementation as well, by the use of Free Monads / Applicatives; and details on how can developers can specify their business logic through Algebras, in order to decouple them from the actual implementations. Raul finished the talk wishing for a brighter future for the language, so Scala can be made more FP friendly.
You can view the slides from this talk here:
Stay tuned for our recap video as well as the videos from the presentations currently being uploaded to the Scala.World YouTube Channel. You can also browse pictures taken at the event here: Scala World 2016 Photos
If you enjoyed Scala World, make sure to check out Lambda World happening next week in Cádiz, Spain! There’s still time to get tickets if you hurry!