Erlang Introduction (For the Ruby Guy) part 3
Sunday, August 17, 2008 at 02:04PM In Erlang you world revolves around processes. Not to be confused with OS processes. Here we are talking about highly light weight threads that can quickly be started and shut down. These are a lot faster and lighter that threads you may be used to from Ruby and you will use them quite a lot more than usually happens in Ruby. The best part is that this great power of Erlang is one of the simplest things to do. You just simply use the spawn(module, function, [parameters]) command to start a function and it starts it as a process. Really thats it. Lets see an example of this by starting the recurse command from part 2: P1 = spawn(demo,recurse,[[1,2,3]]).. Now this process started and ended within a second but imagine if this would have been some call to some webserver taking up to a few seconds. There the process would have done it's thing and the creating function continues doing it's thing without having to hang around for results.
Erlang Introduction (For the Ruby Guy) part 2
Sunday, August 10, 2008 at 08:29PM Here is the second installment of the introduction to Erlang. In the first part I introduced you to some of the basics in the Erlang language and now it is time to get to know more of the fun parts of the language. Like the first part this is not supposed to be a tutorial. I am simplifying things here and there is a lot more you should know if you want to do an actual program in erlang. I highly recommend that you check out Kevin's Erlang in Practice screencast, Joe Armstrong's Programming Erlang book or the excellent documentation on the erlang website.
Installing Erlang and a few libraries on Mac OS X
Wednesday, August 6, 2008 at 09:34PM Install Erlang
Lets start with installing the basic Erlang runtime.
cd /tmp
curl http://erlang.org/download/otp_src_R12B-3.tar.gz | tar zx
cd otp_src_R12B-3
./configure --enable-hipe --enable-darwin-universal
make
sudo make install
To verify that everything is installed enter the command erl. You should be greeted with the erlang shell. You can exit it by entering the shortcut "q()." without the quotes (remember the period).
Install a Few Must Have Libraries
Now lets install a few libraries that it is likely that you will want to try out. Lets start with entering the Erlang library location:
cd /usr/local/lib/erlang/lib
The first thing we want is the the Mochiweb library. Mochiweb is a simple but powerful http server.
sudo svn co http://mochiweb.googlecode.com/svn/trunk/ mochiweb
cd mochiweb
sudo make
cd ..
Next is the EUnit library. EUnit is a powerful unit testing library for Erlang.
sudo svn co http://svn.process-one.net/contribs/trunk/eunit eunit
cd eunit
sudo make
cd ..
If you have some legacy data you need to access in a MySQL database you will need the MySQL library. For new projects you propably are going to want to use Mnesia.
sudo svn co http://erlang-mysql-driver.googlecode.com/svn/trunk/ mysql
cd mysql
sudo mkdir ebin
sudo erlc -o ebin src/mysql.erl
sudo erlc -o ebin src/mysql_auth.erl
sudo erlc -o ebin src/mysql_conn.erl
sudo erlc -o ebin src/mysql_recv.erl
cd ..
Now everything should be set up and ready. Lets try it by entering the following commands in the erl shell:
mochiweb:module_info().
eunit:module_info().
mysql:module_info().
If any are not installed correctly you will receive single line with an exception error.
Erlang Introduction (For the Ruby Guy) part 1
Wednesday, August 6, 2008 at 07:41PM The purpose here is to write a basic beginners info for erlang. It's not in any way a tutorial but it's aim is to peak your interest in the language. This is aimed at Ruby programmers and tries to give a good overview of the basic differences and similarities. Both in programming and thinking. Erlang is a wonderful tool to learn and gives you the same enjoyable programming experience as most have with Ruby. And it's a great match to use them together in a product. Ruby for the front end to ease making a good user experience with trusty old Erlang in the background making sure everything is rock stable. The power of Erlang lies in it's ability to be scalable and stable. To put it bluntly. If your Erlang application is unstable and does not scale well then you have done something wrong.
Blogging again
Tuesday, August 5, 2008 at 03:39PM Well.. I have been away for a while but I decided to start blogging again. I miss annoying people on a regular basis. ;)
Major change is that I have moved to Squarespace for a blogging software. I used to use SimpleLog for my old blog and even though I liked it a lot for it's simplicity I prefer having a little more CMS services available since I plan to have a little bit more here than a simple blog.
I'm currently working on the first post that is kind of an introduction to Erlang for the Ruby programmer. Hopefully I will finish that tomorrow.

