tag:blogger.com,1999:blog-8288194986820249216.post8977283361721632315..comments2024-03-22T05:09:17.789-07:00Comments on Abstract Heresies: You knew I'd say something, Part IIIJoe Marshallhttp://www.blogger.com/profile/03233353484280456977noreply@blogger.comBlogger20125tag:blogger.com,1999:blog-8288194986820249216.post-31599565763202034952009-07-23T06:48:14.821-07:002009-07-23T06:48:14.821-07:00See http://www.ccs.neu.edu/home/will/Research/Lisp...See http://www.ccs.neu.edu/home/will/Research/Lisp50/scheme33.pdf<br />for the historical perpective that led from actors to Scheme (and lexical closures and TCO)therac25https://www.blogger.com/profile/01030437886042722139noreply@blogger.comtag:blogger.com,1999:blog-8288194986820249216.post-4688387441799205982009-05-21T08:05:34.524-07:002009-05-21T08:05:34.524-07:00To implement the Actors model in Python is why the...To implement the Actors model in Python is why the Twisted framework was invented. It works great. I have no doubt that a language with Actors model baked right in, such as the E programming language (http://erights.org ) would be a bit smoother than Twisted, which is Actors "bolted on" to Python. On the other hand, I do have doubt that tail call optimization is either necessary or sufficient to make Python useful as an Actors-model language.Anonymoushttps://www.blogger.com/profile/17046522562803939443noreply@blogger.comtag:blogger.com,1999:blog-8288194986820249216.post-18537589429758739992009-05-04T10:48:00.000-07:002009-05-04T10:48:00.000-07:00@alex: no need to be insulting. Code is more preci...@alex: no need to be insulting. Code is more precise. We're technologists: precision is valuable for us.Paul Prescodhttps://www.blogger.com/profile/15412258048017521995noreply@blogger.comtag:blogger.com,1999:blog-8288194986820249216.post-33884888881984259322009-05-04T09:29:00.000-07:002009-05-04T09:29:00.000-07:00@JonathanAllen:
Can't understand words?@JonathanAllen:<br /><br />Can't understand words?alexhttps://www.blogger.com/profile/14600963853008210433noreply@blogger.comtag:blogger.com,1999:blog-8288194986820249216.post-67566801718229151172009-05-03T11:42:00.000-07:002009-05-03T11:42:00.000-07:00Paul, not quite. If you remove TCO you can't get a...Paul, not quite. If you remove TCO you can't get actor model with threading only (without a global dispatcher, which makes a system coupled and bloated).Vsevolod Dyomkinhttps://www.blogger.com/profile/07729454371491530027noreply@blogger.comtag:blogger.com,1999:blog-8288194986820249216.post-73677479456926967312009-05-03T11:28:00.000-07:002009-05-03T11:28:00.000-07:00Vsevlod: "You won't automatically get threading, b...Vsevlod: "You won't automatically get threading, because it's orthogonal to TCO, but with lightweight threading and TCO you'll get easy async delivery and 1-to-many messaging. For a good demonstration see Joe Armstrong "Programming Erlang" (chapter 8)."<br /><br />Let me paraphrase: <br /><br />Barista: "With $1.50 and a coupon, you'll get a cup of coffee"<br /><br />Me: "How much is coffee usually?"<br /><br />Barista: "$1.50"Paul Prescodhttps://www.blogger.com/profile/15412258048017521995noreply@blogger.comtag:blogger.com,1999:blog-8288194986820249216.post-80561027335294781652009-05-03T09:36:00.000-07:002009-05-03T09:36:00.000-07:00Yes Paul, there's a confusion, but, i think, it's ...Yes Paul, there's a confusion, but, i think, it's on your part. If you read carefully from the beginning, the series is not about Python, but about TCO benefits in general. :) You won't automatically get threading, because it's orthogonal to TCO, but with lightweight threading and TCO you'll get easy async delivery and 1-to-many messaging. For a good demonstration see Joe Armstrong "Programming Erlang" (chapter 8).Vsevolod Dyomkinhttps://www.blogger.com/profile/07729454371491530027noreply@blogger.comtag:blogger.com,1999:blog-8288194986820249216.post-77214253611537347992009-05-03T09:11:00.000-07:002009-05-03T09:11:00.000-07:00D'gou, allowing dunctions to return a list of reci...D'gou, allowing dunctions to return a list of recipients would add two lines of code. Python's list is very easy to use as a command queue. Instead of assigning the result of the function calls to a variable, you would enqueue them. Instead of calling the variable, you pop and then call.<br /><br />It isn't clear to me how TCO makes this easier. Every function has at most one "tail call" just as every list ha at most one tail. That's the definition of "tail".Paul Prescodhttps://www.blogger.com/profile/15412258048017521995noreply@blogger.comtag:blogger.com,1999:blog-8288194986820249216.post-87498515782628601572009-05-03T09:02:00.000-07:002009-05-03T09:02:00.000-07:00I think that there may be some confusion about the...I think that there may be some confusion about the things being compared here. The two things ARE:<br /><br />1. Python with TCO.<br /><br />2. Python without TCO.<br /><br />We are NOT comparing Python with Erlang or E or something like that. That's a totally different conversation.<br /><br />So the last two posters should demonstrate -- in python or scheme code -- how one automatically gets async delivery, threading or 1 to many messaging by adding TCO to a language that does not have it.Paul Prescodhttps://www.blogger.com/profile/15412258048017521995noreply@blogger.comtag:blogger.com,1999:blog-8288194986820249216.post-2065106518083129612009-05-03T06:51:00.000-07:002009-05-03T06:51:00.000-07:00Paul Prescod/Vsevold:
And what happens when one m...Paul Prescod/Vsevold:<br /><br />And what happens when one message/actor needs to "return" several other actions to be taken? <br /><br />One thing about bolt-on-messaging is that it breaks the 1-to-1 mapping.<br /><br />There is more to this than just state machines. What if I want to pass my continuation on to multiple "forward" recipients?D'gouhttps://www.blogger.com/profile/15910070734520335504noreply@blogger.comtag:blogger.com,1999:blog-8288194986820249216.post-32631916523540052772009-05-03T00:55:00.000-07:002009-05-03T00:55:00.000-07:00Paul Prescod said...
Someone on reddit says:
...Paul Prescod said...<br /> Someone on reddit says:<br /><br /> def actor(f,*x):<br /> try:<br /> while 1:f,x=f(*x)<br /> except StopIteration:pass<br /><br />This approach won't work in the asynchronous case, when each f should be executed in it's own thread. (And that's where the Actor model shines)Vsevolod Dyomkinhttps://www.blogger.com/profile/07729454371491530027noreply@blogger.comtag:blogger.com,1999:blog-8288194986820249216.post-19544084917252324572009-05-02T18:07:00.000-07:002009-05-02T18:07:00.000-07:00Oh, here is some code:
> One of the innovation...Oh, here is some code:<br /><br />> One of the innovations provided by the asynchronous pattern is that the caller decides whether a particular call should be asynchronous. It is not necessary for a called object to do additional programming for supporting asynchronous behavior by its clients; asynchronous delegates provide for this in the pattern. The common language runtime handles the difference between the caller and called object views. <br /><br />http://msdn.microsoft.com/en-us/library/aa719595(VS.71).aspx<br /><br />Oh dear, it seems to be written for a language that doesn't support TCO. <br /><br />Well better luck in part IV.Jonathan Allenhttps://www.blogger.com/profile/16213908463228592960noreply@blogger.comtag:blogger.com,1999:blog-8288194986820249216.post-61868705542682363042009-05-02T18:03:00.000-07:002009-05-02T18:03:00.000-07:00I see a lot of words, but no actual code to back i...I see a lot of words, but no actual code to back it up.Jonathan Allenhttps://www.blogger.com/profile/16213908463228592960noreply@blogger.comtag:blogger.com,1999:blog-8288194986820249216.post-58696883787755256492009-05-02T15:22:00.000-07:002009-05-02T15:22:00.000-07:00You say:
"Without tail recursion, you have to im...You say: <br /><br />"Without tail recursion, you have to implement message passing as a separate, ‘bolted on’, feature. You will have explicit message objects to allocate, initialize, enqueue, poll for, destructure, and deallocate."<br /><br />Someone on reddit says:<br /><br /> def actor(f,*x):<br /> try:<br /> while 1:f,x=f(*x)<br /> except StopIteration:pass<br /><br /><br />One of you is incorrect. Which one?Paul Prescodhttps://www.blogger.com/profile/15412258048017521995noreply@blogger.comtag:blogger.com,1999:blog-8288194986820249216.post-84173691150609046502009-05-02T13:05:00.000-07:002009-05-02T13:05:00.000-07:00I find this example more persuasive but I would li...I find this example more persuasive but I would like to see code for the Python with TCO versus with trampolines. One advantage with trampolines is that you cannot accidentally create a stack by misunderstanding the details of the optimization. Explicit TCO would be a better fit for Python, but only if the TCO code is much cleaner than the trampoline version.Paul Prescodhttps://www.blogger.com/profile/15412258048017521995noreply@blogger.comtag:blogger.com,1999:blog-8288194986820249216.post-50845475601648651172009-05-02T09:26:00.000-07:002009-05-02T09:26:00.000-07:00That's what I was thinking, Vsevolod.That's what I was thinking, Vsevolod.Michael Terryhttps://www.blogger.com/profile/05651598767759195674noreply@blogger.comtag:blogger.com,1999:blog-8288194986820249216.post-65983222494020852842009-05-02T09:19:00.000-07:002009-05-02T09:19:00.000-07:00This is how I first ran into continuations. I was...This is how I first ran into continuations. I was 'bolting' on the Actor Model in C++. To me, its the epitome of Object Orientation, because <I>every</I> method must be a 'tell, don't ask' method. You can't ask (without sending a continuation message). You are also forced to be decoupled in time, because you can't depend on when another Actor might execute his message. This model really makes it easy to see when code 'wants' to be decoupled, and makes it easy to do so.SkepticalExtropianhttps://www.blogger.com/profile/06936361591856017420noreply@blogger.comtag:blogger.com,1999:blog-8288194986820249216.post-81682946908436763312009-05-01T21:25:00.000-07:002009-05-01T21:25:00.000-07:00I'd like to add, that Erlang is a good practical e...I'd like to add, that Erlang is a good practical example of this. Essentially tail-recursion is what empowers it to completely decouple different parts of the system and make them as lightweight, as possible.Vsevolod Dyomkinhttps://www.blogger.com/profile/07729454371491530027noreply@blogger.comtag:blogger.com,1999:blog-8288194986820249216.post-66923295011111317922009-05-01T17:48:00.000-07:002009-05-01T17:48:00.000-07:00Fantastic. You gave me a much better understandin...Fantastic. You gave me a much better understanding of the motivation behind tail calls beyond "simply" to save stack space. Thank you.David Vandersonhttps://www.blogger.com/profile/00334549959328743800noreply@blogger.comtag:blogger.com,1999:blog-8288194986820249216.post-26632577212718123512009-05-01T15:38:00.000-07:002009-05-01T15:38:00.000-07:00I posted in part II, complaining that you need to ...I posted in part II, complaining that you need to show something that isn't better written another way. (I still disagree with your later reply, because it isn't fair to say you need to globally rewrite code you specifically chose for the fact nobody would write it that way; it would have been iterators from day one.)<br /><br />Honor compels me to say that this strikes me as a <I>much</I> better argument. You can of course hack something into current Python, but it'll be dirty and weird, as you say, and this opens an entire paradigm up that Python has no good story for right now. This is the best argument I've heard on this topic yet.<br /><br />(BTW, to anyone who might reply, I've seen a couple of different libraries, some based on generators and some not (Candygram, for instance), and none of them are as clean as a tail-call based system could be.)Unknownhttps://www.blogger.com/profile/03842014488803010180noreply@blogger.com