Erlang source code guide

First of all, you might want to have a look to Joe Armstrong's thesis, introducing Erlang at a high level. It will be useful to get an idea of what was the idea behind the language. Then, you could focus on the Erlang Run Time System (erts). The erlang.erl module could be a good start. Then, I would focus on the applications who constitutes the so-called minimal release, kernel and stdlib. Within the stdlib, have a look on how behaviours are implemented. May I suggest the gen_server.erl module as a start?


The short answer is that there is no good guide. And the code is not very well documented.

I recommend finding someone in your neighbourhood that knows the code reasonably well, and buy them dinner in exchange for a little chat.

If you don't have the possibility to do that, then I recommend starting with the loader.

./erts/emulator/beam/beam_load.c

Some useful information can also be found by pretty printing the beam representation. I don't know whether there is any way to do so supplied by OTP, but the HiPE project has some cheats.

hipe:c(MODULE, [pp_beam]).

Should get you started.

(And I also recommend Joe's book.)


Pretty printer of beam can be done by 'erlc -S', which is equivalent with hipe:c(M, [pp_beam]) mentioned by Daniel.

I also use erts_debug:df(Module). to disassemble the loaded beam code, which are instructions actually been interpreted by the VM.

Sometimes I use a debugger. OTP delivers tools supporting gdb very well. See example usage at http://www.erlang.org/pipermail/erlang-questions/2008-September/037793.html


A Guide To The Erlang Source
http://www.trapexit.org/A_Guide_To_The_Erlang_Source