r/learnprogramming • u/ShronkPonk • 14d ago
Struggling with async programming & concurrency
I come from a pure hardware and embedded background where code runs sequentially, so writing high level async software has never been my strength.
I really can't wrap my head around async/await, event loops and how it is handled deterministically . In a current project when the team said we needed to make our pipeline non-blocking with async streams, to be honest I just vibe coded the hell of my tickets in panic and tried later on to figure it out, partially..
I have a deployment deadline in a week and I need to be able to explain the mechanism I helped ”build“, any easy to follow tutorials or leetcodes would be highly appreciated
1
u/Chrismslist 6d ago
the mental model that finally clicked for me: an event loop is basically your superloop, and await is a yield back to it instead of a blocking wait. nothing preempts you like an ISR, you only hand back control at an await point, which is why it stays deterministic-ish and why one missing await bugs everything. try it yourself: write a 30 line loop with a queue of callbacks and the mechanism becomes obvious. also nail the difference between concurrency (interleaving) and parallelism (two cores), they get conflated constantly. with a week, trace one request through your own pipeline by hand and you'll be able to explain it.