Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Are you using multiple threads or just a single one? Not sure why your application would "jerk" because something takes long time? If it's in a separate thread, it being async or not shouldn't matter, or if it's doing CPU intensive work or just sleeping.


If I’m using threads for each of my tasks, then why do I need async at all? I find mixing async and threads is messy, because it’s hard to take a lock in async code, as that blocks other async code from running. I’m sure this can be done well, but I failed when I tried.


It depends what framework/language you're using.

It's messy in something like Python, but mostly transparent in C#. In C# you effectively are using async/await to provide M-N threading ala. GoLang, it's just different syntax.

OP references the C# method Task.WhenAll so they might be assuming other languages are equally capable.


You can map N-async tasks onto M-threads. This is essentially what Rust does, and if you squint this is how Go works as well.

A go routine is not that different from an async task, except the runtime inserts all the await points for you.


I have seen a lot of interfaces that I would be fine describing as "jerking" due to async silliness. Largely from odd reflows that result when the code completes in an order that is not "top down" in the function.

It can be convenient to have the code "just wait" for an async spot, but I do think there are some benefits to forcing the a bit more structure around it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: