Hacker News new | comments | show | ask | jobs | submit login
Metaprogramming Elixir (pragprog.com)
207 points by kungfooguru on Feb 5, 2015 | hide | past | web | favorite | 22 comments



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

Dave Thomas Elixirconf Keynote - Think Different- http://www.confreaks.com/videos/4119-elixirconf2014-opening-...

elixir-lang.org tutorial - http://elixir-lang.org/getting_started/1.html

Programming Elixir - https://pragprog.com/book/elixir/programming-elixir

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

Elixir In Action - http://www.manning.com/juric/

Learn You Some Erlang For Great Good - http://learnyousomeerlang.com/

Erlang and OTP In Action - 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.


Also checkout How I Start Elixir http://howistart.org/posts/elixir/1 and Erlang http://howistart.org/posts/erlang/1


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.


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.


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.


Agree completely.

For me its all about OTP, thats the difference maker with Elixir/Erlang, without that its just another functional language, with it is an incredibly powerful tool/framework for building impressive distributed fault tolerant systems.


I agree with you so much. I find myself digging into Erlang docs more and more.

That being said, I think there needs to be a communal effort to improve Erlang documentation. It is very terse. One of the points brought up in Garret Smiths talk: https://www.youtube.com/watch?v=3MvKLOecT1I


If I may, I feel that there's a better version of the first video. The version you linked suffers from terrible framing where you can't see a single line of code he writes. This video has a much better view, but unfortunately has awful sound. For me though, code is more important than sound quality.

https://www.youtube.com/watch?v=KQwEmdOH-GM


yeah, I found that one, but I couldn't deal with the sound and I felt that the videos were more about getting the general idea of Elixir and understanding some of the things you could do with it in an infotainment way.

I know were you're coming from though, its a really good preso with surprisingly bad recordings.


Erlang in Anger (Frank Herbert): http://www.erlang-in-anger.com


Thanks for bringing this up. I've seen and heard it mentioned before and never took the time to seek it out.


*Fred Hebert


Yeah, otherwise it would be http://www.the-erlang-must-flow.com/


yeah, I'm sure thats a good addition, I've skimmed it and it's on my list to actually read.


Awesome list! I also did two presentations at RedDotRubyConf 2014 and RubyConf 2014 on Elixir:

Rubyists! Have a sip of Elixir – http://www.confreaks.com/videos/5078-RubyConf2014-rubyists-h...

Ruby + Elixir – Polyglot FTW! – http://www.confreaks.com/videos/3845-rdrc2014-ruby-elixir-po...

Also, I'm writing a book on Elixir – http://www.exotpbook.com

Finally, I've done a few posts of Elixir – http://benjamintan.io/blog/tags/elixir/


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.


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...


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

[1] http://phoenixframework.org


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!


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.


Dave Thomas' Programming Elixir should be the first :)


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-...




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: