- First ScalaDays in Lausanne (2010), sold out with 150 attendees. Scala 2.8 was announced.
- Second ScalaDays in Stanford (2011), sold out with 260 attendees. Commercial support, Typesafe Stack with Scala 2.9 and Akka 1.1.
- Third ScalaDays in London (2012), sould out with 400 attendees. Typesafe Stack with Scala 2.9.2, Akka 2.0, Play! 2.
Where we are now (05:45)
- Scala 2.10 on the horizon, basically feature-complete.
- Refinements, testing and release, will happen in the next months.
Scala 2.10 overview (06:20)
- Lots of work on tooling: Eclipse, IntelliJ, ... more features, better performance.
- Low-level concurrency framework in the standard library (Futures and Promises), used by both parallel collections and Akka.
- Native reflection framework.
- A few new language features.
Reflection Framework overview (08:05)
- Cake pattern has a central role, improvements in 2.10 (dependent method types) make it more useful.
- Compilers and reflection are quite similar: Both need to deal with the same concepts, answer similar questions.
- Differences between compilers and reflection: Where does the information come from?, Generate code vs. invoke pre-generated code, error messages vs. exceptions, thread-safety, (im)mutability of types, ...
Reflection in 2.10, demonstration (12:05)
Mirror-based reflection (16:50)
- Mirrors return the reflective information of runtime values.
- Different mirrors can provide different characteristics.
- Types of different mirrors are enforced to be incompatible with each other: Reflects the design of VMs that for instance even the same types on different machines are distinct.
- Common supertype allows reasoning about all mirrors.
Implementation of reflection (18:30)
- Functionality for trees, symbols, types, names.
- Functionality to decompose and explore relationships between them, ...
- Roughly equivalent to the core of the language specification and the core of the compiler.
Comparison with Java (19:15)
- Java has a quite complex typesystem since Generics were introduced.
- What is Java approach? Pretty much empty interfaces, no useful methods defined.
- Want to do anything non-trivial with types in Java? Write your own compiler/typechecker!
- Why was it done this way? Would have required to write essential parts of a compiler (hard) and to make sure both compilers always agree (almost impossible). Smart decision of the Java designers to not suffer this maintenance nightmare.
Scala's approach (22:00)
- Unify the core parts of compilers and reflection.
- Compiler architecture: Object-oriented encapsulation, seperation of concerns. Use a cake pattern in which every component has a self-type that contains all its required dependencies ("Slices of the cake").
- How to integrate reflection?
- Multiple cakes: compiler cake (`scala.nsc.Global`) and reflection cake (`scala.reflect.runtime.Mirror`) inherit from common super-cake (`scala.reflect.internal.Universe`), which captures common information.
- Refactor common functionality into super-cake, let individual cakes handle differences (e. g. compiler cake: IO, reflection cake: thread synchronisation)
- Refine super-cake (`scala.reflect.internal.Universe`) by providing a cleaned-up facade to the user on top, `reflect.api.Universe`.
- Java's interfaces not enough, Scala leverages abstract types to both present a convenient interface to the user and allow elegant/efficient implementation behind the scenes.
Reflection summary (29:50)
- Scala is a pretty regular language:
- Everything can be nested: Classes, methods, objects, types.
- Everything can be abstract: Methods, values, types.
- Type of `this` can be declared freely to express dependencies.
- Enables expression of cake hierarchies for software design in the large.
3 comments
[ 2.2 ms ] story [ 15.3 ms ] threadRetrospective (00:00)
- First ScalaDays in Lausanne (2010), sold out with 150 attendees. Scala 2.8 was announced.
- Second ScalaDays in Stanford (2011), sold out with 260 attendees. Commercial support, Typesafe Stack with Scala 2.9 and Akka 1.1.
- Third ScalaDays in London (2012), sould out with 400 attendees. Typesafe Stack with Scala 2.9.2, Akka 2.0, Play! 2.
Where we are now (05:45)
- Scala 2.10 on the horizon, basically feature-complete.
- Refinements, testing and release, will happen in the next months.
Scala 2.10 overview (06:20)
- Lots of work on tooling: Eclipse, IntelliJ, ... more features, better performance.
- Low-level concurrency framework in the standard library (Futures and Promises), used by both parallel collections and Akka.
- Native reflection framework.
- A few new language features.
Reflection Framework overview (08:05)
- Cake pattern has a central role, improvements in 2.10 (dependent method types) make it more useful.
- Compilers and reflection are quite similar: Both need to deal with the same concepts, answer similar questions.
- Differences between compilers and reflection: Where does the information come from?, Generate code vs. invoke pre-generated code, error messages vs. exceptions, thread-safety, (im)mutability of types, ...
Reflection in 2.10, demonstration (12:05)
Mirror-based reflection (16:50)
- Mirrors return the reflective information of runtime values.
- Different mirrors can provide different characteristics.
- Types of different mirrors are enforced to be incompatible with each other: Reflects the design of VMs that for instance even the same types on different machines are distinct.
- Common supertype allows reasoning about all mirrors.
Implementation of reflection (18:30)
- Functionality for trees, symbols, types, names.
- Functionality to decompose and explore relationships between them, ...
- Roughly equivalent to the core of the language specification and the core of the compiler.
Comparison with Java (19:15)
- Java has a quite complex typesystem since Generics were introduced.
- What is Java approach? Pretty much empty interfaces, no useful methods defined.
- Want to do anything non-trivial with types in Java? Write your own compiler/typechecker!
- Why was it done this way? Would have required to write essential parts of a compiler (hard) and to make sure both compilers always agree (almost impossible). Smart decision of the Java designers to not suffer this maintenance nightmare.
Scala's approach (22:00)
- Unify the core parts of compilers and reflection.
- Compiler architecture: Object-oriented encapsulation, seperation of concerns. Use a cake pattern in which every component has a self-type that contains all its required dependencies ("Slices of the cake").
- How to integrate reflection?
- Multiple cakes: compiler cake (`scala.nsc.Global`) and reflection cake (`scala.reflect.runtime.Mirror`) inherit from common super-cake (`scala.reflect.internal.Universe`), which captures common information.
- Refactor common functionality into super-cake, let individual cakes handle differences (e. g. compiler cake: IO, reflection cake: thread synchronisation)
- Refine super-cake (`scala.reflect.internal.Universe`) by providing a cleaned-up facade to the user on top, `reflect.api.Universe`.
- Java's interfaces not enough, Scala leverages abstract types to both present a convenient interface to the user and allow elegant/efficient implementation behind the scenes.
Reflection summary (29:50)
- Scala is a pretty regular language:
- Everything can be nested: Classes, methods, objects, types.
- Everything can be abstract: Methods, values, types.
- Type of `this` can be declared freely to express dependencies.
- Enables expression of cake hierarchies for software design in the large.
Macros overview (30:50)
- Once reflection and co...
http://skillsmatter.com/podcast/home/scala-days-keynote-3018