Summary
Metaprogramming is one area where Crystal excels. It provides us with a pretty powerful system that can be used for code generation and reducing boilerplate/repetition, while still being fairly simple compared to other languages. However, this power should be used sparingly when appropriate.
In this chapter, we learned how and when to use macros to reduce boilerplate, how to tap into various Crystal events via macro hooks, and were introduced to the macro API to support creating more advanced macros.
In the next chapter, we are going to look at annotations and how they can be used in conjunction with macros to store data that can be read at compile time.