threads - use them as much as you can

Simon Bennett <>
Tue Nov 28 12:09:54 CET 2000


Samuel Tardieu wrote:
> 
> Another nice thing about processes in Erlang is how they map onto objects.
> 
> At the beginning of OO programming, programmers were told "Look, it is
> so nice, you do not call subprograms, you send messages to objects which
> will then react to those messages". This view was flawed, as the object
> was not reacting at all (it had no thread of control on its own), it just
> provided the caller with what to do (the method's code).
> 
> In Erlang, you really send messages to objects, you do not execute yourself
> the code that they supply. Erlang processes are real objects.

In UML (Unified Modeling Language) a distinction is made between 'active
objects' and ordinary objects.  Active objects have their own thread of
control and can be sent messages asynchronously.  

Something similar is also true in Rational Rose RealTime (formerly
ObjecTime Developer), which I believe is becoming the UML RealTime
standard.  It is possible to distinguish between classes (capsules in
Rose RT, actors in OTD), which will be instantiated into objects that
have their own thread and are modelled as state machines, and data
classes which are bog-standard O-O classes.

Capsules communicate via ports, and each port is associated with a
protocol defined in terms of a set of messages that can be exchanged
between ports that use that protocol.

It would be interesting to be able to model systems in Rose RT and then
generate Erlang from the model to provide a framework for the code,
mapping capsules to gen_fsms or gen_servers, using the protocols to
define the messages that are sent, and using the containment hierarchy
in Rose RT to map to a supervision hierarchy. 

Having written multi-threading/-processing code in C, Java and Erlang, I
know which model of concurrency I find easiest!

Simon
___________________________________________________________________

 Simon Bennett            E-mail:     
 Ericsson Intracom        http://www.ericsson.co.uk/UK/intracom
 1 Bede Island Road       Voice (UK)  0116 2542400
 Leicester                Voice (int) +44 116 2542400
 England                  Voice ECN:  832 707 ext 232
 LE2 7EU                  Fax:        +44 (0)116 2046111
___________________________________________________________________



More information about the erlang-questions mailing list