Write code that writes code with Elixir macros. Macros make metaprogramming possible and define the language itself. In this book, you’ll learn how to use macros to extend the language with fast, maintainable code and share functionality in ways you never thought possible. You’ll discover how to extend Elixir with your own first-class features, optimize performance, and create domain-specific languages.
small medium large xlarge
This book is exactly what the young Elixir community needs! Chris McCord does an elegant job of laying out Elixir metaprogramming step by step, with practical and wonderfully instructive examples throughout.
- Bruce Tate
President, RapidRed, LLC
Whether you’re new to Elixir or a seasoned pro, this compact book will give you the foundation you need to harness the full power of Elixir. A joy to read as it gently walks the reader toward metaprogramming mastery, it’s a thoughtful and practical guide to metaprogramming you’ll want to visit again and again.
- Matt Sears
Chris is the person to be writing this book; reading his work in open source is how I learned how to use macros. This book filled in the gaps of my understanding and improved my intuition for how Elixir the language works.
- Jason Stiebs
Metaprogramming Elixir made me want to run out and write code that writes code for me! Great voice and compelling examples!
- Zander Hill
Chris has a habit of seeing past the surface of a technology. In Metaprogramming Elixir, Chris demystifies the foundation of Elixir itself, opening the door for every Elixir programmer to build applications in fun, powerful ways.
- Ryan Cromwell
Technical director, Sparkbox
A treasure trove of metaprogramming patterns, this book is just what the community needs to communicate the power, extensibility, and practicality of metaprogramming in Elixir. After reading it, you’ll know how and why to use metaprogramming both responsibly and irresponsibly. Definitely a must-have for anyone wanting to go beyond the basics of a beautiful language.
- Gabriel Jaldon
Web developer, open source enthusiast
Release: P1.0 (2015-01-27)
Metaprogramming is one of Elixir’s greatest features. Maybe you’ve played with the basics or written a few macros. Now you want to take it to the next level. This book is a guided series of metaprogramming tutorials that take you step by step to metaprogramming mastery. You’ll extend Elixir with powerful features and write faster, more maintainable programs in ways unmatched by other languages.
You’ll start with the basics of Elixir’s metaprogramming system and find out how macros interact with Elixir’s abstract format. Then you’ll extend Elixir with your own first-class features, write a testing framework, and discover how Elixir treats source code as building blocks, rather than rote lines of instructions. You’ll continue your journey by using advanced code generation to create essential libraries in strikingly few lines of code. Finally, you’ll create domain-specific languages and learn when and where to apply your skills effectively.
When you’re done, you will have mastered metaprogramming, gained insights into Elixir’s internals, and have the confidence to leverage macros to their full potential in your own projects.
What You Need
You’ll need a computer, Elixir 1.x, and have a solid grasp of Elixir basics.
Contents & Extracts
Chris McCord is a programmer with a passion for science and building things. He spends his free time crafting the Phoenix Web Framework, speaking at conferences, and teaching others the tools of the trade. He loves community outreach and helping to grow Elixir’s wonderful community.