Speeding up the Erlang editing, compiling, launching / debugging cycle

What is the fastest way to edit an Erlang application, compile code and view the result? It is preferable to jump into the Erlang shell in the last step.

My current newbie setup:

  • A script that compiles the application and launches the erl shell.
  • Then I print the application: start (foo).
  • When I fix a typo, I recompile the module with c ('module') and reload the application.

Is there a faster way? BTW. my editor of choice is Emacs.

+8
debugging erlang erl
source share
4 answers

Here is my setup:

  • During development, I keep the Erlang shell open in a separate terminal window.
  • I start compilation from the editor (using a keyboard shortcut) or simply by typing make in the source directory.
  • After compilation, I load all the changed modules at once by typing l() in the Erlang shell. Here you can find other useful macros: http://www.snookles.com/erlang/user_default.erl

It is rarely necessary to restart the entire Erlang application. Rebooting modified modules is a more common use case and it is usually enough to apply your changes.

As for launching the application: if your application depends on other applications, the application: start () will fail with an error until you run all the dependencies. Because of this, it is customary to write a helper function <your-app-name>:start() . Here is an example. Another useful function is <your-app-name>:stop() .

Using all of these methods, the workflow will look like this:

  • Launch the Erlang shell and save it; type <your-app-name>:start().
  • Make changes; compilation; type l() into the Erlang shell.
  • When changes require a restart of the application, enter <your-app-name>:stop(), <your-app-name>:start().
+12
source share

You can look at rebar as a build tool. make:all/0 and the whole make module could help. To explicitly reload a module from the shell, you can use l(Module) . Finally, you may also be interested in creating an Erlang release to wrap all your Erlang applications.

+2
source share

editing and compiling is done using the IDE (Eclispe with erlide) that I use.

I also created a script that launches vm my application and useful tools. The script is used only for dev time.

To reload modified sources and compiled bins I use reload from mochiweb. The loader monitors the bin file, and if there is a change, it loads the modules and runs the eunit tests, if you have one inside.

Example:

erl + A 5 + K true -name @ 127.0.0.1 -pa $ PWD / ebin $ PWD / test $ PWD / deps / * / ebin -boot start_sasl -s toolbar -s reloader -s

+2
source share

what you can also try is erlbuild. Erlbuild is a simple application that scans the src directory for modified source files and detects some files, than compiles and loads the modules again. After loading the modules, erlbuild runs the module tests.

You can find the project under: https://github.com/ulfa/erlbuild

~ Ulf

+1
source share

All Articles