Erlang is great, and there is a lot of dev tooling available. Unfortunately these best practices are not easy to find for Erlang newbies like me. So I’ll start writing them down here and grow the list as I’m moving up the Dreyfus model
Get command history for `erl`, the Erlang shell
- Install rlwrap. On my Mac using Homebrew:
brew install rlwrap
- Add the alias
alias erl='rlwrap -a dummy erl'
in your Bash profile. On my Mac it’s located here:
~/.profile. Reload your profile like this:
bash$ source ~/.profile
Automatic reloading of re-compiled modules
- Grab Mochiweb’s
reload.erl
from here, compile it and put the beam file here:
~/bin/reloader.beam - Create or edit
~/.erlang
and add the line
code:load_abs("[YOUR_HOME_DIR_PLZ_REPLACE]/bin/reloader").
- From now on, when you have a module loaded in the Erlang shell and re-compile it outside your shell, the new version will be reloaded automatically
Some nice utility functions for your Erlang shell
dbgtc(File) -- use dbg:trace_client() to read data from File
dbgon(M) -- enable dbg tracer on all funs in module M
dbgon(M,Fun) -- enable dbg tracer for module M and function F
dbgon(M,File) -- enable dbg tracer for module M and log to File
dbgadd(M) -- enable call tracer for module M
dbgadd(M,F) -- enable call tracer for function M:F
dbgdel(M) -- disable call tracer for module M
dbgdel(M,F) -- disable call tracer for function M:F
dbgoff() -- disable dbg tracer (calls dbg:stop/0)
l() -- load all changed modules
la() -- load all modules
mm() -- list modified modules
These commands are added by:
- Compiling user_default.erl and move the beam file to
~/bin/user_default.beam
- Create or edit
~/.erlang
and add the line
code:load_abs("[YOUR_HOME_DIR_PLZ_REPLACE]/bin/user_default").
- Feel free to add your own shortcuts to your
user_default.erl
.
There are multiple versions of
floating around on the interwebs. So pick the one that feels right.
Practical Erlang testing techniques
Watch the Practical Erlang testing techniques presentation from Mr. Bob Ippolito for a quick rundown of useful testing libs.
Thanks to @andrzejsliwa for the tips! Please add your tips to the comments and I’ll update the post.