NDC Oslo 2015 - Metaprogramming Elixir

Abstract

Elixir macros give programmers the power to write code that writes code. This power eliminates boilerplate, allows Domain Specific Language abstractions, and provides the freedom to extend the language. Leveraging the fact that it can be represented by its own data structures, Elixir can interrogate its own code to peer in for analysis or to add additional functionality. Used appropriately, macros offer effective module composition and code generation techniques, while more liberal use can serve as an outlet for novel insights through experimentation.

Starting from the basics of macros, we’ll explore these ideas from an introductory level through advanced topics and real-world use-cases. Along the way, we’ll see how Elixir uses meta-programming to generate parts of its own standard library. We’ll also examine how macros can be used to save time and share functionality in a fun and productive way.

Comments