#actor #isolation #heuristic
In practice, programmers reach for stateless actors in Swift to express "this should never run on the main thread".[#20250916actor][]
That isn't good reasoning, because:
- In practice ("runtime"), consider the overhead of using actors like network services[[202509160716]].
- In principle, it doesn't satisfy any of the 3 necessary conditions for actor usage[[202509160821]]
To detect potentially premature actor usage, see the list of code smells:[[202509160833]]
For the purpose of getting off the main actor isolation, there are better tools:
async letintroduces a suspension point for background work just as well, and is simpler[#20250916actor][]- with Swift 6.2 approachable concurrency,
@concurrentfunction[[202509160705]] opts-in to run on the concurrent thread pool[#20250916actor][]
[#20250916actor]: Matthew Massicotte: "When should you use an actor?", 2025-09-06, https://www.massicotte.org/actors