Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Tree: 7eab5f7945
Fetching contributors…

Cannot retrieve contributors at this time

executable file 273 lines (231 sloc) 9.2 KB
<?xml version="1.0" encoding="iso-8859-1" ?>
<!DOCTYPE chapter SYSTEM "chapter.dtd">
<title>Erlang Tools</title>
<prepared>Matthias Lang</prepared>
<section><title>Is there a pretty printer for Erlang?</title>
If you use the emacs mode (it comes with the open source
release, in <c>lib/emacs/erlang.el</c>),
you also get a pretty printer just by printing from emacs.
<section><title>Where is the source for LEEX (the erlang lexer)?</title>
Erlang's libraries provide an Erlang equivalent for
<c>YACC</c> called <c>YECC</c>, but there is no equivalent
for <c>LEX</c>. Robert Virding wrote one called <c>LEEX</c>,
which is available as a 'user contribution' on
<url href="">
<section><title>Is there a diagram tool for Erlang?</title>
Not really, most people use general-purpose diagram
tools like <url href="">
tcm</url> or xfig. TCM, in particular, is highly recommended.
Some people see
<url href="">SDL</url>
as the natural
way of expressing telecomms problems in diagrams,
while Maurice Castro presented some interesting work on an
<url href="">
alternative notation</url> at the Erlang User Conference 1999.
The first thing many people say is "what about Rose".
An Ericsson project took a look at using
Rose for Erlang projects, and concluded that it wasn't
worth using for a whole host of reasons (you can read
Ulf Wiger's post about an investigation into using
Rose as much more than just a diagram tool
in the <url
mailing list archive.</url>
The essential reason for Rose and such not looking
promising for use with Erlang is that the way you model
a problem in Erlang is rather different to the way you
decompose a problem with OO. While you're worrying about
processes, gen_servers, asynchronous messages and supervision
trees the tool wants to help you with singletons, exceptions,
threads and templates.
<section><title>What code testing tools and suites exist for and in Erlang/OTP?</title>
A test suite is especially useful for making sure that
"improvements" to the system haven't broken something.
The <url href="">test system</url> for Erlang. The test server can be used for testing
your project and it includes test suites for the Erlang emulator
and erlang stdlib.
The standard Erlang/OTP installation includes <em>cover</em>,
a test coverage tool.
<url href="">QuickCheck</url> is a
commercial tool for automatically generating
random test cases from a property written in Erlang
itself. When a failing test case is detected, this test case
is automatically reduced to a minimal failing case to simplify
fault analysis.
H&aring;kan Matsson released his <url
mnesia test suite</url>
which, by virtue of Mnesia being large, is a reasonable
test suite for the whole of Erlang.
REVISIT: this link was broken at last viewing -->
<section><title>Is there a way to benchmark an Erlang implementation?</title>
Bjorn's benchmarks are <url href="">freely available</url>. The older ESTONE benchmark
has pretty much disappeared completely.
<section><title>Does anyone have a magic file for Erlang?</title>
Magic files are used on unix systems with a tool called "file" to identify
files. Here's an addition to /etc/magic which allows "file" to identify
BEAM and JAM files.
<codeinclude file="erlang_magic_file"/>
<section><title>Is there an Erlang IDE?</title>
The "official" development environment for Erlang is Emacs,
and there's a special emacs mode for Erlang. This can be
found in <c>lib/emacs/erlang.el</c> under the
source tree.
VI fans have several options. There is a
<url href="">
colouring mode for nedit</url>. VIM has a fully-fledged Erlang
mode. A basic version is included in VIM as of version 5.6, a
much more complete version is available for
<url href="">download</url>.
There is an
<url href="">Eclipse
plugin for Erlang</url>.
Some Windows developers use Ultraedit. Danie Schutte contributed
a <url href="">wordfile</url> which provides syntax highlighting.
There is an Erlang editor for NetBeans :
<url href="">ErlyBird</url>
There is a
<url href="">BBEdit module</url>
There is a
<url href="">Textmate bundle</url>
There is a defunct X IDE for unix systems called "xerl". It
isn't worth using.
<section><title>Are there Erlang Coding Guidelines?</title>
Yes. They can be found <url
<section><title>What refactoring tools are there for Erlang</title>
There are several third-party tools which help with
code refactoring. They can also be used for a range of
other purposes.
<em>Syntax Tools</em>Richard Carlsson's syntax tools do
proper source->source transforms. Among other things they
can be used to modify old code so that it no longer uses
deprecated functions. It is available on the
<url href="">user contributions
<em>Distel/EMACS</em> is an EMACS monstrosity
with support for refactoring and interactive debugging.
The <url href="">
homepage</url> has more information.
<section><title>What static code analysis tools are there?</title>
There are several tools which detect various classes of
likely programming errors in Erlang code.
<url href="">XREF</url>
finds all undefined module calls in a set of modules, i.e.
it catches errors caused by mistyping module or function names,
among others.
The <url href="">Erlang Compiler</url> has several in-built options
which help detect problems. Most of these (e.g. reporting unused
variables, unused functions and some classes of dead code) are
enabled by default.
The <url href="">Dialyzer</url> is a dedicated static code analysis
tool which examines .beam object files. Among other things,
it does a global analysis and reports dead code and
some classes of type error. Highly recommended.
<marker id="decompiling"/>
<title>Is there a "reverse compiler" for BEAM files?</title>
Or: I've lost/deleted/whatever the .erl files for my project,
can I somehow recreate it from the .beam files?
<em>If</em> the code was compiled with
the <c>debug_info</c> flag, then the .beam file
contains a 'partially compiled' representation of the
source---basically the parse tree.
Here is a simple module:
go() when true ->
"this is my function".
and the corresponding abstract code:
3> {ok, {hw, [{abstract_code, Abs}]}} = beam_lib:chunks("hw.beam", [abstract_code]), Abs.
[{string,5,"this is my function"}]}]},
Writing a decompiler which can turn the above example back to source
is a fifteen minute job. Writing a decompiler which handles more
complex Erlang code is more time consuming, but not much harder.
The <c>syntax_tools</c> package from the
<url href="">jungerl</url>
can be used to do most of the hard work.
If the abstract code is <em>not</em> present in the
beam file, the problem gets much harder. It is possible to study
the remaining information and draw some conclusions about what
the original .erl file might have looked like, for instance which
functions were exported. But a lot of other important information,
such as variable names, is not present. In general, recreating the
source code from a beam file without abstract code is not practical.
Jump to Line
Something went wrong with that request. Please try again.