A missed opportunity masquerading as a killer feature.

This article is part of a series called Worse is better, in which I muse on technologies and techniques that became popular despite superior alternatives. Think VHS versus Betamax.

In this article, I will argue that the celebrated async/await language feature pioneered by C# should rather be classified as a missed opportunity. F# did async first, and better, but of course Haskell does monads even better.

Since the introduction in C# the async and await keywords have been ported to multiple other languages, including C++, Python, JavaScript, and more. With such apparent success, it seems odd to complain that it's worse than alternatives.

My Richard-Gabriel moment #

To be honest, async/await is perfectly cromulent. Pragmatically it solves real problems. What's the complaint?

As examples go, this is perhaps the most direct counterpart to Gabriel's original lament about C++ and Lisp. Gabriel considered Lisp superior to C++ because Lisp was a coherent and elegant system. Still, the heterogeneous hacked-together nature of C++ enabled faster time to market, eventually outcompeting Lisp.

Adding async and await keywords to a language is comparable to the C++ approach. Instead of solving a general problem, it only solves a particular problem, albeit a large one.

Computation expressions #

What makes this so regrettable is that a general language-design solution already existed. As witnessed by language version history, F# already had asynchronous workflows with syntactic sugar in 2007. This language feature still exists today:

member _.GetRecommendationsAsync userName = task { // <- async
    // v await
    let! scrobbles = songService.GetTopScrobblesAsync userName

    // The rest of the code block follows...

This example is from Porting song recommendations to F#, although I've clipped the code and changed the comments for didactic reasons.

The language feature is called computation expressions, and while the base library comes with a few built-in computation expressions, it's a completely user-definable feature. My article Song recommendations with F# free monads has a comprehensive example, but usually, a few lines of code are enough.

The original 2007 computation expression was called async, and it's still around. Since it predated the .NET Task Parallel Library, it was based on its own implementation of Async<'T>.

Later, the F# core library also got task expressions to support the de-facto standard of using Task<T> for asynchronous processing. No new language feature was required.

In the above code example, task introduces the computation expression, roughly corresponding to the C# async keyword. Likewise, the exclamation point ! in let! corresponds to await. The beauty of the F# language design is that while it perfectly supports asynchronous programming, it's by no means specialized to that task.

Short-circuiting workflows #

Computation expressions can add syntactic sugar for any functor, applicative functor, or monad, although you get the most bang for your buck with the latter.

For example, you can write short-circuiting workflows if you add a little computation expression builder for the option type. For instance, you could rewrite Cpr.tryParse from the article Danish CPR numbers in F# to something like this:

// string -> CprNumber option
let tryParse (candidate : string ) =
    let canonicalized = candidate.Trim().Replace("-", "")
 
    option {
        let! dayString               = canonicalized |> String.trySubstring 0 2
        let! dayCandidate            = dayString |> Int.tryParse
 
        let! monthString             = canonicalized |> String.trySubstring 2 2
        let! monthCandidate          = monthString |> Int.tryParse
 
        let! yearString              = canonicalized |> String.trySubstring 4 2
        let! yearCandidate           = yearString |> Int.tryParse
 
        let! sequenceNumberString    = canonicalized |> String.trySubstring 6 4
        let! sequenceNumberCandidate = sequenceNumberString |> Int.tryParse
 
        return! tryCreate
            dayCandidate
            monthCandidate
            yearCandidate
            sequenceNumberCandidate
    }

This workflow may fail at every step marked by an exclamation point. If it does, it stops processing the rest and simply returns None.

This behaviour didn't require a new keyword, or any new language feature, but instead relies on the general-purpose computation-expression language feature and, in this case, a little user-defined expression builder:

type OptionBuilder () =
    member _.Bind (x, f) =
        match x with
        | Some v -> f v
        | None -> None
    member _.Return x = Some x
    member _.ReturnFrom x = x
 
[<AutoOpen>]
module OptionBuilder =
    let option = OptionBuilder ()

While this is already quite elegant, it still requires a bit of (reusable) boilerplate for every functor you wish to support, such as option, result, task, etc.

Programmable semicolons #

Haskell, with its more powerful type system, fully automates this process. Every Monad (or Applicative with the ApplicativeDo extension) instance enables you to drop into do notation, which gives you nice syntactic sugar for the monad in question.

Since Maybe is a Monad instance, you don't have to write any user-code equivalent to the above OptionBuilder. Just drop into do notation, and the compiler automatically handles the workflow for you. As an example, you could port the above tryParse function to Haskell like this:

tryParse :: String -> Maybe CPRNumber
tryParse candidate =
  let canonicalized = filter (/= '-') $ trim candidate
  in do
    let (dayStr, rest1) = splitAt 2 canonicalized
    let (monthStr, rest2) = splitAt 2 rest1
    let (yearStr, rest3) = splitAt 2 rest2
    let sequenceNumberStr = take 4 rest3
    day <- readMaybe dayStr
    month <- readMaybe monthStr
    year <- readMaybe yearStr
    sequenceNumber <- readMaybe sequenceNumberStr
    tryCPRNumber day month year sequenceNumber

All the variables bound by <- arrows may cause the computation to short-circuit. This syntax is equivalent to F# let! bindings. Returning a short-circuiting value is also possible in both cases, but while F# requires the return! keyword, in Haskell this is done by omitting return.

This Haskell language features is so powerful that Real World Haskell (among other sources) calls it 'programmable semicolon'. You could use the same phrase for F# computation expressions.

Where C# falls short #

The async/await feature of C# provides syntactic sugar similar to F# computation expressions and Haskell do notation, but unfortunately, only for asynchronous workflows. As long as your 'outer' monad is Task<T> it works decently, but it doesn't address other cases, like the above examples of short-circuiting computation.

Ironically, C# has another language feature that enables syntactic sugar for monadic workflows: Query syntax (AKA LINQ). You can see a small example in the Maybe monad article, as well as plenty of other articles on this site. You could port the above CPR example to C# and achieve short-circuiting behaviour using query syntax.

Is it possible to use query syntax with asynchronous workflows too? Yes, indeed, since asynchronous computations are also monadic. Is the async/await language feature redundant, then?

No, because query syntax has other limitations.

Venn diagram of computation expressions showing overlap between LINQ and async/await. Both support sequential composition; LINQ uniquely emphasizes extensibility, while async/await uniquely includes branching and commands. Parallel composition is shown as part of computation expressions in general, but is not a member of neither LINQ nor async/await.

As this diagram attempts to capture, while LINQ works for any monad (any functor, in fact), it supports neither branching nor Commands. That is, you can't use if or switch inside of a LINQ query, and you can't call void methods. You can see an example of the kind of trouble the latter issue causes in my Preserved in translation video. Another example of the awkwardness of LINQ can be seen in the article Flattening arrow code using a stack of monads.

On the other hand, as already covered, async/await does support branching and Commands, but is not user-definable; it only works for asynchronous workflows.

Finally, while both support sequential composition (monadic bind), none of them support 'parallel' composition, which is what you can get by ignoring monads and instead emphasising applicative functors. By 'parallel' I mean that you can compose independent computations in a way where what happens to one computation does not short-circuit the rest of the composition. This is particularly useful for validation, as shown in An F# demo of validation with partial data round trip. More specifically, it can be used to implement true parallelism, as demonstrated by the Haskell async package.

Language design versus implementation #

To be clear, my gripe about async/await is about programming-language design. Given the language design choice, the C# (or rather: .NET) implementation of async/await is impressive. Clearly, a lot of work has gone into making it work efficiently.

People who know how async/await and the Task Parallel Library works may consider the async package primitive at best, and possibly cheating. As far as I can tell, the Haskell async package creates a new thread every time you enter an Async computation. This can be expensive, and may not be necessary.

A C# Task, on the other hand, may or may not run on a separate thread. Often they utilize thread pools and relinquish threads back to a pool while waiting for external I/O events. A lot of thought has gone into the implementation, and my experience is that it works well. The Haskell async package does none of that, as far as I can tell.

The F# task computation expression, however, is simply syntactic sugar over the .NET implementation, thereby demonstrating that you can get the best of both worlds. A sophisticated, efficient implementation controlled by elegant and extensible language design.

Conclusion #

C#'s async/await language feature is so celebrated that other languages have adopted it. Even languages with little or no connection to Microsoft, such as Python and JavaScript, have a similar feature, sometimes even using the same keywords. Surely, this is a sign of success?

The async/await language feature is, in my eyes, a perfect example of Gabriel's maxim that worse is better. It's an essentially ad-hoc addition by way of adding more keywords to an already-complicated programming language.

What makes this disappointing is that a more elegant language design was already known at the time. C# could have got its own version of F# computation expressions, which would have enabled both language designers and 'normal' programmers to solve many more problems using the same, universal tool.

Of course, since C# already has two competing, partially overlapping kinds of syntactic sugar, I can't rule out that one day, it'll get a third, proper language feature that solves this once and for all. But I don't really believe that. That ship has sailed.

Which only underscores the message from the previous article: F# is a better programming language than C#.


Comments

Johannes Egger #

I'm sure you know that since C# 7, it's actually possible to use types other than Task as return types for async methods (see https://learn.microsoft.com/en-us/dotnet/csharp/asynchronous-programming/async-return-types#generalized-async-return-types-and-valuetasktresult):

Console.WriteLine(Run(Option<int>.None)); // "None"
Console.WriteLine(Run(Option<int>.Some(3))); // "Some(5)"
 
static async Option<int> Run(Option<int> b)
{
    return await Option<int>.Some(2) + await b;
}

But the majority of libraries out there don't seem to implement their monadic types like this. Maybe you know why? Is there something fundamentally wrong with this approach?

As a reference, click here to unhide the (AI-written) implementation of Option<T>.
using System.Runtime.CompilerServices;
using System.Runtime.ExceptionServices;
 
[AsyncMethodBuilder(typeof(OptionMethodBuilder<>))]
public readonly struct Option<T>
{
    private readonly T _value;
    public bool HasValue { get; }
 
    private Option(T value) { _value = value; HasValue = true; }
 
    public static Option<T> Some(T value) => new Option<T>(value);
    public static Option<T> None => default;
 
    public T Value => HasValue ? _value : throw new InvalidOperationException("Option is None");
 
    // Makes Option<T> awaitable
    public OptionAwaiter<T> GetAwaiter() => new OptionAwaiter<T>(this);
 
    public override string ToString() => HasValue ? $"Some({_value})" : "None";
}
 
internal interface INoneAwaiter { }
 
public readonly struct OptionAwaiter<T> : ICriticalNotifyCompletion, INoneAwaiter
{
    private readonly Option<T> _option;
    public OptionAwaiter(Option<T> option) => _option = option;
 
    // Some -> completes synchronously; None -> compiler asks the builder to "suspend"
    public bool IsCompleted => _option.HasValue;
    public T GetResult() => _option.Value;
 
    // Never actually called: the builder intercepts None
    public void OnCompleted(Action continuation) => throw new NotSupportedException();
    public void UnsafeOnCompleted(Action continuation) => throw new NotSupportedException();
}
 
public sealed class OptionMethodBuilder<T>
{
    private Option<T> _result;
    private ExceptionDispatchInfo? _error;
 
    public static OptionMethodBuilder<T> Create() => new OptionMethodBuilder<T>();
 
    public void Start<TStateMachine>(ref TStateMachine stateMachine)
        where TStateMachine : IAsyncStateMachine
        => stateMachine.MoveNext();
 
    public void SetStateMachine(IAsyncStateMachine stateMachine) { }
 
    public void SetResult(T result) => _result = Option<T>.Some(result);
 
    public void SetException(Exception exception) => _error = ExceptionDispatchInfo.Capture(exception);
 
    public Option<T> Task
    {
        get { _error?.Throw(); return _result; }
    }
 
    public void AwaitOnCompleted<TAwaiter, TStateMachine>(ref TAwaiter awaiter, ref TStateMachine stateMachine)
        where TAwaiter : INotifyCompletion
        where TStateMachine : IAsyncStateMachine
    {
        if (awaiter is INoneAwaiter)
            _result = Option<T>.None;   // short-circuit: never resume the state machine
        else
            throw new NotSupportedException("Only Option<T> can be awaited inside an async Option<T> method.");
    }
 
    public void AwaitUnsafeOnCompleted<TAwaiter, TStateMachine>(ref TAwaiter awaiter, ref TStateMachine stateMachine)
        where TAwaiter : ICriticalNotifyCompletion
        where TStateMachine : IAsyncStateMachine
        => AwaitOnCompleted(ref awaiter, ref stateMachine);
}
2026-11-23 16:20 UTC

Thank you for writing. I was, indeed, aware of that option(!), but chose not to discuss it because I was concerned that it would make the article less readable. In any case, I don't think it changes the conclusion.

The point of the article is that F# is a better programming language than C#. Even if something is possible in both languages, but one language makes it much harder than the other, then that only demonstrates that one is better than the other.

Whether there is something fundamentally wrong with using awaitable types as monads, as you (and others) propose, is another question, and to be honest, I don't (yet) know. One way to attempt to answer that question is to examine whether or not the monad laws hold for such an implementation. Given that the implementation is riddled with exception branches and mutable state, that's not an easy undertaking.

This also hints at a more practical reason why you don't see this much in the wild. It's complicated.

Still, you could argue that most monadic types (like your proposed Option) are reusable, so even if the implementation is tricky, once implemented and well tested, it could provide benefits to 'normal' users. So why don't we see this more?

A more practical explanation, I'm guessing, is that it's just a hard sell. It's not natural to await an option. What's asynchronous about it? The same question could be asked of many other monadic types, like Either, State, or Reader. What's asynchronous about state? Why would you await it?

Another question that comes to mind that I honestly don't know the answer to is this: Theoretically, and in Haskell, a monad is always an applicative functor, and an applicative functor is always a functor. Thus, we would like our language feature to extend to, and be consistent with, such data structures. Is it possible to make a type awaitable if it's only a functor?

2026-12-03 07:20 UTC


Wish to comment?

You can add a comment to this post by sending me a pull request. Alternatively, you can discuss this post on Twitter or somewhere else with a permalink. Ping me with the link, and I may respond.
Published: Monday, 16 November 2026 07:36:00 UTC