<blanu>
So I'm trying to learn pony and so far it's been pretty easy, but I'm stuck finding examples of using actors to actually do things. For instance, I would like to map a function over an array in parallel, where I use one actor per array item. Can anyone advise me or point me to some relevant code examples?
<SeanTAllen>
I'm not aware of any examples of doing that. I know some folks have done, but not sure if they ever posted.
<SeanTAllen>
In general that's not a particularly common usage of actors.
<SeanTAllen>
For what you are talking about I think you would want to use Promises and then join on all the results
<SeanTAllen>
And plenty more, if you clarify, perhaps I could help more.
<blanu>
Oh I see, well that is very interesting feedback, thank you.
<SeanTAllen>
Were you thinking of actors purely as a means of parallelization?
<blanu>
It seems from your examples that I've misunderstood the role of actors in pony as being about parallelism, when they are more used for concurrency.
<blanu>
Yes, the idea that you can have millions of actors implied to me that they were for parallelism.
<SeanTAllen>
well, they can be used for parallelism but, more than that
<SeanTAllen>
its about resource ownership so you can "share" resources in a safe fashion and "synchronize" on that resource via message passing
<SeanTAllen>
so for example, an actor per tcp connection and you send over the socket by sending messages to that actor
<SeanTAllen>
or if you application logged to a file, you would have an actor whose job it was to receive message that would in turn be logged into said file, all in a data race free, thread safe fashion
<SeanTAllen>
you could do the pure parallelization case but that's not the most common case
<blanu>
Sure, that makes sense. I understand the concurrency use case.
<blanu>
The the low overhead and automatic scheduling of pony actors makes pony seem attractive to me for data parallelization, so it's interesting to hear that this is not common practice.
<blanu>
Thank you for the actor examples, I will study them and figure out what it is that I'm not understanding.
<SeanTAllen>
Youre welcome. Stop by whenever you need help. There is often someone here, but if not ask your question and check the logs later for an answer. We try to answer all questions or at least, ask follow ups.
emdeanman_ has quit [Remote host closed the connection]
<blanu>
Interestingly, it divides the task into chunks and spawns worker actors, rather than using a parallel map function. I wondering if this is just because it's the paradigm that pony programmer think in, or if there is a performance reason.
gylzw has joined #ponylang
gylzw has quit [Remote host closed the connection]
<blanu>
So if I'm understanding correctly, to use actors you make several instances using a constructor function, and you get one actor per instance. Then you call "be" methods on the actors.
<blanu>
I guess I was expecting there to be some different syntax or types involved, but as far as I can tell using actors vs. classes is similar except for the declaration.
<slfritchie>
If you're describing the small-seeming difference between a `fun` and `be` annotation on a method-looking-thing, you're right.
<blanu>
Indeed!
<blanu>
Is there a resource somewhere for existing pony packages? I might write a package, if what I need doesn't already exist.
<slfritchie>
Sorry, blanu, there isn't a CPAN-style collection of package description, though that'd be really handy.
<slfritchie>
A runner-up is to ask GitHub for pony language repositories ... though not nearly as useful.
<slfritchie>
s/for/about/
acarrico has quit [Ping timeout: 265 seconds]
<SeanTAllen>
the pony-language topic on github can help you find some
<blanu>
I think I might see why a parallel map is not a good match for pony. Behaviors do not return values, so the actors need a place to write their results. So each actor needs a write-only reference to a different part of the array in which to place its result. It's unclear on how to do this in pony, or if it's possible, since isolation seems to be at the level of the whole data structure.
<blanu>
The mandelbrot example bypasses this issue by writing results directly to a file.
jemc has quit [Quit: WeeChat 1.9]
khan has quit [Ping timeout: 256 seconds]
khan has joined #ponylang
endformationage has quit [Ping timeout: 264 seconds]
endformationage has joined #ponylang
khan has quit [Quit: khan]
khan has joined #ponylang
khan has quit [Quit: khan]
khan has joined #ponylang
endformationage has quit [Quit: WeeChat 1.9.1]
khan has quit [Ping timeout: 264 seconds]
khan has joined #ponylang
khan has quit [Quit: khan]
gokr has joined #ponylang
gokr has quit [Ping timeout: 264 seconds]
gokr has joined #ponylang
<SeanTAllen>
blanu: to do that in pony, you would use something like a Promise, so you can get the result back from each of the "workers" then it would work out fine.
SenasOzys has quit [Ping timeout: 256 seconds]
SenasOzys has joined #ponylang
aturley has joined #ponylang
aturley has quit [Quit: aturley]
khan has joined #ponylang
acarrico has joined #ponylang
acarrico has quit [Ping timeout: 264 seconds]
vaninwagen has joined #ponylang
endformationage has joined #ponylang
khan has quit [Remote host closed the connection]
khan has joined #ponylang
khan has quit [Client Quit]
khan has joined #ponylang
aturley has joined #ponylang
aturley has quit [Quit: aturley]
khan has quit [Quit: khan]
khan has joined #ponylang
khan has quit [Client Quit]
khan has joined #ponylang
khan_ has joined #ponylang
khan has quit [Ping timeout: 240 seconds]
khan_ is now known as khan
gokr has quit [Ping timeout: 260 seconds]
endformationage has quit [Ping timeout: 240 seconds]
vaninwagen_ has joined #ponylang
vaninwagen_ has quit [Ping timeout: 256 seconds]
endformationage has joined #ponylang
matthias_wahl has joined #ponylang
khan has quit [Quit: khan]
khan has joined #ponylang
khan has quit [Client Quit]
khan has joined #ponylang
khan has quit [Quit: khan]
khan has joined #ponylang
khan has quit [Client Quit]
khan has joined #ponylang
SenasOzys has quit [Ping timeout: 276 seconds]
SenasOzys has joined #ponylang
matthias_wahl has quit [Ping timeout: 268 seconds]
khan has quit [Quit: khan]
khan has joined #ponylang
khan has quit [Client Quit]
khan has joined #ponylang
SenasOzys has quit [Read error: Connection reset by peer]