Future is about asynchronous execution. It’s a high level abstraction over system threads (Ruby
Thread class). So when you need to speed up and parallelize some calculations then you need to use threads. But it’s some kind of low level things so it’s easier to use
Futures instead. The one of the benefits is that usually implementations of
Futures use thread pool so you can manage the level of concurrency and system resource consuming. So the problem which
Future solves is complexity of low-level threads concurrency model.
On the other hand
Promise is about architecture and composition. Not about concurrency. It’s a high level abstraction over callbacks and is a subtype of
Observer pattern. It allows to decouple component which produces some result
and component which consumes this result. Both producer and consumer may know nothing about each other. So the problem which
Promise solves is complexity and coupling that you get with callbacks approach.
concurrent-ruby. They provide both classic versions of
Future. But now they also provide a new API –
s at the end) which looks like just a combination of promises and futures with uniformed API. It implements (actually reuses)
Future libraries but provides some new interface over them. For instance future behaves similar to promise and allows to register callbacks and can be chained similar to promises.
CLICK HERE to find out more related problems solutions.