3 ms·
Promises, Deferreds, and Futures are all names for the same general idea, that which uses a monad to stand in for the result of operation that may or may not ha
by spartango 13y ago
Promises, Deferreds, and Futures are all names for the same general idea, that which uses a monad to stand in for the result of operation that may or may not have been completed.
There are implementations of this concept for many languages, from Java's futures to C# Tasks to Twisted Deferred to various JS Promise/Future implementations.
One thing that I find amusing in the callbacks+/-futures discussion is Google Guava's ListenableFutures (http://code.google.com/p/guava-libraries/wiki/ListenableFutureExplained http://code.google.com/p/guava-libraries/wiki/ListenableFutu...):
The JDK ships with Futures under java.util.concurrent, and they do what you would expect. What Guava adds is the ability to use Futures in the "pure" sense (get/check result) and with callbacks or delegates. The neat thing here is that you can use whichever paradigm is appropriate for the design of different modules of your system, and safely mix and match as needed.
Guava isn't the answer to all the questions in the Futures world, but I do think it brings a neat idea to the table here.