Archive for September, 2013

Seven Languages – Erlang

by Oliver on Friday, September 27th, 2013.

Well, well, well. One virtual “week” later, but two real world months later, I have finished the chapter on Erlang from Seven Languages in Seven Weeks. Based on the Git repository where I am recording my coding efforts through the book, I’ve been working at it for almost 11 months, which is slightly disappointing, but I have noticed during the chapter on Erlang a subtle shift in how my brain is functioning. Perhaps it is Erlang, perhaps it is the book as a whole, but I do notice that I am considering programming languages in a more balanced, perhaps philosophical way.

After five chapters it is starting to become evident that the languages were presented in a very well-crafted order. Ruby is undeniably the easiest and most familiar to the hordes of programmers out there largely experienced in imperative or even vaguely C-like syntax languages. As a side-note, since we are hosting several RailsGirls teams in the building, we recently started a “book club” going through this book chapter by chapter with these new software developers and some of my coworkers. It is proving very stimulating discussing languages, especially when we have different opinions about them and different experiences. I’m looking forward to hearing others share their delight in features I’ve hated, and vice versa.

So far we have only just finished Ruby and started on Io (which I covered what feels like an age ago). From there it gets progressively more diverse, more challenging by the chapter but each time you reach a new language your thinking has been altered in such a way that the challenges are within reach. This is perhaps a bit abstract so I’ll get back to talking about Erlang, and perhaps my point will become clear.

I find it terribly ironic that I almost bitterly finished the chapter on Prolog, thankful I’d never see that syntax or computing model again, and found it staring my in the face with Erlang. Erlang originally grew out of Prolog so a lot of the syntax is very similar, but somehow after conquering the chapter on Prolog previously, the problems framed around learning Erlang didn’t seem as hard.

That being said, familiarity with the basic syntax only got me so far. The concurrency model, OTP services and supervisors/monitors are a lot to wrap your head around and I found this chapter utterly mind-bending, but in a good way. I gave myself plenty of time (about two months in total) but made sure I finished every exercise, and I believe it was well worth the effort, as I feel I have a much better understanding of how it all works now. It’s not a language I would reach for instinctively, but at least I feel I could navigate my way around it (and we do in fact have some services written in Erlang at SoundCloud). It does intrigue me to know that robust services such as CouchDB and the latest Chef Server have been written successfully in this language.

What specifically did I find interesting about the language?

  • The use of Prolog-inspired pattern-matching, guard statements and the catch-all underscore all make for some very interesting ways of expressing data-driven decision-making or branching.
  • Function overloading by using different pattern matchers in the input parameters.
  • The actor- and message-based concurrency model.
  • The various ways of linking and monitoring processes to ensure they robustly resist entire system failure.
  • Atoms. I’m not sure what I make of them exactly – they feel a bit like symbols in Ruby, but evidently have a much wider namespace as you can register a process with an atom as its name, then refer to it in different places to where you registered it. But they are definitely convenient.
  • The fact that you can send messages asynchronously or synchronously, either by expecting a response only as a return message to another process, or by waiting for return value.
  • The slightly different syntax to io:format.
  • How you have to do something that feels like force-quitting the Erlang VM to exit (Ctrl-C then q).

Of course these are all observations based on very beginner-usage of Erlang. It has its differences which I find both challenging and interesting, not necessarily flaws. If you’re playing along at home, feel free to check out the code I managed to create while working through this chapter, and of course I’m always interested to read your opinions on the subject so feel free to leave a comment. Onward and upward to Clojure!

Tags: , ,

Friday, September 27th, 2013 Tech No Comments

Too much to do, too many first world problems…

by Oliver on Saturday, September 14th, 2013.

We’ve been in the country for almost four years and I still feel like I don’t have a very good grasp on the language. OK, there are indisputable differences between children and adults in language learning but that doesn’t mean you can’t learn a language in adult life. I just find that I procrastinate, and find it hard to prioritise the language learning into my daily routine.

Sometimes it is just easier to zone out and read 9gag, or Failblog. I’ve cut down my RSS subscriptions to the point where I get through them all in a few minutes every couple of days. There is a constant few technical papers or videos I have on the backlog to read or watch when I get a moment, and sometimes actually get to them. I’m progressing rather slowly with Seven Languages in Seven Weeks, a book about learning seven computer languages – and I’ve almost completed the 5th in the list but haven’t yet managed to prioritise even my first non-native spoken language – German.

At work we recently did a “Bio Hacking” course, which sounds a bit hand-wavy, but at its core was basically about getting your stress levels down and allowing your brain the rest periods necessary to operate it at full capacity. I also learned that procrastination (among other things I learned about my habits) is related to an over-developer aversion to failure. Probably learned during childhood through some catastrophic failure event, or alternatively so much success that you couldn’t bear the thought of not succeeding. I’m not sure I recall either of these happening so it’s a bit of a mystery to me.

Nevertheless I am procrastinating right now in writing this blog post instead of finishing the chapter on Erlang, or doing some German revision. It’s hard to think I’ll change my habits drastically after 34 years on this planet, but I also can’t stand the idea of becoming one of those people who has stayed in Germany for 10 years and just gave up learning the native language at some point. Or really anybody that just gave up trying to better themselves at any point in their lives because they saw it as futile.

Saturday, September 14th, 2013 Germany, Thoughts No Comments