4 ms·
It seems like this problem would be elegantly solved by starting a thread, green thread or coroutine (depending on language) for each task and calling the API f
by tomlu 14y ago
It seems like this problem would be elegantly solved by starting a thread, green thread or coroutine (depending on language) for each task and calling the API functions synchronously from within that. I'm not sure what support JS has for these things.
- epochwolf 14y agoThe problem is javascript doesn't have support for this. That's why we see callbacks everywhere.
- georgemcbay 14y agoJS has no support for these things, but you're right, when using languages (like Go) that do support this concept, it is very easy to write elegant code which can block locally without actually blocking the entire application, which allows you to write code that is far cleaner and easier to reason about.
- dons 14y agoPrecisely. Threads allow you to separate concerns better - one thread per task, rather than trying to process all tasks. Simon Marlow captured this well: http://stackoverflow.com/a/3858684/83805 http://stackoverflow.com/a/3858684/83805 "the abstractions that threads provide are essential for making server code easier to get right, and more robust"