threads
Alan Kay
Alan.Kay at squeakland.org
Fri Feb 15 14:18:24 UTC 2002
Bijan, as you say, Erlang programming is very similar to Smalltalk-72
programming, since message receiving is implemented in much the same
way (and both are derived from a kind of coroutine structure on
something like a closure).
Cheers,
Alan
-------
At 11:02 PM -0500 2/14/02, Bijan Parsia wrote:
>On Fri, 15 Feb 2002, Richard A. O'Keefe wrote:
>[snip]
>> Threads in Erlang are different.
>
>Definitely!
>
>[snip]
>> My prejudice is that the assignment-free nature of Erlang is what makes
>> threading work so simply in it, but sometimes I wonder whether the _real_
>> answer isn't the way Joe Armstrong &co packaged up common working patterns
>> as "behaviours". If that's right, then that may be good news for Squeak:
>> perhaps suitable "behaviours" could be provided in Squeak.
>
>Interesting thought! My impression, though, is that
>"pre-behaviour"/from scratch thread programming is pretty easy
>to. Further, I rather suspect that the implementation of the behaviours
>relies fairly heavily on the functional bits of Erlang...that's certainly
>how those fellows represent it (they could be self-deceived of course).
>
>[snip]
>> In Erlang, the notion of "finish a certain step" is not terribly meaningful.
>> The only events that matter for process interaction are "send message" and
>> "receive message".
>[snip]
>
>And everything's extremely asynchronous. Threads can queue stuff up in
>their "message boxes" skip over some messages, come back latter,
>etc. Plus, writing a Erlang process "message loop" is very easy given that
>you you can pattern match the message. So you get code like:
>
>loop(val) ->
> receive %Sorta a "case" against the mailbox.
> increment ->
> loop(Val + 1)
> {From, value} ->
> From ! {self(), Val}, %The ! is "Send message to"
> loop(Val);
> stop -> %No call to loop; terminates
> true;
> Other -> %Capitalized atoms are variables
> loop(Val)
> end.
>
>It often feels a bit like Smalltalk-72 programming :)
>
>Actually, in spite of the asychronous nature of the message sends, the
>receiver side of things is *very* straightforward and perfectly
>smalltalky. Chapter 18 of the Erlang book sketches a fully ansych object
>system, moduling objects as processes. Verra nify.
>
>I rather suspect that with a bit of care in user code, one could do a bit
>of Erlang style stuff in Smalltalk.
>
>Cheers,
>Bijan Parsia.
--
More information about the Squeak-dev
mailing list
|