How would you explain actors to a non-programmer? [closed]

北城余情 提交于 2019-12-03 07:40:25

问题


Well, the title's pretty much it: if I sat a non-techie/my mum/twelve-year old boy/cocker spaniel in front of you and asked you to explain actors to them, where would you start? I ask because my master's project involves them to a pretty large degree, and every other day someone asks me to tell them what I'm doing. When I'm talking to other people on my course it's not so bad—usually the concept is foreign but understandable—but recently my flatmate, a chemist, asked me to explain it to her, and to say I struggled would be a pretty humongous understatement.

I'm looking for some sort of explanation that conveys the idea, rather than the technical underpinnings. It can be a metaphor, and it doesn't have to be precise—I just want to make them understand what I'm doing with them. Any ideas?


回答1:


  • There can be many actors. All actors act "at the same time". The concurrency is a key part of this model.

  • Actors cannot know what other Actors are thinking. The only way to move information is with a message. (no shared state)

  • Actors can receive messages, and act on them by:

    • doing computation with the data in them

    • sending messages to other actors

    • creating other actors.

    • ignoring/discarding the message.

This basically makes actors just like... People. People don't know what each other are thinking, they must send messages to convey information, they have the choice of ignoring incoming messages, considering them, or communicating with other people. Random bad things can happen to people. Lots of people all do things at the same time. To handle more load, add more people.

Regarding your masters project, I suggest finding out about the Erlang Web framework. The programming language Erlang is based on the Actor model, and is used to great effect in scalable systems including phone switches... and the Facebook messaging system.




回答2:


I'll try a simple metaphor:

Actors are people doing some work inside their houses. In front of each house, there is a mailbox. In order to communicate with each other and get work done, messages are sent between the actors.




回答3:


I am not sure that this will be good one, but I'll try:

Let's imagine a classic middle-east marketplace. There are buyers(suppose they are just walking tourists) and sellers. Buyers are walking through marketplace, and sellers cry out name's of theirs goods: Carpets!! Species!!! Horses!!! Сandies!!! Jewels!!! and so on... Some buyers are not interest in specific kind of goods and go to the next store, but some buyers become interested, and ask: "How much is it?", seller: "50$", buyer:"Can you give me a discount?", and so on...

Actors are buyers and sellers here. Sellers are sending messages with types of their goods. Buyer can skip a message, or can send message for asking price.




回答4:


Actor - is something we can also call subject. Actors are doing something with objects. Actor is calls so, because it's somebody who acts.




回答5:


I would say, "Actors are a simple way to tell computers to do more than one thing at the same time. They are different from other ways to tell computers to do more than one at the same time because they take fewer resources than some of the alternatives and because they are easier for programmers to use correctly than some of the other alternatives."



来源:https://stackoverflow.com/questions/2335337/how-would-you-explain-actors-to-a-non-programmer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!