Challenges of asynchronous programming
Besides the many concepts explored in this chapter, probably the three most important challenges that a programmer faces when designing an asynchronous solution are:
- Setting expectations: not all programming constructs are applicable in all contexts, and they come with costs. CPU- and I/O-bounded problems may not always benefit from multi-threaded approaches.
- Testing/debugging asynchronous code: testing is a crucial aspect of modern programming, and threads and coroutines can be complicated to debug. Some techniques and common patterns have been developed, and they will be discussed in later sections.
- Thread safety: shared resources always impose access management challenges. Concurrent changes to stored data are an obvious challenge, so it’s important to keep in mind key concepts like ACID compliance when designing database solutions. Likewise, shared resources (volatile/non-volatile memory, callback execution) must guarantee execution safety in multi-thread environments.