

Metaprogramming Elixir - kungfooguru
https://www.pragprog.com/book/cmelixir/metaprogramming-elixir

======
dpeck
For anyone looking to learn more about Elixir/Erlang, here's a dump of links
that I posted recently to the local Atlanta Elixir Meetup group.

Roughly in the order I'd recommend consuming them.

Dave Thomas - Power of Erlang, Joy of Ruby -
[https://www.youtube.com/watch?v=lww1aZ-
ldz0](https://www.youtube.com/watch?v=lww1aZ-ldz0)

Dave Thomas Elixirconf Keynote - Think Different-
[http://www.confreaks.com/videos/4119-elixirconf2014-opening-...](http://www.confreaks.com/videos/4119-elixirconf2014-opening-
keynote-think-different)

elixir-lang.org tutorial - [http://elixir-
lang.org/getting_started/1.html](http://elixir-
lang.org/getting_started/1.html)

Programming Elixir - [https://pragprog.com/book/elixir/programming-
elixir](https://pragprog.com/book/elixir/programming-elixir)

Awesome Elixir - Curated list of great libraries -
[https://github.com/h4cc/awesome-elixir](https://github.com/h4cc/awesome-
elixir)

Elixir In Action -
[http://www.manning.com/juric/](http://www.manning.com/juric/)

Learn You Some Erlang For Great Good -
[http://learnyousomeerlang.com/](http://learnyousomeerlang.com/)

Erlang and OTP In Action -
[http://www.manning.com/logan/](http://www.manning.com/logan/)

I haven't had a chance to read McCords new book, but having read his code and
interacted with him a fair bit in #elixir-lang the last few months I can only
assume I'll be adding it to the bottom of this list as an important
intermediary step to becoming proficient in Elixir along with learning OTP.

~~~
bphogan
This is a great list. I appreciate this. I have to add that your last entries
are really important. Elixir is great, but I'm finding more and more that I
have to dig into Erlang to do many, many things, because Elixir doesn't have
that many libraries yet. Things like basic hashing have to be done using
Erlang, so knowing the Erlang standard library seems to be pretty important
right now.

And yea, you're not going very far without digging into OTP, and Martin
Logan's book is pretty excellent. Great entry on this list.

~~~
adamkittelson
A lot of that is by design. It's my understanding that they made the decision
not to wrap erlang standard libraries just for the sake of wrapping them,
because the erlang standard libaries work just fine when called from elixir.

If something needed to be wrapped to make it play more nicely with elixir, for
example to change argument order to better suit elixir's |> operator, or if
there were other real benefits to wrapping an erlang library, then they might
wrap it. Otherwise if the erlang library is good just use the erlang library.

~~~
bphogan
Yea, that's what I figured. But I don't like it so much. I tend to end up
wrapping it myself just because I like piping with |>.

But my main point was that when I started, I could just look to one source for
language docs.

But as I dug in, I realized that to do a lot of things, I needed to look at
Erlang too. And then I realized I had to understand it.

It's not bad, it's just a thing that makes learning the awesome language a lot
more difficult.

------
bradfordarner
I got the book last weekend. Chris has done a wonderful job!

For me, metaprogramming is one of the things that was a deciding factor with
Elixir, in addition to all the other functional programming aspects that are
part of the language. I'm most definitely not an amazing polyglot with a wide
degree of experience with every single functional language out there, but this
feature pushed me to invest time to learn Elixir. Metaprogramming has saved me
immense time in numerous applications in Ruby. So, I consider it a critical
thing to learn.

Of course, after investing time in Elixir you very quickly learn the power of
the Erlang VM. Elixir is like a gateway drug! I now have a consistent mix of
Erlang and Elixir syntax in the stuff I'm playing around with. One of the
chief complaints for people with Erlang is the syntax. Elixir makes the entire
proposition of learning Erlang far more appealing...and then you really it is
all actually Erlang under the hood!

And, one of the big things that Elixir adds on top of the Erlang VM is
metaprogramming. There aren't a lot of great sources out there on the subject.
Chris's book is a great addition to the slowly growing Elixir library.

------
chrismccord
Author here. Fun to see this getting some HN love. Those who want a glimpse of
what Elixir metaprogramming is all about can check out my Erlang Factory SF
talk which gives a nice overview of Elixir's macro system:
[http://www.chrismccord.com/blog/2014/03/13/write-less-do-
mor...](http://www.chrismccord.com/blog/2014/03/13/write-less-do-more-and-
have-fun-with-elixir-macros/)

------
thisishugo
The first rule of Macros is: don't write macros.

However, if you are going to use (and abuse) this powerful feature of Elixir,
I can't think of anyone better than Chris McCord to help guide you on your
way. Chris' talk on Macros[0] at Erlang Factory last year was not only highly
education, but also very entertaining. If that video doesn't convince you, I
recommend you take a look at the Phoenix web framework codebase[1]. Chris is
an incredibly talented programmer, and an incredibly helpful, and patient
guide to those less skilled than he attempting to contribute code to his
projects (I know this because he held my hand through getting a pull request
merged into Phoenix some months ago when I was still playing with Elixir).

[0] [http://vimeo.com/88885763](http://vimeo.com/88885763)

[1] [http://phoenixframework.org](http://phoenixframework.org)

------
rjsamson
I bought the ebook last weekend and I have to say that Chris has done a really
great job here. For anyone looking to get deeper into Elixir, this is a great
read - can't recommend it enough!

------
alanpeabody
Even coming in with a few years experience in Clojure and having spent time
writing macros in Elixir I have found this to be a really worthwhile read (so
far).

That said, this should not be your first Elixir book (as Chris points out in
the book's introduction). It should be your second, especially if you are
interested in writing libraries.

~~~
perishabledave
Dave Thomas' Programming Elixir should be the first :)

~~~
djm_
Agreed - fantastic book and very well written.

You can get a taster of it by watching his keynote at ElixirConf. [1]

[1]
[http://www.confreaks.com/videos/4119-elixirconf2014-opening-...](http://www.confreaks.com/videos/4119-elixirconf2014-opening-
keynote-think-different)

