I know you’re worried about blocking the main thread. But consider this: it’s way easier to fix a main-thread-blocker than it is to fix a weird, intermittent bug or crash due to threading.
I think it’s better still to use a language that prevents those classes of intermittent bugs and crashes, such as Rust. While language-level concurrency support, through features like controlled mutability and Rust’s Send and Sync traits, is certainly no panacea, particularly when interoperating with code in other languages, I think it does help. I was disappointed to realize the other day that Apple apparently didn’t tackle this problem in Swift. Yes, they more recently added things like async/await and actors, but AFAIK, nothing like Rust’s features for actually using multiple threads safely.
I want to have this printed up on little cards that I can hand out to people who insist on threaded async everything everywhere.
I think it’s better still to use a language that prevents those classes of intermittent bugs and crashes, such as Rust. While language-level concurrency support, through features like controlled mutability and Rust’s Send and Sync traits, is certainly no panacea, particularly when interoperating with code in other languages, I think it does help. I was disappointed to realize the other day that Apple apparently didn’t tackle this problem in Swift. Yes, they more recently added things like async/await and actors, but AFAIK, nothing like Rust’s features for actually using multiple threads safely.
Have you looked at the
Sendable
and stricter concurrency in Swift 5.8?