OO ? Pierre R 17th August, 2007 12:08 (UTC)
Are you sure you understand what OO means ?
OO ? Kirit Sælensminde 17th August, 2007 12:46 (UTC)
Pierre R said

Are you sure you understand what OO means ?

:-) * [*Other than that I'm not sure how to answer the question.]


To join in the discussion you should register or log in
OO ? Pierre R 18th August, 2007 01:32 (UTC)

Inheritance ?

Subtype polymorphism ?

PDA (Procedural Data Abstraction) style : encapsulation of stateful data together with operations (method) in a same entity called object to build data abstraction ?

OO ? Kirit Sælensminde 18th August, 2007 03:39 (UTC)
Pierre R said

Inheritance ?

Subtype polymorphism ?

Inheritance (if we consider it separate from subtypeing) is really just an implementation convenience for composition and forwarding. Take apart any Smalltalk inheritance and you'll find that you can always move the class in the hierarchy and add an instance of the superclass as an attribute. You also need to forward all of the old super-classes methods that you don't override (and all of it's parents' ones too). This is what makes inheritance so useful, but I've never seen it as a defining quality of any OO system (although finding an OO system that doesn't have it is very rare). In the case of Erlang, there is absolutely nothing stopping you from implementing inheritance as composition and I suspect that the flexibility of Erlang's switch-like receive statement would make it much easier to do than it would in Smalltalk, Java or C++.

Subtype polymorphism can be seen as one of two things (and I'm not sure which you mean):

  1. Liskoff substitution
  2. Inclusional polymorphism (a form of structural subtyping in type theory)

Erlang processes must allow this as it's impossible for any message based system not to. Any process implementation can be substituted for any other which responds properly to the same messages.

As for the stronger type checking offered by inclusional polymorphism, as far as I know Erlang doesn't support this — you cannot formally specify within Erlang which messages a process must respond to (at least as far as I know, but I don't Erlang well at all). That you can't do this in Erlang doesn't stop the process and messages part of the language from being OO any more than Smalltalk's inability to the do the same thing stops it from being an OO language.

PDA (Procedural Data Abstraction) style : encapsulation of stateful data together with operations (method) in a same entity called object to build data abstraction ?

Isn't this exactly what an Erlang process is? Change the word “object” to “process”.


To join in the discussion you should register or log in
OO ? Pierre R 18th August, 2007 16:33 (UTC)
Kirit Sælensminde said

Inheritance (if we consider it separate from subtypeing) is really just an implementation convenience for composition and forwarding. Take apart any Smalltalk

I do not meant inheritance without subtyping …

nheritance and you'll find that you can always move the class in the hierarchy and add an instance of the superclass as an attribute. You also need to forward all of the old super-classes methods that you don't override (and all of it's parents' ones too). This is what makes inheritance so useful, but I've never seen it as a defining quality of any OO system (although finding an OO system that doesn't have it is very rare). In the case of Erlang, there is absolutely nothing stopping you from implementing inheritance as composition and I suspect that the flexibility of Erlang's switch-like receive statement would make it much easier to do than it would in Smalltalk, Java or C++.

I still believe you miss the point. Of course you can do everything inheritance does using other techniques. OO is a paradigm not a catalog of features. A paradigm is a style of programming together with specific techniques, nothing else. When discussing functional languages with my colleages, I am amazed so many of them keep saying : “you can do the same in java”. That is not the point.

Take a look at http://en.wikipedia.org/wiki/Programming_paradigm

Subtype polymorphism can be seen as one of two things (and I'm not sure which you mean):

  1. Liskoff substitution
  2. Inclusional polymorphism (a form of structural subtyping in type theory)

subtype polymorphism also called inclusion polymorphism : http://en.wikipedia.org/wiki/Type_polymorphism#Subtyping_polymorphism

Erlang processes must allow this as it's impossible for any message based system not to. Any process implementation can be substituted for any other which responds properly to the same messages.

Liskoff substitution (and subtype polymorphism) is really tight to inheritance and subtypes. Take a look to the original paper written by Liskof.

As for the stronger type checking offered by inclusional polymorphism, as far as I know Erlang doesn't support this — you cannot formally specify within Erlang which messages a process must respond to (at least as far as I know, but I don't Erlang well at all). That you can't do this in Erlang doesn't stop the process and messages part of the language from being OO any more than Smalltalk's inability to the do the same thing stops it from being an OO language.

I would say it does. Again just a question of style … Smalltalk supports subtype polymorphism, doesn't it ? I am not sure what you mean by “inclusional”.

PDA (Procedural Data Abstraction) style : encapsulation of stateful data together with operations (method) in a same entity called object to build data abstraction ?

Isn't this exactly what an Erlang process is? Change the word “object” to “process”.

I don't think so if you think in term of style of programming (or paradigm or model).

