Status update

Eugene Burmako
05.11.2012

It's been two weeks since we published Scala 2.10.0-RC1, and it looks like the final release of 2.10.0 is coming really soon. So let's retrospect a little.

State of the art

Macros are now officially a part of the Scala language, albeit an experimental one. We have a decently working implementation and some docs (also much more docs are on the way - be sure to check the reflection guide and the macro guide at the Scaladoc site once they're up in a few days).

And what's the most important: we have several projects that already use macros, and even more are on their way. Here we'd like to take time and say a big and hearty "thank you" to our early adopters. You guys are fantastic!

Speaking of evolution, at first we imagined that macros would mostly deliver a convenient way to build DSLs or even language workbenches (that's why DSL-related use cases originally had such priority at http://scalamacros.org/usecases/index.html).

But later this perception has changed. Sure one can design much more powerful DSLs than it's possible without compile-time metaprogramming (e.g. literals for binary numbers or a LINQ-like DB connectivity toolkit). But we've mostly seen people using macros to perform low-level AST twiddling (which I think can't be classified as DSLing).

For example, there's an elaborate assert macro, a series of method inlining macros, a dynamic trait mixing macro (I know, that's my own Stack Overflow answer, but I've seen other people doing similar things as well), a macro which infers Scala types from database, a macro which generates json serialization type classes, also another serialization macro, et cetera et cetera. There's a bunch of other usages to achieve little improvements here and there (e.g. a macro that works around Scala closure conversion for better serialization), but we don't have source code to link for those. But anyways macros are still very useful for DSLs. In this department the biggest players to our knowledge are Slick, ScalaMock v3 and SBT v0.13.

Future avenues

Now while the post-release dust is settling, we're planning our next journey along the road of compile-time metaprogramming in Scala.

Our biggest interest lies in experimenting how language features such as types, implicits or annotations work together with macros. Currently macros can only work in the small, providing intra-method code generation, but with type macros, implicit macros and annotation macros it becomes possible to do stuff that transforms the very fabric of the language.

There are already designs of a theorem prover interface and an effect-capturing system that can be built on top of the new flavors of macros. We also have some sketches already outlined on this site (http://scalamacros.org/future.html), but expect more information to come over the next months.

Despite having new and shiny things to research, we definitely do not plan to abandon the freshly implemented functionality. Our macro- and reflection-related issue tracker is only slightly over 100 bugs and improvement suggestions. We dare you to double this amount!

On a more serious note, we're well aware of the limitations of the current macro system (separate compilation, awkwardness in scenarios the involve untyped or partially typed trees). There are some ideas how to overcome these hurdles, and we plan to look into these ideas as we go.

Putting it in a nutshell

Download the freshly released Scala 2.10.0-RC1, get started using our documentation, explore the macrology together with us and have fun! We hope you'll like macros - the incarnation of compile-time metaprogramming for Scala.