forked from matthiasl/Erlang-FAQ
-
Notifications
You must be signed in to change notification settings - Fork 1
/
tools.xml
executable file
·273 lines (232 loc) · 9.23 KB
/
tools.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
<?xml version="1.0" encoding="iso-8859-1" ?>
<!DOCTYPE chapter SYSTEM "chapter.dtd">
<chapter>
<header>
<title>Erlang Tools</title>
<prepared>Matthias Lang</prepared>
<docno></docno>
<date>2007-09-12</date>
<rev>1.0</rev>
<file>tools.xml</file>
</header>
<section><title>Is there a pretty printer for Erlang?</title>
<p>
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.
</p></section>
<section><title>Where is the source for LEEX (the erlang lexer)?</title>
<p>
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="http://forum.trapexit.org/viewforum.php?f=20">
trapexit</url>.
</p></section>
<section><title>Is there a diagram tool for Erlang?</title>
<p>
Not really, most people use general-purpose diagram
tools like <url href="http://wwwhome.cs.utwente.nl/~tcm/index.html">
tcm</url> or xfig. TCM, in particular, is highly recommended.
Some people see
<url href="http://www.sdl-forum.org/">SDL</url>
as the natural
way of expressing telecomms problems in diagrams,
while Maurice Castro presented some interesting work on an
<url href="http://www.erlang.se/euc/99/Event.ps">
alternative notation</url> at the Erlang User Conference 1999.
</p><p>
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
href="http://erlang.org/pipermail/erlang-questions/1999-March/000165.html">
mailing list archive.</url>
</p><p>
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.
</p></section>
<section><title>What code testing tools and suites exist for and in Erlang/OTP?</title>
<p>
A test suite is especially useful for making sure that
"improvements" to the system haven't broken something.
The <url href="http://www.erlang.org/project/test_server/index.html">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.
</p><p>
The standard Erlang/OTP installation includes <em>cover</em>,
a test coverage tool.
</p><p>
<url href="http://www.quviq.com/">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.
</p><p>
<!--
Håkan Matsson released his <url
href="http://www.erlang.org/~hakan/mnesia_test_3.9.2.tgz">
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 -->
</p></section>
<section><title>Is there a way to benchmark an Erlang implementation?</title>
<p>
Bjorn's benchmarks are <url href="http://www.erlang.se/~bjorn/benchmarks2/">freely available</url>. The older ESTONE benchmark
has pretty much disappeared completely.
</p></section>
<section><title>Does anyone have a magic file for Erlang?</title>
<p>
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.
</p>
<codeinclude file="erlang_magic_file"/>
</section>
<section><title>Is there an Erlang IDE?</title>
<p>
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.
</p><p>
VI fans have several options. There is a
<url href="http://www.erlang.org/contrib/nedit_mode-0.9.tgz">
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="http://zanazan.am/vim/">download</url>.
</p><p>
There is an
<url href="http://sourceforge.net/projects/erlide/">Eclipse
plugin for Erlang</url>.
</p><p>
Some Windows developers use Ultraedit. Danie Schutte contributed
a <url href="http://www.erlang.org/download/contrib/ultraedit_erlang.zip">wordfile</url> which provides syntax highlighting.
</p><p>
There is an Erlang editor for NetBeans :
<url href="http://sourceforge.net/projects/erlybird">ErlyBird</url>
</p>
<p>
There is a
<url href="http://mac.softpedia.com/get/Developer-Tools/ErlangBBLM.shtml">BBEdit module</url>
</p>
<p>
There is a
<url href="http://oneless.blogspot.com/2007/04/howto-erlang-textmate-bundle.html">Textmate bundle</url>
</p>
<p>
There is a defunct X IDE for unix systems called "xerl". It
isn't worth using.
</p>
</section>
<section><title>Are there Erlang Coding Guidelines?</title>
<p>
Yes. They can be found <url
href="http://www.erlang.se/doc/programming_rules.shtml">
here</url>
</p></section>
<section><title>What refactoring tools are there for Erlang</title>
<p>
There are several third-party tools which help with
code refactoring. They can also be used for a range of
other purposes.
</p><p>
<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="http://www.erlang.org/user.html">user contributions
page</url>
</p><p>
<em>Distel/EMACS</em> is an EMACS monstrosity
with support for refactoring and interactive debugging.
The <url href="http://fresh.homeunix.net/~luke/distel/">
homepage</url> has more information.
</p></section>
<section><title>What static code analysis tools are there?</title>
<p>
There are several tools which detect various classes of
likely programming errors in Erlang code.
</p><p>
<url href="http://www.erlang.org/doc/man/xref.html">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.
</p><p>
The <url href="http://erlang.org/doc/apps/compiler/">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.
</p><p>
The <url href="http://www.it.uu.se/research/group/hipe/dialyzer/">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.
</p></section>
<section>
<marker id="decompiling"/>
<title>Is there a "reverse compiler" for BEAM files?</title>
<p>
Or: I've lost/deleted/whatever the .erl files for my project,
can I somehow recreate it from the .beam files?
</p><p>
<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.
</p><p>
Here is a simple module:
</p>
<code>
-module(hw).
-export([go/0]).
go() when true ->
"this is my function".
</code>
<p>
and the corresponding abstract code:
</p>
<pre>
3> {ok, {hw, [{abstract_code, Abs}]}} = beam_lib:chunks("hw.beam", [abstract_code]), Abs.
{raw_abstract_v1,[{attribute,1,file,{"./hw.erl",1}},
{attribute,1,module,hw},
{attribute,2,export,[{go,0}]},
{function,4,
go,
0,
[{clause,4,
[],
[],
[{string,5,"this is my function"}]}]},
{eof,6}]}
</pre>
<p>
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="http://jungerl.sourceforge.net/">jungerl</url>
can be used to do most of the hard work.
</p><p>
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.
</p>
</section>
</chapter>