Forum Discussion
adelarsq
Nov 12, 2021Copper Contributor
F#: Tasks vs Async
With F# 6 now we have option to also using Tasks. Which are the drawbacks to use Tasks or Async?
Also appears that Tasks are faster. How much faster?
Thanks in advance.
- pblasucciCopper ContributorThere was actually a bit of discussion about this on Twitter just a few days ago.
TL; DR --
The Task CE is meant to simplify cases where you have a lot of interop with other existing Task-based APIs (eg: you're writing an APS.NET Core middleware), or if lots of profiling dictates that Async CE is causing performance issues. But by and large, the Async CE should be preferred.
Hope this helps! 🙂 - MauricioCaspianCopper Contributor
Async programming in F# is designed for lightweight and compositional asynchronous workflows, making it well-suited for tasks that involve I/O operations or waiting for external resources. It provides built-in exception handling and cancellation propagation, making it easier to manage errors and handle asynchronous operations.