[erlang-questions] OTP Cheatsheet

zxq9 zxq9@REDACTED
Sat Sep 26 11:41:28 CEST 2015


On Saturday 26 September 2015 13:51:15 Vimal Kumar wrote:
> Hi all,
> 
> Erlang newbie here, learning from the book "Learn You Some Erlang For Great
> Good". Things were superfine until I reached OTP section. Currently
> scratching my head seeing all the behaviours and complexities involved, but
> taking everything slowly in.
> 
> I was looking for whether there is any quick cheatsheet available on OTP -
> somesort of quick reference that lists the different OTP behaviours, its
> required functions and return types. Googled, but didn't find any such.

It is hard to beat the Erlang docs for this. Unfortunately, it is hard to navigate the Erlang docs until you've spent some time bumbling around within them.

The place to start getting a once-over of all this stuff is in the "OTP Design Principles" part of the User's Guide. There is a once-over of what an OTP application looks like, a section on each of the main behaviors, and them some further discussion:
http://www.erlang.org/doc/design_principles/des_princ.html

The module docs themselves provide a cut-and-dried rundown of each component of the form you are asking for.

The gen_server, gen_fsm, gen_event and supervisor docs are under "Basic -> stdlib":

gen_server:
http://www.erlang.org/doc/man/gen_server.html

gen_fsm:
http://www.erlang.org/doc/man/gen_fsm.html

gen_event:
http://www.erlang.org/doc/man/gen_event.html

supervisor:
http://www.erlang.org/doc/man/supervisor.html


Other stuff worth knowing in the stdlib that you may want to read is the documentation for proc_lib, supervisor_bridge and sys.

proc_lib:
http://www.erlang.org/doc/man/proc_lib.html

supervisor_bridge:
http://www.erlang.org/doc/man/supervisor_bridge.html

sys:
http://www.erlang.org/doc/man/sys.html


All of the module docs can be found from the command line as well by typing `erl -man [module_name]`, so to read the gen_server docs you can do `erl -man gen_server`.

The ideas are more alien than complex, imo, and for me it was helpful to read different discussions that approached bits of OTP from several angles as I worked on projects I cared about. So skim the docs, work through LYSE, code a little, read the User's Guide (tons of interesting stuff in there), pick up some other books (even the ones that are currently over your head might give you some food for thought) and read/skim through those (knowing you'll come back later), read the mailing list archives (http://erlang.org/pipermail/erlang-questions/), etc.

Immersion via various sources seems to be the way most people finally get around to really understanding what is going on.

Federico Carrone put together a site that is pretty much just an aggregation of useful Erlang links that you might want to skim over when you have time. There is a lot of interesting stuff linked there: http://spawnedshelter.com/

-Craig



More information about the erlang-questions mailing list