Saturday, October 07, 2006

Erlang = Awesome

Ok, so I'm no Erlang hacker yet. It's only been a month since I declared my intention to learn it. I have now made my first effort. It's a small program that watches for DNS requests and prints them on the screen.It has taken me about 4 hours of reading documentation and trying things out at the command line to get to this point. Granted, I didn't really know how to read or write erlang when I started so I think I'm moving along quite nicely.

As for what I intend to build... A few years ago I wrote an internet filtering daemon for a small company. It was a DNS proxy. Basically it would catch a request for name resolution (to find the real internet address of something like blogger.com for instance), pass that request to a real name server and check its records to see if the request should be granted. If it is supposed to block the site it would change the internet address returned when the DNS packet is sent back to the requesting client.

It took a bit more C code than I would have liked. The thing that has me writing this in erlang is that many of the things I tried to do with difficulty in C exist as easy to use language features in erlang. Binary parsing , concurrent processing, and error handling are the first to come to mind. One bad pointer reference and a C program crashes (Illegal Operation in windows speak) while erlang programs can be more easily written to catch such crashes and respawn whatever parts have died.

In server programming high availability is key. Erlang seems to be a tool that can help me design for it.

Shaun

No comments: