Scalan: a reasonably typed meta programming framework in Scala by Alexander Slesarenko
This video was recorded at Scala Days Berlin 2016 follow us on Twitter @ScalaDays or visit our website for more information http://scaladays.org Abstract: In this talk I will report about our results with Scalan project [1]. Even though the talk will be self contained, it is also a continuation of the talk given last year in Amsterdam [2] where I focused on a high-level overview of Scalan and its goals. However, many topics were not covered and even mentioned. The main topic of this talk is a unique meta-programming style and idioms available in Scalan for more than a year, but not yet widely known in Scala community [3]. We believe they can be successfully used in many existing and new projects. Meta-programming in Scala is a hot topic and a lot of efforts has been put in making it first-class by introducing and developing Scala Macros [4] and LMS [5] among others. However, meta-programming is sufficiently more complex, error prone and hard to debug than usual programming. Moreover, meta-programming experience depends on the choice of intermediate representation and supported language, in particular which data structures are used and what manipulations are defined out-of-the-box This is clearly illustrated in Dotty [6] where similar motivations has lead to introduction of Denotations and new encoding of High-kinded Types to name a few. Scalan's meta-programming style and idioms [3] is the result of the following design choices: - use graph-based IR for program representation and manipulation even though it may seem harder to deal with - focus on optimizations of the functional subset of Scala as the first priority and motivation - allow limited usage of effectful operations, to have full control of the performance of generated code - use standard Scala compiler and toolchain in particular Scala Macros and compiler plugin infrastructure - exploit Scala's powerful type-level computations and DSL embedding flexibility to remain type safe most of the time My talk is oriented to a wide audience of Scala developers who love functional programming style and still care about performance. People may find it useful to add meta-programming based performance optimization and code generation capabilities to their domain-specific libraries. This is going to be a tutorial-like talk with REPL sessions and live examples of interesting non-trivial program transformations that can be easily composed in Scalan.