** Is there anything like Actors in JavaScript and its ecosystem (Node, CoffeeScript, Backbone etc) ? With the widespread use of AJAX it seems perfect for asynch message-passing.
2 Answers
If you are using Javascript in the browser, take a look at Web workers: https://developer.mozilla.org/en-US/docs/Web/Guide/Performance/Using_web_workers
From the page: Dedicated Web Workers provide a simple means for web content to run scripts in background threads
You communicate to the web workers using message passing.

- 5,598
- 3
- 26
- 31
Because JavaScript is traditionally single-threaded, it would be difficult to make Actors or a similar async message-passing technique without exposing some of the internals to the users of the library. If I understand correctly, Actors wait synchronously for messages, and it's just sending which is happening asynchronously. It's much more idiomatic in JavaScript to both read and write asynchronously and use callbacks to deal with the results of the communication.
Of course, there are ways around this, so this other question and the presentation linked in the top answer and this list of node.js modules for dealing with control flow are decent starting points for how you might go about implementing your own.