27

Python added the async/await constructs in 3.5 in 2015. The Javascript community made steps towards it for a bazzillion years and finally added a very similar implementation to the draft in ES8 released in 2017 (From my understanding). Typescript also added async methods in 2015 in version 1.7 that to the untrained eye look exactly like js async methods.

C# Added async methods in 2012 that look like all other implementations of async/await and were based on F#'s similarly behaving but different looking asynchronous workflows that were introduced in F# 2.0 in 2010. This is the earliest example I know of language built in asynchronous programming - C# with the async/await pair and F# with async flows.

Are there earlier examples of the keywords being used in this context as language constructs (or library)? From my limited information it looks like everyone imitated the good parts of the C# implementation, but did C# copy it from someone else?

  • 3
    If you're just looking for the usage of the words async await in a programming language, that's fairly recent. But asynchronous programming of the kind practiced by async await has been around for a long time. – Robert Harvey Aug 27 '18 at 14:53
41

Haskell (2012)

There is an async package for Haskell (2012) by Simon Marlow.

In case you don't know, Simon Marlow is a lead developer of Haskell.

Notes:


C# (2011)

Accoding to an Anders Hejlsberg interview for Channel 9 about Asynchronous Programming async/await in C# takes inspiration on async worflows in F#.

Microsoft released a version of C# with async/await for the first time in the Async CTP (2011). And were later officially released in C# 5 (2012).

In case you don't know, Anders Hejlsberg is the lead architect of C#, and has also worked in other languages including TypeScript.


F# (2007)

According to Don Syme, on his blog (2007), F# async workflows take inspiration from the implementation of asynchronous monad for haskell. In particular Peng Li's paper (2007) and Koen Claessen's "A Poor Man's Concurrency Monad" paper (1999).

The first version of F# to include "asynchronous workflows" is F# 1.9.2.7 (2007).

In case you don't know, Don Syme is the lead architect of F#, among other things.


Haskell (1999)

Koen Claessen's paper is the older implementation of operations with a result and continuations I can find (which is the logic behind async/await), dating to 1999. It implements concurrency by defining atomic operations, continuations and a round-robin scheduler. The monaid approach would be the motivation for the switch from message passing to awaiting results.

Abstract form the paper:

Without adding any primitives to the language, we define a concurrency monad transformer in Haskell. This allows us to add a limited form of concurrency to any existing monad. The atomic actions of the new monad are lifted actions of the underlying monad. Some extra operations, such as fork , to initiate new processes, are provided. We discuss the implementation, and use some examples to illustrate the usefulness of this construction.

This was not part of an official release of the language.


Prior work: Haskell

Concurrent Haskell (1996) is an extension of Haskell, to which "A Poor Man's Concurrency Monad" is an alternative. Concurrent Haskell used software transactional memory and threads (fork).

And the paper "Implicit and Explicit Parallel Programming in Haskell" (1993) by Mark P. Jones and Paul Hudak. This paper laid the groundwork for Koen Claessen's paper. The paper defines a fork function among other things.


Prior work: ML

In the paper "Implicit and Explicit Parallel Programming in Haskell" Mark and Paul analyze the properties of a fork function and the problem of side effects in concurrency, among other things. They reference the paper "A semantics for ML concurrency primitives" (1992) which picks a set concurrent primitives based on Concurrent ML and provides a proof that they preserve sequential execution properties.

  • 2
    This is a really good answer. I’m glad you mentioned Haskell & ML (both of which F# draws inspiration from). I know you’ll hear Haskell folks talking about “continuation style”. async/await is just compiler magic/syntax sugar on top of that concept. – RubberDuck Aug 28 '18 at 0:27
  • Did Haskel officially ship with these keywords or constructs before F#? – The Sharp Ninja Oct 22 '20 at 19:06
  • 1
    @TheSharpNinja I have improved the answer, hopefully that makes things clearer. – Theraot Oct 22 '20 at 19:52
2

I believe that Microsoft would not take already existing words, so the words async and await can be attributed to the times which you refer to. However, the ideas of Coroutines and Cooperative multitasking are very old.

  • 2
    I dont think it is correct to compare coroutines and asynchronous programming - they offer very different type of abstraction. – wondra Aug 27 '18 at 13:08
  • 5
    "I believe that Microsoft would not take already existing words" - Do you have any basis for that belief? Designers of successful languages are usually more pragmatic than that. – Sebastian Redl May 4 '19 at 18:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.