Future (programming)

From Wikipedia, the free encyclopedia

In computer science, a future (also known as a promise in the programming languages E and Alice) is a proxy for a result that is not yet known, usually because the computation of its value has not yet completed. Carl Hewitt has argued that the term future is to be preferred over promise on two grounds. First, promises can be about any time not just the future so the term promise is more vague than future. Second, a promise is just a linguistic expression whereas a future, as in the commodities market, is an actual claim and proxy for the goods.

The future construct was introduced in 1977 in a paper by Henry Baker and Carl Hewitt. The use of futures (promises) can dramatically reduce latency in distributed systems. E.g., it enables pipelining of messages as in the Actor model also called called promise pipelining [1] [2] in E and Alice.

Contents

[edit] Pipelining

In a conventional RPC an expression like

t3 := (x.a()).c(y.b())

which could be expanded to

t1 := x.a(); t2 := y.b(); t3 := t1.c(t2)

which means that t3 is not computed until after the values of t1 and t2 have been computed. Using futures, the above expression could be written

t3 := future (future x.a()).c(future y.b())

which could be expanded to

t1 := future x.a(); t2 := future y.b(); t3 := future t1.c(t2)

which means that t3 is computed immediately. However any attempt to obtain information from t3 may have to wait.

[edit] Implementations

The future construct was implemented in programming languages such as MultiLisp and Act1. The use of logic variables for communication in concurrent logic programming languages was quite similar. These started with "Prolog with Freeze" and "IC Prolog", and became a true concurrency primitive with Concurrent Prolog, Flat Concurrent Prolog, Parlog, Vulcan, Janus, Mozart/Oz, Flow Java, and Alice. The single assignment "I-var" from data flow languages, included in Reppy's "Concurrent ML", is much like the concurrent logic variable.

The pipelining technique (using futures to overcome latency) was first invented for the Actor model and then re-invented by Barbara Liskov in 1988 and in the Project Xanadu (circa 1989).

Languages supporting "future/promises/concurrent logic variables/I-vars" include:

Languages supporting promise pipelining include:

[edit] References

  • Henry Baker and Carl Hewitt The Incremental Garbage Collection of Processes Proceeding of the Symposium on Artificial Intelligence Programming Languages. SIGPLAN Notices 12, August 1977.
  • Henry Lieberman. Thinking About Lots of Things at Once without Getting Confused: Parallelism in Act 1 MIT AI memo 626. May 1981.
  • Henry Lieberman. A Preview of Act 1 MIT AI memo 625. June 1981.
  1. ^ Steve Dekorte (2005). Io, The Programming Language.

[edit] External links

In other languages