参与者相对于期货的优势 [英] Advantages of actors over futures

查看:77
本文介绍了参与者相对于期货的优势的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在期货行业编程,对演员很好奇。我想听到一个有经验的声音:

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


  • 参与者比期货有什么优势?

  • 何时应该使用一个而不是另一个?

据我所知,参与者持有国家,而期货没有,这是唯一的区别吗?所以,如果我有真正的一成不变,我不应该在乎演员吗?

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?

请赐教:-)

推荐答案

一个重要的区别是参与者通常具有内部状态,因此从理论上讲它们是不可组合的;参见博客文章,其中阐述了一些问题。但是,实际上,它们通常在命令式方法和纯函数式方法之间提供了一个最佳结合点。因此,如果可能的话,建议仅使用期货编程,但是如果消息传递模型更适合您的问题领域,请随时使用参与者。

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.

这篇关于参与者相对于期货的优势的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