Friday, September 01, 2006

Next Language

After spending some time reading I think I've found the next language I want to learn. The last one I learned is Lisp. Lisp was my first functional programming language. I was able to learn about the concept of lambdas (aka. Lexical Closures) and lambda calculus.

My programming style will never be the same.

The new language I want to learn is erlang. The funny thing about erlang is that it's kind of like lisp. Not that it's a lisp dialect, but that it's a language that makes people wonder what I'm thinking.

I have a friend who really doesn't see why it is that I would choose Lisp for my current project. However, Lisp gives me great flexibility and freedom in how I write my code and how I think about my code's abstractions. I am able to write more reusable code faster in Lisp than I ever managed to in C#.

Now, why erlang? Seeing as it's more likely to get me more funny looks than dinner party invitations it just doesn't add up. Perhaps its history will help show why I want to learn it.

Erlang was developed by Ericsson for use in designing fault tolerant systems. Since its release in 1998 erlang has been used in telecom equipment built by multiple vendors. What's so great about it? It's a language that allows you to spend more time expressing your particular programming problem and less time handling the details of memory management. In C if you allocate something and forget to free it when you're done you have a memory leak and that memory space will not be useful again until the program is closed and restarted; this becomes a problem when you do it in a loop that runs 5,000 times. In Lisp and Erlang when you associate a value with a variable it adds a reference to the value. When all variables that reference a value go away it's reference count drops to 0 and the value is marked for garbage collection. All you had to do was use it while you wanted it and it goes away when you have no more need for it.

Erlang has other advantages. I hear it's good for concurrent programming. Something that is going to be getting bigger as we start seeing more cores going into processors.

Is it the end all of programming? Probably not.

All the same, I'd rather learn it. Learning a new language can introduce you to design patterns that will help you write better code in whatever language you use most.

Shaun

No comments: