Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You are missing a much bigger piece. Protocols.

I can implement any data structure, and if I define reduce for that data structure I get the entire Enum module for free, all tail call optimized.

It means I can mix and match data structures. I can do crazy things like zip a binary search tree and a lazy data stream together and then call take(5) to get the first 5 elements. And all that is required is reduce to be defined for all data structures. Protocols are a big deal.



Erlang/Elixir noob here. Are you saying that protocols are a useful thing to learn in a) Erlang, b) Elixir or c) both?


Protocols (and macros) are the real differences in Elixir that you don't have in Erlang.

The presence of protocols in Elixir enable many really cool features and designs that you wouldn't be able to do easily in Erlang.


Elixir has them built-in. They are basically an interface. A protocol says "this object implements this interface".




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

Search: