What is asynchronous programming?

  • software often waits for some I/O operation to complete (file operation, network call, database query etc.)
  • we can use this time for something productive instead to wait for data to be available or I/O operation to be completed
  • with asynchronous programming user can work in the meantime
  • not waiting for I/O operations synchronously enhances user experience

Of course this problem is much more complex. Modern software operates on much more different PC architecture than 20 years ago. Nowadays software must be asynchronous to appear more user friendly and to made better use of modern multi CPU architecture. Right now complex, professional software uses multiple processes, threads on multiple CPUs (CPU you buy is not really *single* CPU) or even utilize GPU for more complex computations (like i.e. video editing software). Before that we mostly had single threaded desktop applications that had ‘please wait’ or ‘loading’ pop ups. Right now this is song of the past really and to achieve better User Interfaces that allow to edit tag of your post without changing whole post. With mobile devices on the rise and sometimes lousy cellular network those kind of designs would not be sensible or sometimes impossible to implement. Did you ever happened to reenter some chunk of data into some software because you lost it? Maybe network was down? Or you hit back button by mistake? Right now it belongs to past mostly. All of those would be hard to do with synchronous operations. Right now people are bit spoiled and they tend to leave the page/application if it appears to be slow and not every company can sell ‘one-in-the-market-necessary-for-your-work-software’ that you will be forced to use. And this is why we have asynchronous operations and this is why we have asynchronous programming model that allows us to program such operations.

From the technical point of view we hit bottleneck with faster CPUs every new generation. CPUs started to be very hot and power hungry about 20-15 years ago. That kind of progress was no longer possible CPU manufacturers started to implement Hyper Threading and squeeze more cores into single chip. Still software were mostly single threaded but when home use CPUs started to gain traction (mostly because were cheaper) software needed to caught up. I remember working on mostly single threaded desktop application around 2011-12. Company was trying to use of multi threading to modernize it via Thread Pool usage. Eventually hardware and framework and libraries caught up on this new trend. With those possibilities and new tools it was finally possible to write software that use more than just one single CPU core. After mobile phones started to be popular it was even more important since their architecture and low power makes single, fast frequency CPUs impossible. It becomes necessity to write software with multi threading in mind. Eventually with web application gaining traction and browsers becomes sandboxes for those it was possible to write complex JS applications with asynchronous, multi threading operations.

With all of those possibilities and changed environment it was the only choice for IT world to make asynchronous application standard. And with this new standard way of coding changed and applications design changed, so now you can open your messaging app on your phone and and add photo to the message and send it at the same time. And then close it – while upload is still being done. If this fail you will be notified. If this will succeed – it was success due to asynchronous programming.

Further read:

https://www.bmc.com/blogs/asynchronous-programming/

https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/async/

https://learn.microsoft.com/en-us/dotnet/csharp/async

Leave a Reply

Your email address will not be published. Required fields are marked *

Solve : *
18 + 14 =