Hello ErlIDE: Installation to Hello World

IDEs Don't Kill Code Bases, People Kill Code Bases

I have just gotten over my mental block for trying ErlIDE. The biggest conflict for me was that my exploration of Erlang was in part a rebellion against Java and IDE-centric programming. ErlIDE is an excellent solution for Erlang development. I now use it in lieu of TextMate and Vim for my desktop automation projects such as erlang_hgsvn which I use daily to merge SVN branches. Vlad Dumitrescu has created an excellent product and I will do my best to contribute in whatever way I can to its success.

Many people have had difficulty installing and using ErlIDE. This step by step guide will show how to install ErlIDE and make effective use of it so that it helps rather than frustrates you.

(Linux only) Allow Large Number of Open Files

When using Erlang it is generally advised to significantly raise the limit on the number of open files per process. Add the following lines to /etc/security/limits.conf (right above # End of file):

* soft nofile 1048576
* hard nofile 1048576

Install Erlang/OTP (if you have not already)

  • Ubuntu Linux: run the following in Terminal:
    sudo apt-get update
    sudo apt-get install erlang
  • Windows: run the Windows Installer for Erlang R12B-4
  • Mac OS X: install MacPorts and then run the following in Terminal:
    sudo port selfupdate
    sudo port install erlang

Install Eclipse and ErlIDE

  1. Download Eclipse IDE for Java Developers
  2. Extract it where you want to run it from (there is no installer, just an archive)
  3. Launch Eclipse by double-clicking eclipse (Linux), eclipse.exe (Windows), or Eclipse (Mac) in the eclipse folder
  4. Select Help (menu) → Software Updates... (a dialog will appear)
  5. Click Add Site...(another dialog will appear)
  6. Enter http://erlide.sourceforge.net/update into the Location field, then click OK (dialog will close)
  7. Select the checkbox by http://erlide.sourceforge.net/update and click Install... (another dialog will appear)
  8. Select Next
  9. Select I accept ... radio button and click Finish (a progress dialog will appear)
  10. (wait for confirmation dialog) Select Yes (Eclipse will restart)

Add Primary Erlang Runtime

Without these steps things like syntax highlighting, code completion and other significant aspects of the ErlIDE UI will not work properly. The IDE will function basically, but it will not work as intended.

  1. Select Window (menu) → Preferences... (Windows/Linux) or Eclipse (menu) → Preferences... (Mac) (a dialog will appear)
  2. Expand Erlang and select Installed runtimes
  3. Click Add... (a dialog will appear) and Enter Erlang in the Runtime name field
  4. Click Browse... and select the root of your Erlang/OTP install (mine is /opt/local/lib/erlang), then click OK (dialog will close)
  5. Click OK (preferences dialog will close)

Create Hello World Project

  1. (wait for Eclipse to restart) Select Window (menu) → Close All Perspectives
  2. Select Window (menu) → Open Perspective → Other... (a dialog will appear)
  3. Select Erlang and click OK (dialog will close and Erlang Perspective will load)
  4. In the Erlang Navigator bring up the context menu (right-click/control-click) and select New Erlang Project (a dialog will appear)
  5. Enter hello_world in the Project Name field and click Finish (dialog will close and hello_world project will appear in Erlang Navigator view)

Start Erlang Node To Run Code

  1. Select hello_world project, bring up the context menu and select Run As → Run Configurations... (a dialog will appear)
  2. Enter hello_world in the Name field
  3. Double-click Erlang application (a new confguration will appear in the right-hand panel)
  4. In the Main tab under Projects click the checkbox beside hello_world
  5. In the Runtimes tab click the checkbox beside Start the Erlang node if not running already and enter hello_world in the Node name field
  6. Click Run (dialog will close and Console will appear with hello_world Erlang node)
  7. Leave the Console running for the next part

Write Hello World Live!

  1. On the hello_world project bring up the context menu (right-click/control-click) and select New Module (dialog will appear)
  2. Enter hello_world in Module name field
  3. To the left of the Apply button, enter say_hello in the first box and 0 in the second box and click Apply
  4. Click Finish (dialog will close and an editor for hello_world.erl will be opened)
  5. In the Console type hello_world:say_hello().
  6. Oops! It displays ok and shows no greeting! Let's fix that
  7. In the hello_world.erl editor replace ok in say_hello with io:format("Hello World!") and save (Ctrl-S/Command-S)
  8. In the Console type hello_world:say_hello().
  9. Great! It displays "Hello World!" for us! Let's get it to say something else
  10. In the hello_world.erl editor replace "Hello World!" in say_hello with "Hello ErlIDE!") and save (Ctrl-S/Command-S)
  11. In the Console type hello_world:say_hello().
  12. Nifty! It displays "Hello ErlIDE!" for us! We can change the code at runtime.

Embrace Convention

When I first tried ErlIDE over a year ago I found the predetermined project structure irritating. I now realize that this project structure is an accepted convention in the Erlang community. It reflects the way that most Erlang/OTP applications are distributed.

Go With The Flow

Buy into ErlIDE's default project structure even though it can now be overridden. It will make it easier for you to work with ErlIDE and easier for other Erlang developers to use what you have created. We have had trouble using Eclipse integration for J2EE at work because of the non-standard layout of our projects. Make the right choice upfront and adopt the conventional Erlang project structure. I wish Joe had mentioned this in his book...

Understated Power Overstated Roughness

ErlIDE is much less rough around the edges than I would expect for a 0.3 release. It is also understating its capabilities and the quality of the Eclipse integration. There is definitely work to be done, but it is an excellent foundation.

ErlIDE is the best tool I have used for Erlang development. It is the clear winner in ease of use for comparable functionality. For anyone already familiar with Eclipse ErlIDE is familiar and comfortable to use. I think ErlIDE will be instrumental in getting more Java developers to use Erlang. I will be actively contributing whatever fixes and features I can to ErlIDE.