13

I really like the idea of jQuery's deferred/promise pattern or paradigm but sometimes I have trouble wrapping my aging brain around the finer points or specific implementation details.

In fact recently I've found that the deferred/promise pattern/paradigm seems to predate jQuery and is also in at least these other JavaScript libraries/frameworks:

I've probably missed some, included stuff that's really part of one of the others, and made other mistakes in that list... Please edit it to correct it or leave comments.

Was the deferred/promise concept invented by "Q"? Was it invented with some other JavaScript library or framework? Or does it predate JavaScript completely?

If the whole idea has traditionally been part of functional programming, where was it first done and where can I read about the concept generally rather than these various different JavaScript implementations?

Or is functional programming entirely beside the point? Is the concept more related to concurrent programming than to functional programming?

hippietrail
  • 15,848
  • 18
  • 99
  • 158

2 Answers2

9

According to Wikipedia: The term promise was proposed in 1976 by Daniel P. Friedman and David Wise, and Peter Hibbard called it eventual. A somewhat similar concept future was introduced in 1977 in a paper by Henry Baker and Carl Hewitt.

See: Futures and promises history on Wikipedia:

The future and/or promise constructs were first implemented in programming languages such as MultiLisp and Act 1. The use of logic variables for communication in concurrent logic programming languages was quite similar to futures. These started with Prolog with Freeze and IC Prolog, and became a true concurrency primitive with Relational Language, Concurrent Prolog, Guarded Horn Clauses (GHC), Parlog, Vulcan, Janus, Mozart/Oz, Flow Java, and Alice ML. The single-assignment I-var from dataflow programming languages, originating in Id and included in Reppy's Concurrent ML, is much like the concurrent logic variable.

The promise pipelining technique (using futures to overcome latency) was invented by Barbara Liskov and Liuba Shrira in 1988,[12] and independently by Mark S. Miller, Dean Tribble and Rob Jellinghaus in the context of Project Xanadu circa 1989.[13]

The term promise was coined by Liskov and Shrira, although they referred to the pipelining mechanism by the name call-stream, which is now rarely used. [...]

rsp
  • 107,747
  • 29
  • 201
  • 177
  • Great! I just found this independently after posting my question and have about eleven Wikipedia pages open to read. (-: – hippietrail Aug 07 '12 at 12:01
  • Hmm are "MultiList" and "Act 1" functional languages? I'm guessing this concept is more related to concurrency than to functional languages like I originally asked... – hippietrail Aug 08 '12 at 06:05
  • 1
    @hippietrail: it's [**MultiLisp**](http://en.wikipedia.org/wiki/MultiLisp) and yes, it's a functional programming language (a dialect of Lisp/Scheme). Act 1 was an experimental programming language for constructing [actor systems](http://en.wikipedia.org/wiki/Actor_model) - see [this paper](ftp://publications.ai.mit.edu/ai-publications/pdf/AIM-625.pdf) (pdf) from 1981 by Henry Lieberman. – rsp Aug 08 '12 at 12:53
  • Actually, the concept of promises _as we know_ them is more Liskov and Shrira and less Baker and Hewitt although their contribution is sound. – Benjamin Gruenbaum Mar 21 '14 at 02:10
6

I think in JavaScript deferred/promise concept first appeared in Dojo (inspired by Python's Twisted) then in jQuery.

The notable moment is work of CommonJS group which put a lot effort to "standarize" promises for JavaScript, see A, B and D proposals, on that basis Kris Kowal's Q (I guess currently most popular implementation) evolved.

Deferred (I'm the author) is later implementation, it was initially inspired by Q, its goal is to make promises feel natural in JavaScript, and also to make transition from Node.js callback style easy.

But yes as @rsp wrote, promises are much older concept than JavaScript itself :)

Mariusz Nowak
  • 32,050
  • 5
  • 35
  • 37
  • 1
    `Deferred` was in `MochiKit` before `Dojo`. Dojo added it after Mochikit, then `jQuery` added it after Dojo but jQuery's implementation behavior is slightly different. – Kernel James Nov 07 '12 at 02:03