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
- Download Eclipse IDE for Java Developers
- Extract it where you want to run it from (there is no installer, just an archive)
- Launch Eclipse by double-clicking
eclipse(Linux),eclipse.exe(Windows), orEclipse(Mac) in the eclipse folder - Select
Help (menu) → Software Updates...(a dialog will appear) - Click
Add Site...(another dialog will appear) - Enter
http://erlide.sourceforge.net/updateinto theLocationfield, then clickOK(dialog will close) - Select the checkbox by
http://erlide.sourceforge.net/updateand clickInstall...(another dialog will appear) - Select
Next - Select
I accept ...radio button and clickFinish(a progress dialog will appear) - (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.
- Select
Window (menu) → Preferences...(Windows/Linux) orEclipse (menu) → Preferences...(Mac) (a dialog will appear) - Expand
Erlangand selectInstalled runtimes - Click
Add...(a dialog will appear) and EnterErlangin theRuntime namefield - Click
Browse...and select the root of your Erlang/OTP install (mine is/opt/local/lib/erlang), then clickOK(dialog will close) - Click
OK(preferences dialog will close)
Create Hello World Project
- (wait for Eclipse to restart) Select
Window (menu) → Close All Perspectives - Select
Window (menu) → Open Perspective → Other...(a dialog will appear) - Select
Erlangand clickOK(dialog will close and Erlang Perspective will load) - In the Erlang Navigator bring up the context menu (right-click/control-click) and select
New Erlang Project(a dialog will appear) - Enter
hello_worldin theProject Namefield and clickFinish(dialog will close andhello_worldproject will appear in Erlang Navigator view)
Start Erlang Node To Run Code
- Select
hello_worldproject, bring up the context menu and selectRun As → Run Configurations...(a dialog will appear) - Enter
hello_worldin theNamefield - Double-click
Erlang application(a new confguration will appear in the right-hand panel) - In the
Maintab underProjectsclick the checkbox besidehello_world - In the
Runtimestab click the checkbox besideStart the Erlang node if not running alreadyand enterhello_worldin theNode namefield - Click
Run(dialog will close and Console will appear withhello_worldErlang node) - Leave the Console running for the next part
Write Hello World Live!
- On the
hello_worldproject bring up the context menu (right-click/control-click) and selectNew Module(dialog will appear) - Enter
hello_worldinModule namefield - To the left of the
Applybutton, entersay_helloin the first box and0in the second box and clickApply - Click
Finish(dialog will close and an editor forhello_world.erlwill be opened) - In the
Consoletypehello_world:say_hello(). - Oops! It displays
okand shows no greeting! Let's fix that - In the
hello_world.erleditor replaceokinsay_hellowithio:format("Hello World!")and save (Ctrl-S/Command-S) - In the
Consoletypehello_world:say_hello(). - Great! It displays "Hello World!" for us! Let's get it to say something else
- In the
hello_world.erleditor replace"Hello World!"insay_hellowith"Hello ErlIDE!")and save (Ctrl-S/Command-S) - In the
Consoletypehello_world:say_hello(). - 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.
14 comments:
Hi Alain,
nice checklist - I will give it a shot. I am a VI junkie and happy so far, but that might change when it comes to large project - I know exactly what you mean.
Also it was great to read your post on the 8.11 problem - I was trying to get what did Joe mean in his book when posing that problem. Having your input as a starting point I came to my own conclusion, and your take on that would be interesting.
Thanks,
Serge
Hi Serge,
Thank you for your kind words :)
Your solution to 8.11 is interesting. I had originally considered that approach. I like Ladislav Lenart's solution because there is no requirement of a registered process. For a tested solution for transactions I would look at things like mnesia and the global module. Kevin Smith's screencasts cover those topics well.
Regards,
Alain
Alain :)
of course you did. Seriously, as in OO, the dedicated object/process should do a particular job and handle concurrency. And the planned exception looks like a hack. But! This might be a reality in the complex project, so I accept the try/catch with the sigh...
Hi! Very nice article. I'm afraid I'm your worst nightmare: I'm new to Eclipse, new to ErlIDE and new to Erlang.
Running Mac OS X, 10.5.6, I have the Pragmatic Programming book on Erlang by my side and was going through the motions when I found your site and thought it a good idea to get some kind of IDE for Erlang.
Everything went fine up to "Start Erlang Node To Run Code", point 6. When I clicked on "Run" I go a series of messages saying:
{error_logger,{{2009,3,1},{15,54,44}},"** Connection attempt from disallowed node ~w ** ~n",['jerlide_250bafc@hulk']}
=ERROR REPORT==== 1-Mar-2009::15:54:44 ===
** Connection attempt from disallowed node jerlide_250bafc@hulk **
Eshell V5.6.4 (abort with ^G)
(hello_world@hulk.oriste.lan)1>
=ERROR REPORT==== 1-Mar-2009::15:54:45 ===
** Connection attempt from disallowed node jerlide_250bafc@hulk **
(hello_world@hulk.oriste.lan)1>
=ERROR REPORT==== 1-Mar-2009::15:54:45 ===
** Connection attempt from disallowed node jerlide_250bafc@hulk **
(hello_world@hulk.oriste.lan)1>
...and on and on and on...
In the above "hulk" is the name of my local machine, "oriste.lan" is my local domain.
I wondered if you could point me in the direction of where I need to look to remedy this: I have no idea if this is a problem with my network settings, with my Erlang configuration, with ErlIDE or Eclipse. All I want is to teach myself Erlang. Maybe you or your readership recognizes these error messages and can quickly help me out.
Thanks again for the article.
I found it! The error apparently was caused by the fact that I had my Eclipse installation in a folder whose name contained a space. After I deleted everything to start from scratch, I decided to NOT include a {space}-version number suffix in the folder name. I then re-did every step of your great tutorial and everything worked fine. Thanks again.
I received error messages similar to those posted by oriste. I already had eclipse installed in a folder without any whitespaces.
SOLUTION:
Change the node name so that it was different than my workstations hostname. DOH! Works great now.
Hi ,
I had a similar problem when I've set up new environment:
Connection attempt from disallowed node jerlide_ec81e30@wro00091b
I have tried different node names.
Finally, I have changed it to:
jerlide_ec81e30
and now works fine
Unfortunately, since you don't tell anyone WHICH of the packages to install (there are approximately 10 choices) this pages doesn't help too much.
Hi kevindtimm,
What operating system are you using?
This is a pretty old article. When it was written the commands worked to install directly. What specific problem are you seeing?
Hi Alain, I'm trying to get erlIDE up and running for my OSX Snow Leopard, and everything installs correctly, at least I think so.
macports, erlang, Erlide plugin for Eclipse.
The problem I have is with the Console within Eclipse. I type in commands - hello_world:say_hello(). and nothing happens. I don't get any response within my console. Am I doing it wrong? I even tried running native erlang commands, like help(). and q(). and nothing. Thanks for the how-to, I can't wait till I get this working :D
Nevermind, it turns out I had to restart Eclipse a couple times to get things working correctly. Now I get the console with all of erlang's glory!
@James Allen:
Thank you for reading the article. I am glad you found a solution :)
You bet. One thing that I should add, that when creating a new module, it doesn't automatically create the function, but rather only the exported function name, so erlide shows an error of an undefined function.
For people new to Erlang (such as myself) this was a bit confusing - perhaps a previous version of erlide automatically created the function when creating the module, I'm not sure. Thanks again!
Post a Comment