Re: Any actor or coroutine implementations for Cocoa?
Re: Any actor or coroutine implementations for Cocoa?
- Subject: Re: Any actor or coroutine implementations for Cocoa?
- From: "Jim Roepcke" <email@hidden>
- Date: Tue, 29 Apr 2008 15:55:59 -0700
Hi Jens,
I've been researching the Actor model for the last couple of months. I
too thought Erlang used Actors, because that's what everyone says, but
after a lot of looking I cannot find a single reference where the
creators of Erlang say it uses the Actor model! They do say it
implements the Cooperating Sequential Processes (CSP) model, which is
quite close to the Actor model. I think this is largely academic,
perhaps the current (incorrect but defacto???) understanding of what
the Actor model is is just based on "Erlang-style concurrency".
More comparing CSP and Actors here: http://c2.com/cgi/wiki?ActorsModel
Also check out Scala Actors and Rubinius for other implementations of
the Actor model (which appears really to be implementing Erlang-style
concurrency. I wrote a producer-consumer program in Erlang, Io,
Rubinius and Scala for my research and compared those implementations.
Of those, Io uses coroutines, Erlang uses its "processes" (very
light/fast user level threads), Scala uses a hybrid model of threads
and events, and Rubinius (Ruby) uses Rubinius' green (user level)
threads.
Of the above, I found Io's syntactic approach be the most
"interesting" overall, but Erlang's is certainly the best overall
implementation by a long shot.
Using coroutines or some other kind of user-level threading approach
would certainly be important for high performance, but you could start
with a thread-based approach like Rubinius or Scala. When I looked at
Io's coroutine code, I was shocked because it looked incredibly
similar to the user-level thread library I wrote for my undergraduate
Concurrency class... wasn't sure if that meant my library was really
robust or Steve's coroutine code was really simple... regardless, Io's
coroutines had very good performance in my tests, as did mine. ;-)
I'm definitely interested in collaborating with you on this, ping me
at email@hidden at your convenience.
Jim
On Tue, Apr 29, 2008 at 10:04 AM, Jens Alfke <email@hidden> wrote:
> Anyone know if the "Actor" design pattern for concurrent programming has
> been implemented for Cocoa?
>
> In a nutshell, an Actor is an object that has its own [cooperative] thread
> and message queue. Actors interact by message-passing instead of shared
> state. The idea is to eliminate the need for standard synchronization
> primitives like semaphors and locks, and get rid of the race conditions and
> deadlocks that plague multi-threaded programs. There's a very good overview
> on the website for the new Ruby library Revactor:
> http://revactor.org/philosophy
> Actors are also built into languages like Erlang and Io.
>
> The only hard part about implementing Actors in Obj-C appears to be the
> underlying dependency on coroutines. Steve Dekorte [author of Io] has a
> newish coroutine implementation in C that works on OS X. When I discovered
> that last year, I then found an Objective-C wrapper by dPompa, but that
> relies on his HigherOrderMessaging library, which is incompatible with 10.5
> and hasn't yet been updated.
>
> If nothing's currently available, I'd gladly work together with one or more
> other motivated people to get coroutines and/or Actors working. Anyone else
> interested?
>
> —Jens
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden