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 Semester Down

I’m sitting on my bed waiting for 6am to come around. I leave for home in the morning so I probably should get some shuteye, but I can’t sleep. Not sure if its because I’m excited to go home or if I’m just too used to going to bed at 3am. Either way, here I am, waiting for the inevitable.

It’s kind of strange to be one eighth of the way done with college already. The last few months seemed to have passed rather quickly. The first couple months were hard. I missed home; the classes were hard; and everyone seemed to know more than me. I figured out how to manage it all and cope with the stress after talking to a few people. There were moments where I wondered what I was doing here at CMU and if I had made a mistake in flying all the way across the country for school. I managed to convince myself that I wouldn’t be happy anywhere else knowing I could have gone to CMU. That worked for a while, but the longing for home was still there. These past few weeks have been different. CMU finally feels like home. Nothing has really changed, but I guess I’ve finally settled it.