Promises (CloudMonk.io)

Promises



Return to Futures, Asynchronous Programming, Asynchrony, Asynchronous Programming Fundamentals

* What programming languages support the promises. Answer in MediaWiki syntax with the URL of the official documentation for each language reference.

Promises are a programming construct used to handle asynchronous operations, allowing developers to write cleaner, more readable code that can handle operations which may not complete immediately. Several programming languages support promises, either natively or through libraries. Below is a list formatted in MediaWiki syntax, including the official documentation URLs for each language's promise or equivalent feature.

JavaScript


JavaScript is one of the most well-known languages to support promises natively. Promises in JavaScript are used extensively in web development for asynchronous operations like network requests.
* Official Documentation: [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise MDN Web Docs on Promises]

Python


Python supports asynchronous programming with its `asyncio` library, which includes features similar to promises, known as "Futures" and "Tasks".
* Official Documentation: [https://docs.python.org/3/library/asyncio-task.html Python asyncio documentation]

Swift


Swift supports asynchronous programming with "Promises & Futures" through third-party libraries, such as PromiseKit.
* Official Documentation: [https://github.com/mxcl/PromiseKit PromiseKit on GitHub]

Java


Java does not have a direct equivalent to JavaScript's Promise, but it has the `CompletableFuture` class, introduced in Java 8, which offers similar capabilities for asynchronous programming.
* Official Documentation: [https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html Java CompletableFuture documentation]

Scala


Scala has "Futures and Promises" as part of its standard library, offering a powerful way to work with asynchronous operations.
* Official Documentation: [https://docs.scala-lang.org/overviews/core/futures.html Scala Futures and Promises documentation]

C#


C# utilizes the Task Parallel Library (TPL) for asynchronous programming, with `Task` and `Task` being the central types. While not named "Promise", these Tasks serve a similar purpose.
* Official Documentation: [https://docs.microsoft.com/en-us/dotnet/standard/asynchronous-programming-patterns/task-based-asynchronous-pattern-tap Microsoft Docs on TAP]

Ruby


Ruby supports futures and promises through external libraries, such as Concurrent Ruby.
* Official Documentation: [https://www.rubydoc.info/gems/concurrent-ruby/Concurrent/Promise Concurrent Ruby documentation]

PHP


PHP offers promises through third-party libraries, with Guzzle's promises being one of the popular implementations.
* Official Documentation: [https://docs.guzzlephp.org/en/stable/quickstart.html#promises Guzzle Promises documentation]

Dart


Dart supports promises with its "Futures" for asynchronous programming, which is a part of the Dart core library.
* Official Documentation: [https://dart.dev/codelabs/async-await Dart Futures documentation]

Kotlin


Kotlin uses coroutines for asynchronous programming, which can be used to achieve behavior similar to promises. For promise-like functionality, Kotlin developers often turn to third-party libraries.
* No direct equivalent, but coroutines documentation: [https://kotlinlang.org/docs/reference/coroutines-overview.html Kotlin Coroutines documentation]

Each of these languages has its own take on asynchronous programming, with promises or similar constructs enabling developers to handle asynchronous tasks more effectively. The official documentation for each provides a comprehensive guide on how to use these features within the respective programming environments.

----

{{wp>Promises}}

{{navbar_promises}}
navbar_promises

{{navbar_async}}

{{navbar_concurrency}}

{{navbar_footer}}