Under the Hood of Macros in Elixir
Really cool article!<p>I&#x27;ve been learning Elixir for a couple of weeks now and metaprogramming is one thing that trips me up. Especially just browsing the source of Phoenix for the first time, it was&#x2F;is really hard to follow what&#x27;s happening.<p>I come from a PHP background, using Laravel, which is regarded as a &quot;magical&quot; framework, but I think a stark difference is the lack of robust metaprogramming in PHP. Almost everything can be traced back to a parent object or a trait. The few magic methods you may see floating around are usually implemented in `__get()` and off the top of my head, I think they usually are only magic getters&#x2F;setters on models.<p>Laravel has a concept of macros that you can use to extend objects injected from the DI container, but each must be explicitly defined, so grepping for them is easy.<p>In Phoenix, I could end up with a generated function at compile time that is nonexistent in my git repo. Not being able to click through to the definitions of these has tripped me up. A function called `{my-domain}_path()` feels like it should have an explicit definition.<p>Still enjoying Elixir and hopefully I can work with it professionally at some point! I just wish it was easer to trace back where some of these things functions come from when you&#x27;re using them far away from the definition.