> in actor systems, there's no intermediate queue-like channel that messages are sent to.
There are essentially two message passing models:
1. Multiple writer/single reader
2. Multiple writer/multiple reader
Where multiple/single means the number of actors/processes[/whatever] that can read or write to a queue.
Erlang and the Actor model are examples of the former. Multiple Actors can write to a given queue but only one Actor can read from it. From the writer's perspective, the queue is part of the reading Actor; the abstraction boundary encompasses the queue. Strictly speaking, the writer doesn't even know a queue exists: it just has a porthole it can push messages at.
Internally the Actor comprises 3 things: (1) the queue, (2) the read loop, and (3) the actions that get called in the read loop based on the received message. None of that is visible outside the Actor though. If you draw a diagram of an Actor system, it only shows Actors and the messages sent among them. Queues are hidden at that level.
Contrast that with the multiple reader/multiple writer scenario. This is the model used in service bus middleware like RabbitMQ. In this case the queues are external to the readers and writers. A system-level diagram would show the queues as first-class entities, alongside the components reading and writing to them.
As I have already said in another comment, I assume that the poster to which I have replied meant to say that the COBOL queues are many-to-many message queues, which are distinguished from many-to-one message queues exactly as you describe.
However the original comment was not clear, because the difference in behavior in comparison with actors is not given by the existence or non-existence of queues, which must always exist for message passing, but in the important differences both in implementation techniques and in their behavior, between many-to-one queues and many-to-many queues.
The distinction is between the use of queues shared between tasks and queues that are owned, and only readable by, each individual task (actor).
Another point about all this is that actors aren't just a concurrency mechanism that you can use or not as you see fit. They're a fundamental unit out of which entire applications are built. There are no function calls between actors, only message passing. This provides useful global concurrency safety properties that other systems can't match unless they essentially reimplement some similar model throughout the system.
What I'm getting at here is it's not just the properties of the individual queues that matter, but how the model is applied and enforced system-wide.
I'm guessing an OS built on the BEAM or a similar model would take a similar approach, where code executed by actors is actually run in schedulers, that can multiplex them and make the message passing efficient because they know what happens in the system.
The point is that it's not a shared message queue as in the COBOL case, or most enterprise queuing systems. An actor is a self-contained, isolated object with its own message handling and state, and it executes concurrently with all other actors.
As such, this is not quite correct:
> you must be aware that the input queue exists and it is not the same thing as the actor.
The term "actor" refers to the bundle of state, behavior (handler loop), and message queue.
You certainly must be aware of the existence of the queue though, but since you have to write a message handler loop for each actor, it would be difficult not to be.
I have written COBOL programs in the very distant past, but they were not concurrent programs, so I do not know how COBOL queues behave, so you are probably right.
But the input queues of actors must also be shared, i.e. they must be "many-to-one" message queues, because there are many other actors which can send messages to an actor.
There are 3 kinds of shared message queues: many-to-one, one-to-many and many-to-many. Whenever the message queues may be used by multiple threads, which is always on modern CPUs, the 3 kinds of shared message queues must use certain methods to allow concurrent accesses, which are different for the 3 kinds of queues.
Obviously, many-to-many queues have the most complex implementation, while many-to-one queues are simpler, but they must still use atomic instructions in the right way, to avoid data corruption. Only the one-to-one message queues do not need atomic instructions, but only store-release and load-acquire instructions.
Each actor owns its own queue, and is the only reader. This makes it a many-to-one queue.
> Whenever the message queues may be used by multiple threads, which is always on modern CPUs, the 3 kinds of shared message queues must use certain methods to allow concurrent accesses, which are different for the 3 kinds of queues.
This is exactly what actor systems like Erlang avoid. The Erlang VM handles preemptive multitasking for the actors it manages, without using OS threads. This eliminates a lot of concurrency issues, and is a big part of why Erlang systems have such a reputation for reliability.
You can think of it like a green thread system where each thread has its own private message queue.
> but they must still use atomic instructions in the right way, to avoid data corruption.
This is only an issue because the message queues you're talking about are implemented separately from the OS, so there are no guarantees about concurrency behavior. This is exactly what the actor model solves for.
In general, in programs it does not matter much where you put artificial borders of ownership between entities, but whether the access to a resource is shared or exclusive has a crucial impact on the required code.
If threads are not visible to the programmer who writes the code for an actor, there are 2 cases. The first is when threads really do not exist, in which case the VM is single-threaded and executed on a single core of a modern CPU, so the achievable performance is modest, but there is no need for handling concurrency.
The second case is when the VM is in fact multi-threaded, which, as you say, must be the case for Erlang, but it manages the scheduling of the threads itself, and the allocation of actors to threads, in a manner transparent for the programmer.
In this case the VM must include code for managing concurrent accesses from multiple hardware threads to the message queues, so they still are shared-access queues, even if their implementation is provided by the VM.
I mentioned that in my first comment. In actor systems, the idiomatic model is just to spawn a new actor for each job.
But if you want a multi-reader message queue, you can implement an actor that provides that, and there are standard implementations of this.
Actors are the primitive mechanism on which other concurrency mechanism can be built, without all the problems of traditional threads.