Thanks for your reply. I believe Erlang is not an OO languages. You are right saying that Erlang is not just functional. According to WP (http://en.wikipedia.org/wiki/Multi-paradigm_programming_language) Erlang is a multi-paradigm language (functional, concurrent, distributed). There are more than two paradigms in the world of programming science. In the CTM book, Erlang is described as an example for the message-passing concurrency model.

That said. I am not by any mean an expert in Erlang. But I already like it ;-)

Edited — Removed an empty blockquote tag that was causing a render problem, KS

OO ? Kirit Sælensminde 19th August, 2007 03:09 (UTC)
Pierre R said
Kirit Sælensminde said

… you'll find that you can always move the class in the hierarchy and add an instance of the superclass as an attribute.

I still believe you miss the point. Of course you can do everything inheritance does using other techniques. OO is a paradigm not a catalog of features. A paradigm is a style of programming together with specific techniques, nothing else. When discussing functional languages with my colleages, I am amazed so many of them keep saying : “you can do the same in java”. That is not the point.

I take your point. I'm not talking about the same from a Turing equivalence standpoint, and I agree that is not really a useful basis to compare languages with.

That said, the equivalence of inheritance and composition isn't that sort of idea. The difference in implementation is fully encapsulated within the object, which makes this an implementation detail. It is only in the case of a language which uses inclusional polymorphism (subtyping polymorphism as you're calling it) that there is a difference.

Erlang processes must allow this as it's impossible for any message based system not to. Any process implementation can be substituted for any other which responds properly to the same messages.

Liskoff substitution (and subtype polymorphism) is really tight to inheritance and subtypes.

Sort of. Re-read the introduction to the paper (even just the first paragraph). They are not discussing subtype polymorphism. Note also that they are discussing “subtype” and not “subclass”. Confusing LSP with subtype polymorphism is a very common mistake (one the Wikipedia article makes too). Subtype polymorphism must satisfy LSP or it is not useful, but LSP describes a wider notion of what a subtype means.

As for the stronger type checking offered by inclusional polymorphism, as far as I know Erlang doesn't support this — you cannot formally specify within Erlang which messages a process must respond to (at least as far as I know, but I don't Erlang well at all). That you can't do this in Erlang doesn't stop the process and messages part of the language from being OO any more than Smalltalk's inability to the do the same thing stops it from being an OO language.

I would say it does. Again just a question of style … Smalltalk supports subtype polymorphism, doesn't it ? I am not sure what you mean by “inclusional”.

Smalltalk does not. You cannot specify that an argument to a method must be of a certain type.

Inclusional means that when you specify a type (for example as an argument) then that type includes all of its sub-classes — again note the difference between “class”“ and ”type" here. Read the part on polymorphism in The three pillars of Object Orientation.

PDA (Procedural Data Abstraction) style : encapsulation of stateful data together with operations (method) in a same entity called object to build data abstraction ?

Isn't this exactly what an Erlang process is? Change the word “object” to “process”.

I don't think so if you think in term of style of programming (or paradigm or model).

Thanks for your reply. I believe Erlang is not an OO languages. You are right saying that Erlang is not just functional. According to WP (http://en.wikipedia.org/wiki/Multi-paradigm_programming_language) Erlang is a multi-paradigm language (functional, concurrent, distributed). There are more than two paradigms in the world of programming science. In the CTM book, Erlang is described as an example for the message-passing concurrency model.

This I agree with as it is the point that I was trying to make. Re-read what I say and you'll see that the process aspect of Erlang is what I say is very closely related to OO programming.


To join in the discussion you should register or log in
OO ? Pierre R 21st August, 2007 15:13 (UTC)

Smalltalk does not. You cannot specify that an argument to a method must be of a certain type.

I have to say that I don't know much about Smalltalk. I am a bit puzzled here. My understanding is that subtype polymorphism (a synonym for inclusion polymorphism) does not require a statically typed language (just a rather strongly typed one). Even if the type is not defined in Smalltalk, if you expect the parameter to be of type 'shape' you will be able inside the method to call shape.draw(). The message draw() will be sent to a rectangle if at runtime the actual type of the parameter is a rectangle (rectangle extends shape) or to a circle if at runtime the actual type is a circle (circle extends shape).

Am I wrong ?

OO ? Pierre R 21st August, 2007 17:27 (UTC)
Pierre R said

Smalltalk does not. You cannot specify that an argument to a method must be of a certain type.

I have to say that I don't know much about Smalltalk. I am a bit puzzled here. My understanding is that subtype polymorphism (a synonym for inclusion polymorphism) does not require a statically typed language (just a rather strongly typed one). Even if the type is not defined in Smalltalk, if you expect the parameter to be of type 'shape' you will be able inside the method to call shape.draw(). The message draw() will be sent to a rectangle if at runtime the actual type of the parameter is a rectangle (rectangle extends shape) or to a circle if at runtime the actual type is a circle (circle extends shape).

Am I wrong ?

Yep I believe I am wrong here … Smalltalk polymorphism is not a form of subtype (or inclusion) polymorphim. And you do not need to be statically typed to be able to specify the type of the arguments to a method (CLOS).