3 ms·
I very rarely write macros but Elixir is much, much nicer to work with for having them. Probably my favorite overall library in Elixir is Ecto. It's the go-to
by AlchemistCamp 5y ago
I very rarely write macros but Elixir is much, much nicer to work with for having them.
Probably my favorite overall library in Elixir is Ecto. It's the go-to relational DB library and makes great use of macros for its query syntax DSL. The Phoenix router, controllers, etc also benefit quite a bit.
The thing that makes Elixir's macro implementation a really big win for me as a user is how explicit it is.
There is never a case of hidden magic. Just as you can see what functions are brought into a module by scrolling up and looking for the keywords "alias" and "import", you can find macros by looking for "use" and "using". This is very different from JavaScript, where another module could alter the prototype chain or overwrite attributes on any non-const object it has access to.