8

I currently program in Futures, and I'm rather curious about actors. I'd like to hear from an experienced voice:

  • What are the advantages of actors over futures?
  • When should I use one instead of other?

As far as I've read, actors hold state and futures doesn't, is this the only difference? So if I have true immutability I shouldn't care about actors?

Please enlighten me :-)

Nathan Kleyn
  • 5,103
  • 3
  • 32
  • 49
Thiago
  • 2,238
  • 4
  • 29
  • 42
  • Java or Scala, but I guess this question would be rather language-agnostic; am I wrong? – Thiago Jul 13 '11 at 19:26
  • Well, only a very select number of languages have both, most only do one or the other, if at all, and the quality of the implementations varies wildly. I don't think there's a meaningful agnostic response to this. – skaffman Jul 13 '11 at 20:41
  • Let's say scala actors and java futures, can you provide me some information on the trade-offs? – Thiago Jul 13 '11 at 21:30
  • 2
    I found this post to be very mind clearing when it comes to the relationship between actors and futures (in Scala): http://www.chrisstucchio.com/blog/2013/actors_vs_futures.html – Erik Kaplun Mar 31 '14 at 00:20

1 Answers1

9

One important difference is that actors typically have internal state, and therefore theoretically, they are not composable; see this and this blog post for having some issues elaborated. However, in practice, they usually provide a sweet spot between the imperative and the purely functional approach. So if possible, it is recommended to stick to programming with only futures, but if the message-passing model fits your problem domain better, feel free to use actors.

thSoft
  • 21,755
  • 5
  • 88
  • 103