4 ms·
Isn't async in f# considerably less efficient than in c#?
by kod 8y ago
Isn't async in f# considerably less efficient than in c#?
- btschaegg 8y agoI think so, yes. However, I'd attribute that to F# having the first implementation and not enough clout to influence the central .NET implementation, like C# did. AFAIK, there's another computation expression builder using Task<T> in FSharpx that performs better. However, since in C#, async functions also seem to boil down to monadic continuations, I see no obvious reason the F# way couldn't be optimized to the same degree (given enough determination and resources). If there's anyone here with insight into the `async` implementation that knows otherwise, I'd really appreciate a comment on this :) Edit: Andrei Alexandrescu had a nice latin phrase on this in a talk at DConf 2018[1]: «Quod licet iovi non licet bovi». There, he's basically arguing the same thing: It is very often more desirable to give the language user a tool they can use themselves instead of reserving it only for the language implementers. [1]: https://dconf.org/2018/talks/alexandrescu.pdf https://dconf.org/2018/talks/alexandrescu.pdf Page 4
- dgudkov 8y agoThey have different design goals. Async in F# works better for F# applications. Tomas Petricek wrote a couple good articles [1][2] comparing both approaches to async computations. [1] http://tomasp.net/blog/csharp-fsharp-async-intro.aspx/ http://tomasp.net/blog/csharp-fsharp-async-intro.aspx/ [2] http://tomasp.net/blog/csharp-async-gotchas.aspx/ http://tomasp.net/blog/csharp-async-gotchas.aspx/