[erlang-questions] Erlang modelling question

Olivier Boudeville <>
Fri Jun 22 10:24:31 CEST 2007


Well, thanks for the information, I did not know Scala. But I would
prefer sticking to Erlang for this project.

So : as nobody claimed that this POO->Erlang mapping is in this case a
mistake, I will give it a try and hopefully come up with an
implementation of a somewhat generic mechanism to recreate the
(multiple) inheritance described in various sources.

What puzzles me is that, in most multi-agent simulations, this need to
factorize common code should appear, but I did not find yet a pre-made
system on top of Erlang to do so.

Regards,

Olivier.

t ty a écrit :
> If you feel more familiar with OO and want the process capabilities of
> Erlang have you considered using Scala ( www.scala-lang.org) ? Scala
> shares syntax similarities with Java and runs over the JVM but has
> support for Actors, pattern matching, closures and even tail call
> optimization.
>
> t
>
> On 6/21/07, Olivier Boudeville <> wrote:
>> Hi,
>>
>> it is a kind of POO-related question (I guess lots of Erlang newcomers
>> have trouble making abstraction of their POO habits !). I read several
>> past threads on close subjects and Joe Armstrong book, but I could not
>> really find a satisfactory solution to my problem : I would like to
>> simulate a distributed system with plenty of actors interacting
>> concurrently. For this reason and many others, Erlang for sure should be
>> an interesting implementation language.
>>
>> My problem is that most objects share behaviours at different levels. At
>> least in a POO-way of modelling, the obvious solution would be to
>> represent them as active objects whose classes would be defined through
>> rather deep inheritance trees. This is not an artificial way of
>> considering the reality : they are indeed linked with "is-a"
>> associations. Not depending on the modelling approach X is really a
>> specialized Y which itself is a specialized Z, they share both data and
>> behaviours.
>>
>> In Erlang, at least in my case study, I believe these instances should
>> be processes, classes should be mapped to modules and events to
>> messages. As code duplication should be avoided, when I have a MyX
>> instance-process of class-module X that receives a message that actually
>> should be handled by code factorized in Z, I must find a way to climb up
>> the hierarchy towards Z, either specified manually (hardcoded) or thanks
>> to an automatized method look-up.
>>
>> Is such a mapping from a POO model to Erlang a non-sense ?
>>     - If yes, the modelling must be inadequate : how would the same
>> situation be modelled in an Erlang way ? (one could take creatures,
>> mammals, dogs for the Z, Y, X classes). My main concern is
>> developer-friendly code reuse
>>     - If no, I will end up implementing the multiple-inheritance case
>> mentioned in Joe's book, just suspecting I miss the point somewhere !
>>
>> Again, I am not worried by encapsulation, polymorphism, etc., they can
>> be secured easily I think, I just search for a clean way of factorizing
>> code between similar concepts. If in addition I did not have to recode
>> by hand all the message-switching logic that would convey a request
>> received instances of each of the many specialized classes to the
>> relevant superclass...
>>
>> Thanks in advance for any hint because I am really out of luck,
>>
>> Olivier.
>>
>>
>>
>>
>> _______________________________________________
>> erlang-questions mailing list
>> 
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>
>
>




More information about the erlang-questions mailing list