Hacker News new | ask | show | jobs
by NKCSS 3661 days ago
When reading, I thought: do I really need a framework for this? I've written simular batching before in c# but for the more elaborate cases, it makes sense and the de-duplication and only retrieving once to ensure all instances are the same looks nice; well done!
1 comments

Yeah, it's certainly preferable to use Task.WhenAll or Promise.all in simple cases.

For more complex cases, I like to make the analogy with asynchronous code. There's a few problems with complex async code that only uses a minimal abstraction, like callbacks:

* Writing asynchronous code is error-prone

* Asynchronous code obscures our intent

* Programmers are bad at reasoning about asynchronous code

So we developed abstractions like async/await and promises, allowing us to write async code in a sequential-looking way. Unfortunately, introducing concurrency into the mix breaks this sequential abstraction, which means certain familiar problems emerge:

* Writing concurrent code is error-prone

* Concurrent code obscures our intent

* Programmers are bad at reasoning about concurrent code

Haxl attempts to reclaim this sequential abstraction, allowing us to write code that looks sequential, but is actually concurrent "behind the scenes".