Keynote - Martin Odersky: Reflection and Compilers

Play Keynote - Martin Odersky: Reflection and Compilers
Sign in to queue


Reflection and compilers do tantalizing similar things. Yet, in mainstream, statically typed languages the two have been only loosely coupled, and generally share very little code. In this talk I explore what happens if one sets out to overcome their separation.

 The first half of the talk addresses the challenge how reflection libraries can share core data structures and algorithms with the language's compiler without having compiler internals leaking into the standard library API. It turns out that a component system based on abstract types and path-dependent types is a good tool to solve this challenge. I'll explain how the "multiple cake pattern" can be fruitfully applied to expose the right kind of information.

The second half of the talk explores what one can do when strong, mirror-based reflection is a standard tool. In particular, the compiler itself can use reflection, leading to a particular system of low-level macros that rewrite syntax trees. One core property of these macros is that they can express staging, by rewriting a tree at one stage to code that produces the same tree at the next stage. Staging lets us implement type reification and general LINQ-like functionality. What's more, staging can also be applied to the macro system itself, with the consequence that a simple low-level macro system can produce a high-level hygienic one, without any extra effort from the language or compiler.







Download this episode

The Discussion

  • User profile image

    I don't see slides and camera doesn't zoom on screen :-\

  • User profile image

    @borkdorkork: Hi. We don't have the slides available yet. We hope to, though!


  • User profile image
    Andre van Delft

    The sound is terrible. Big pity.

  • User profile image

    @Andre van Delft:

    We are looking into what we can do (the signal we received at the venue was just too maxed out and there is no pro audio equipment serving that room). We have a skilled editor looking into these audio "issues". Stay tuned.


  • User profile image

    Oh, already in progress! 

    Great talk here.  Smiley

    (I agree on the audio being sub-par. Compare the audio to e.g. the latest episode of cloud cover and you'll have much more pleasant voice recordings. The content rocks though.)

  • User profile image

    @exoteric: Yeah. The audio system at the venue was less than stellar. We did what we could do. Now, as I mentioned above, we are working on it in post-production. (well, post post-production at this point). No guarantee we can magically make it better, but we're trying. No need to discuss this more on this post. Keep on topic!



  • User profile image

    Scala may be the best choice for JVM environment. It gives developers some functional concepts but is quite simple language still (for a Java developer). This was a great presentation. Also challenging audience.

    However, I didn't like the "Cake pattern". It reminds me of the C# partial classes: Try to be object-oriented (classes) but still break two basic design principles of OO:

    1. Single responsibility principle: Composition classes often have many responsibilities.

    2. Open Close Principle: Software entities like classes, modules and functions should be open for extension but closed for modifications. This means that the internal state and design of the entity should not be visible to outside.

  • User profile image

    guys..see the date(2nd April 2101)

Add Your 2 Cents