Daniel Chruściak

Senior software developer @ Javeo

Software Developer with over 10 years experience. Currently Team Leader in Javeo where he builds next-generation applications. The enthusiast of Scala and functional programming, also follower of simplicity and clean code.

If you are perfectionist you want to minimize the amount of boilerplate code. You’ve heard about Scala and you think it is a good idea to use it as your language of choice. But it turns out that there are places where boilerplate code is unavoidable and you want do better.  Your dream is to have library or maybe some kind of DSL which will read your mind without explicit orders. Maybe you’ve heard about  metaprogramming in Ruby, but you dropped the idea of using it because of lack of static typing. Is there a way to generate code using the advantages of static typing and still keep the expressiveness?

Yes! Scala is an expressive language with many outstanding features. One of them are Scala macros. It is a fantastic multitool for creating rich and easy to use libraries. Macros are used under the hood of many known libraries such as Slick, frameworks like Play, and even within the Scala language. They allow developer to take advantage of self-generating and self-mutating code.
Our talk will consist of 3 parts:
- Introduction to macros(overview and main concept),
- example of using macro annotations (with usage of quasiquotes- rich domain specific API for AST tree manipulation)
- presenting how to write your own library based on the example of our solution.

During this talk we will outline advantages and downsides of macros. We will describe and overview what quasiquotes are, and how to use them in a flexible way. Moreover, we will specify the main problems which we encountered during writing our own library, now used in production.
We had a lot of fun when learning macros. They helped us to write a library, which we now use with Play Framework and Slick. We believe that macros can be used by developers more frequently to solve everyday problems. Come and find out if they can help you too.

Video ←Back