Actors are the new concurrency. They are everywhere. People make bold claims about actors, and while I do not agree with many of them, two in particular I regard as myths. Here they are:
- Actors are a shared nothing architecture
- Actors are easier to get right because of their shared nothing architecture
I know I'm alone with calling those myths, but here we go. Considering the first myth. If they share nothing, they could not collaborate on data. Sharing immutable messages does not help for getting data synced up again. So this can't be the way to collaborate. Indeed actors do share everything! Each actor can be considered a data structure with state and a write lock (
synchronized in Java).
The second myth. Actors are easier to get right because they share nothing and therefor do not have locks. As argued above they have locks, so this can't be the reason why they are easier to get right. I consider two characteristics of actors to be the reason for them being easier:
- They only can hold one lock at a time (when using synchronized send messages). This is a common approach to prevent deadlocks in locking architectures.
- They mostly send asynchronous messages. This prevents the common problems that arise from holding locks and blocking. In locking architectures when accessing locks in an asynchronous way (e.g. with futures and timeouts) there are also no deadlocks for the calling thread.
I would like to learn something from this. So please keep your flaming minimal and help me understand possibles errors in my thinking instead.
Update: If you do not believe me concerning the shared-nothing part, read the example from James