I am fully aware that this topic may sound unrealistic at this point, and will probably never happen. But I still think it is worth mentioning.
I also know this naming did not come out of nowhere. Swift’s `actor` clearly comes from the broader actor model, and I am not questioning that history. I am questioning whether it was the clearest word for learning this feature in Swift.
My point is simple:
I think the word actor is not the clearest name for what this feature most importantly is in Swift. The main job of this construct is not that it "acts".
Its main job is that it isolates mutable state behind a protected boundary. That is why, from a learning point of view, a word like isolator feels more truthful to me.
For example:
actor BankAccount {
var balance: Int = 0
func deposit(_ amount: Int) {
balance += amount
}
}
What matters most here is not that BankAccount is “acting”.
What matters is that balance is isolated and protected.
If the syntax had been this:
isolator BankAccount {
var balance: Int = 0
func deposit(_ amount: Int) {
balance += amount
}
}
then I think the mental model would be more immediate.
The name actor can easily make people think of:
-
something active
-
something doing work
-
something like a worker, queue, or thread-like entity
But the important idea Swift wants us to learn is really:
-
this is an isolation boundary
-
it protects mutable state
-
it is not a task
-
it is not a thread
I know the cost of changing this would be enormous, so I am not pretending this is realistic.
My point is smaller:
I think actor was not the clearest naming choice for learning and teaching Swift Concurrency, and I am curious whether others felt the same or, if it is just me.