Thursday, July 10, 2008

Erlang and the Object Oriented Viewpoint

In a blog post some time ago, Robert's post pointed me to
Ralphs Johnson article talking about the object oriented properties of Erlang.

This really intrigues me as I am a big (in every sense) OO fan. Getting a little more serious about learning Erlang recently, I am thinking more about the points Ralph put forward. Traditional OO thinking states that a language is object oriented if it supports inheritance, encapsulation and polymorphism. However, I don't know where this originated, or from whom. Is it supposed to be taken literally or is there a wide berth for interpretation of this loose definition. Message passing is also a central tenet which is generally overlooked by many supposed OO languages (Java, C++) preferring other mechanisms to achieve similar results, which I feel somewhat miss the point.

So, you cannot write an Erlang process that 'derives' from another process - but does that even matter? As Robert once said to me, the power of the OO paradigm is delegation, not inheritance, and that is something most people don't get. I also feel that OO systems help me to understand how things work and hence translate from the real world to that of computers. Encapsulation and message passing are easy to achieve and I could argue that polymorphism is possible - what about inheritance?

I really like the way message selection works with pattern matching and the total reliance on recursion, matching and higher order functions to eliminate need for many control constructs such as conditions or iterations. This is central to the incredible alleged reliability for the language.

No comments: