Go channels are bad
I&#x27;ve always really, really liked Ada&#x27;s rendezvous-based concurrency.<p>There&#x27;s more to it than I can really describe here, but in effect it allows you to treat a thread as an object with methods; calling a method on the object sends a message to the thread. The thread&#x27;s main code can, at any point, block and wait for a message, or combination of messages.<p>The handling code looks like this:<p><pre><code>    ...some code...
    accept DoSomething(value: in out integer) do
      ...some code here...
    end
    ...some more code...
</code></pre>
That causes the thread to block and wait for the message. When the message is sent, the caller blocks, the receiver runs the handler, then the caller resumes.<p>The beauty here is that inside the message handler, you know that the caller is blocked... which means it&#x27;s safe to pass parameters by pointer[<i>]. Everywhere the parameter&#x27;s in scope, the parameter is safe to use. The type system won&#x27;t let the thread store the pointer anywhere without copying the contents first, so you get zero-copy messaging </i>and* it&#x27;s failsafe.<p>You can also do really cool stuff with timeouts, guards, automatic thread termination, etc. Here&#x27;s a simple multithreaded queue (syntax and logic not guaranteed, it&#x27;s been a while):<p><pre><code>    loop
      select
        when usage &lt; capacity =&gt;
          accept Push(value: in integer) do
            data[usage] := value;
            usage := usage + 1;
          end;
      or
        when usage &gt; 0 =&gt;
          accept Pop(value: out integer) do
            usage := usage - 1;
            value := data[usage];
          end;
      or
        terminate;
      end select;
    end loop;
</code></pre>
Multithreaded! Blocks the client automatically if they pop while the queue&#x27;s empty or push while it&#x27;s full! Automatically terminates the thread when the last connection goes away and the thread leaves scope! Thread safe! Readable!<p>I&#x27;d love to be able to do this in a more mainstream language.<p>[*] This is a simplification. Ada&#x27;s pointers are not like other language&#x27;s pointers.