calum.org:~#

Erlang

Tags: erlang morse russian programming prime numbers

Added: 2009-11-16T19:29

Erlang

I wanted to write websites, so I learnt PHP. Nice and easy. Lots of example code. I then wanted to write stuff that ran on my Nokia N95 phone, so I learnt J[2]ME. Trickier. Debugging random network glitches/dropouts was a pain. I then went further down the Java path with Spring, JEE, JPA, JMS, DWR etc so that I could write huge Java websites and applications.

I wanted to give myself a challenge, so I've decided to learn 3 "languages". Russian. Erlang. Morse code.

I know some Russian.
I'm making (slow) headway with Morse code - http://lcwo.net/ is a great site for it though.

Erlang is a functional programming language. It doesn't have any shared memory between processes, and variables aren't.
Its key strengths are splitting a big problem over many cores on local or remote machines to solve that problem quicker.

However, after a relatively short amount of time, I've managed to write a dynamically resizing, distributed prime number generator.

It works like this. One node is the master server. It then learns of all the nodes on the Erlang network, and starts getting them all to check prime numbers, and report back. If new nodes come online, great. If nodes fall off, it doesn't matter.

The "is_prime" function wasn't written by me though - I just used that as it was a "hard" thing to do.

You can look at the files here: prime_server.erl, checker.erl, counter.erl, is_prime.erl. Please don't be unkind though - it's my first foray.
I'm know of several ways it could be improved, but I'm sure there are lots more.

posted by Calum on 2009-11-16T19:29 under

Add a comment

Your IP:
Please enter 4884125 here: