Quest for the perfect Erlang development environment

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

  1. Install rlwrap. On my Mac using Homebrew:
    brew install rlwrap
  2. 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

  1. Grab Mochiweb’s
    reload.erl

    from here, compile it and put the beam file here:

    ~/bin/reloader.beam
  2. Create or edit
    ~/.erlang

    and add the line

    code:load_abs("[YOUR_HOME_DIR_PLZ_REPLACE]/bin/reloader")

    .

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

** user extended commands **
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:

  1. Compiling user_default.erl and move the beam file to
    ~/bin/user_default.beam
  2. Create or edit
    ~/.erlang

    and add the line

    code:load_abs("[YOUR_HOME_DIR_PLZ_REPLACE]/bin/user_default")

    .

  3. Feel free to add your own shortcuts to your
    user_default.erl

    .

There are multiple versions of

user_default.erl

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Please copy the string svuAJ3 to the field below: