title: The actor model: Why is Erlang/OTP special? Could you use another language?
body: <p>I've been looking into learning Erlang/OTP, and as a result, have been reading (okay, skimming) about the actor model.</p>
  
  <p>From what I understand, the actor model is simply a set of functions (run within lightweight threads called "processes" in Erlang/OTP), which communicate with each other only via <em>message passing</em>.</p>
  
  <p>This seems fairly trivial to implement in C++, or any other language:</p>
  
  <pre><code>class BaseActor {
      std::queue&lt;BaseMessage*&gt; messages;
      CriticalSection messagecs;
      BaseMessage* Pop();
  public:
      void Push(BaseMessage* message)
      {
          auto scopedlock = messagecs.AquireScopedLock();
          messagecs.push(message);
      }
      virtual void ActorFn() = 0;
      virtual ~BaseActor() {} = 0;
  }
  </code></pre>
  
  <p>With each of your processes being an instance of a derived BaseActor. Actors communicate with each other only via message-passing. (namely, pushing). Actors register themselves with a central map on initialization which allows other actors to find them, and allows a central function to run through them.</p>
  
  <p>Now, I understand I'm missing, or rather, glossing over one important issue here, namely:
  lack of yielding means a single Actor can unfairly consume excessive time. But are cross-platform coroutines the primary thing that makes this hard in C++? (Windows for instance has fibers.)</p>
  
  <p>Is there anything else I'm missing, though, or is the model really this obvious?</p>