Lambda the Ultimate

inactiveTopic Maybe Erlang is OO after all?
started 8/25/2003; 2:10:52 AM - last post 8/27/2003; 5:19:53 AM
Ehud Lamm - Maybe Erlang is OO after all?  blueArrow
8/25/2003; 2:10:52 AM (reads: 1906, responses: 5)
Maybe Erlang is OO after all?
Joe Armstrong posted this message to the erlang-quesions mailing list:

Thus it might be argued that:

- Erlang *is* OO

and

- Erlang is *more* OO than any of the other so called OO languages

Put that in your pipe and smoke it!

On first glance it might seem that this is more appropriate for the fun department, but the thread that followed this initial message contains some interesting discussion about what OOP is all about.


Posted to OOP by Ehud Lamm on 8/25/03; 2:12:47 AM

Chris Rathman - Re: Maybe Erlang is OO after all?  blueArrow
8/25/2003; 11:23:31 AM (reads: 688, responses: 1)
The big 3 in OO are: (a) Encapsulation; (b) Inheritance; and (c) Polymorphism. As it turns out, inheritance is probably the least important aspect - good thing for Erlang - my attempts at doing Inheritance in the language got way too involved way too quick.

The encapsulation in Erlang is achieved via threads. The polymorphism is achieved via messaging. As was discussed in a thread on message vs method OOP, the OOP languages that use messages are much more dynamic in nature. So, I'd agree that messaging in Erlang is probably truer to the original OO designs within Smalltalk, than say the method based languages like Java or C++.

That said, I don't think that mimicking OO practices in Erlang is the best use of the facilities of the language. Threading and Messaging in the language is quite strong and that's the direction that it should be used.

Patrick Logan - Re: Maybe Erlang is OO after all?  blueArrow
8/25/2003; 12:50:44 PM (reads: 657, responses: 0)
I agree with Chris. Erlang's process model is good for "active objects", i.e. an object is a process and you send it messages asynchronously.

But Erlang's sequential programming model is it's most cumbersome, and does not really support OO in the sense of Smalltalk or Python.

I'd like to see a combination that worked better.

Ehud Lamm - Re: Maybe Erlang is OO after all?  blueArrow
8/26/2003; 6:07:28 AM (reads: 579, responses: 0)
The big 3 in OO are: (a) Encapsulation; (b) Inheritance; and (c) Polymorphism.

This is indeed the common wisdom. Personally, I am allergic to this list. Encapsulation exists in so-called object-based languages (e.g., Ada83, Modula-2); Polymorphism is a very generic term (pun intended): In OOP we are interested in subclass polymorphism and not parameteric pm.

When I want to highlight the properites most important, I usually concentrate on the following: deffered definitions (i.e, abstract methods etc.); subclass polymorphism, esp. as regards heterogenous datastructures; dynamic binding(late)/dispatching; factoring out common behaviours ("classwide programming" is what we all it in the Ada world).

Chris Rathman - Re: Maybe Erlang is OO after all?  blueArrow
8/26/2003; 6:32:49 AM (reads: 533, responses: 0)
It kind of depends whether you think Simula or Smalltalk defines the genre. Specifically, the polymorphism can be defined as SubType polymorphism - being a superset of subclass polymorphism. Subclassing is the means by which the static OOP languages achieve subtype polymorphism.

Subtyping in dynamic messaging languages like Smalltalk (or even Erlang) is not restricted solely to the subclassing mechanism. Specifically, the typing is a function of the ability to respond to a message of the desired type. For example, if we had a type of Drawable and the meaning of that type is that the object is capable of drawing itself on a screen, then any class that implements the draw method is considered of type Drawable - even it doesn't explicitly subclass the Drawable class.

Static OO languages do require an explicit definition of subtype via either the subclass or interface mechanism. In Smalltalk you don't really need multiple inheritance, but it's a requirement for languages like Eiffel. Was one of the shortcomings of Simula that it was limited to single inheritance - a problem that I don't know has ever been resolved satisfactorally.

Vesa Karvonen - Re: Maybe Erlang is OO after all?  blueArrow
8/27/2003; 5:19:53 AM (reads: 461, responses: 0)
Static OO languages do require an explicit definition of subtype via either the subclass or interface mechanism.

Do you mean static OO languages in general or just the current mainstream static OO languages?

Perhaps we are talking about different things, but as far as I can see, it is possible to design OO languages that do not require explicit annotation of subtype relations. See chapter 32[.2] of Types and Programming Languages. The subtype relations in the described object system follow directly from the various subtyping rules and do not need to be explicitly specified. Specifically, the definition of a ResetCounter does not explicitly say that it is a subtype of Counter. I think that a careful reader of that chapter can get a very good understanding of the difference between inheritance and subtyping (which is, IMO, often not clearly documented in OOA/D/P literature).