Hello! If I were be to explain asynchronous progra...
# getting-started
v
Hello! If I were be to explain asynchronous programming to a newbie, what would be some simple examples of situations when a client actively need to do something useful while waiting for server/database? I want real-life-ish situations to drive my point. Keeping UI event loop responsive, what else?
m
Maybe you could relate it to real-life directly? When you have to wait for something for a long time, you usually find something else to do in the mean time. You don't "block" by doing nothing at all while waiting.
m
Dashboards are common cases where asynch is extremely useful. Getting data from multiple places is faster if each one is done at same time, rather than sequentially.
c
Maybe contacting many servers on the web with different response speeds? It'd be faster to treat each request asynchronously to display the data. Example: You are filling a search box for a movie. Your app then sends request to many different APIs that can return data about the search. You 'd rather have results displaying live in case what you need is in the fastest answerings servers rather tan wait until everything completed.
v
Yes, contacting multiple servers is a common problem, but I would like to stick to only one server to simplify the example. Concurrent requests are really the next level.
c
Maybe some complex parsing on a user request? you could be using NLP to understand a user query, format it and send it to the server. If it takes a while, you would like to be able to parse the second request while the server if fetching the data, instead of waiting around doing nothing?
Just trying to throw ideas 😄 Sorry if they are not very clever ^^
v
@CamilleBC thanks! All ideas are appreciated 🙂
My current best idea is a bank client that is so slow that user can send 2 transactions while the first one is still running
But my idea is BS because console is buffered, so it does everything for you (
c
I don't think it matters that much. You are just trying to convey an idea, your real-life case scenario doesn't need to factually correct.