Learning Erlang

I’m learning Standard ML in Principles of Programming (15-212). I didn’t think I would like the functional programming paradigm but it’s starting to grow on me. Having functions as first class values allows you to do some pretty neat things that would be a pain in other languages and some of the programming idioms are quite elegant. The only thing I haven’t enjoyed is Standard ML and it’s strong type system. The syntax leaves much to be desired as well, but this seems to be common among functional programming languages. As you can probably tell by the title of this post, I decided to learn Erlang in my free time.

The main reason I chose Erlang over say Haskell, Clojure, or some other functional language is my interest in concurrency and scalability. From what I’ve read people have had a lot of success with Erlang in situations that require concurrency and scalability so it seemed like a good way to satisfy my concurrency itch and my curiosity for functional programming. For the curious, Wikipedia has a short list of some projects using Erlang including some big names like Facebook and Amazon.

I’ve been reading Programming Erlang by Joe Armstrong. It’s a pretty solid book so far. It’s well written and easy to follow. There’s a lot of code snippets for you to try which fits my learning style. I wish there were some exercises at the end each section or chapter to get the reader thinking and writing some code instead of passively reading. My strategy for getting around this so far is to redo my 15-212 homework in Erlang, which has worked out pretty well.

I find my 15-212 homework easier to do in Erlang. It’s dynamically typed so I can add an integer and float together (what a concept!). I know you can do that in SML if you call the real function but it’s a pain and makes the code hard to read. Also, guards are awesome. One of the things that really annoyed me about pattern matching in SML is that while it was a very elegant, you still had to resort to if/else to check for things like inequalities and greater than or less than relationships. Guards in Erlang let you do this in natural way that feels like an extension to pattern matching.

Erlang is great so far. I’m starting to get into the concurrency features of Erlang so hopefully I’ll have more interesting things to post later.

One thought on “Learning Erlang

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>