Promise
Noun · Development
Definitions
Promise is an object in asynchronous programming that represents the eventual completion (or failure) of an asynchronous operation and its resulting value. A promise exists in one of three states: pending (the operation is still in progress), fulfilled (the operation completed successfully with a result), and rejected (the operation failed with an error). Once a promise settles (becomes fulfilled or rejected), its state is immutable. Promises were introduced to solve the readability and error-handling problems of nested callbacks (callback hell). They allow chaining with .then() for success handlers and .catch() for error handlers, creating a flat, readable sequence of asynchronous steps. Promise.all() runs multiple promises in parallel and waits for all to complete, while Promise.race() resolves with the first promise to settle. Promises are native to JavaScript (ES2015) and form the foundation of the async/await syntax. The concept also appears in other languages: Futures in Java, Rust, and Dart; Deferred in Python's Twisted; and Tasks in C#. Understanding promises is essential for modern web development.
In plain English: An IOU from an asynchronous operation: 'I do not have the answer yet, but I promise to give it to you when it is ready, or tell you if something went wrong.'
Example: "fetch returns a Promise — you .then() it to get the response, or await it if you prefer readable code."
Etymology
- 1976
- Daniel Friedman and David Wise introduced the concept of 'futures' in a paper on parallel computing, describing placeholders for values not yet computed.
- 1988
- Barbara Liskov and Liuba Shrira formalized 'promises' in their paper on distributed computing, distinguishing them from futures as a mechanism for asynchronous method calls.
- 2009-2012
- JavaScript libraries like jQuery.Deferred, Q, and Bluebird popularized promises for managing asynchronous callbacks. The 'Promises/A+' specification standardized behavior.
- 2015
- ECMAScript 2015 (ES6) included native Promise support in JavaScript. Promises became the foundation for async/await syntax and modern asynchronous programming patterns.
Origin Story
The Pledge That Tamed Asynchronous JavaScript
A Promise in programming is an object representing the eventual completion or failure of an asynchronous operation. The concept was first described by Daniel P. Friedman and David Wise in a 1976 paper on 'futures,' and independently by Henry Baker and Carl Hewitt around the same time in the context of the Actor model. For decades, the idea remained mostly academic. The concept re-emerged in the JavaScript world around 2009 when Kris Kowal created the Q library, implementing Promises for Node.js developers drowning in nested callbacks. The jQuery library had its own Deferred objects, and various competing implementations proliferated. The chaos was resolved when the Promises/A+ specification was finalized in 2012, establishing a minimal, interoperable standard. JavaScript itself adopted Promises natively in ECMAScript 2015 (ES6), making them a built-in language feature. The .then() and .catch() chaining pattern replaced deeply nested callback pyramids, making asynchronous code dramatically more readable. Promises also became the foundation for async/await syntax, introduced in ES2017, which made asynchronous JavaScript look and behave like synchronous code.
Coined by: Daniel P. Friedman and David Wise (concept); Kris Kowal (JavaScript implementation)
Context: The theoretical concept dates to 1976; the JavaScript Promise pattern crystallized with the Promises/A+ specification in 2012.
Fun fact: The Promises/A+ specification is remarkably short, fitting on a single web page. Its simplicity was intentional: the authors believed that a minimal contract would encourage adoption, and it worked, with over 40 independent implementations conforming to the spec.