Lately I’ve been working on the functional language F#, which I find very interesting and fits very well with my interest in writing simple-to-read and strongly-typed code. Thankfully C# has incorporated some features that have made C# closer to a functional language.
While reading Isaac Abraham’s “Get Programming With F#: A Guide for .net Developers” book – which I recommend – the author referred to an article on Tomas Petricek’s blog about the differences between C# Task and Async in F#.
I must say that the article is written in a very interesting, clear way, and able to explain some technical details that we do not face every day in projects. After reading the article obviously everything was very obvious 😁
https://tomasp.net/blog/csharp-async-gotchas.aspx/
In particular, I was struck by these:
– Gotcha #1: Async does not run asynchronously: the sync code inside an async function does not run asynchronously until an async call is made 🙃
– Gotcha #3: Async void methods: now all editors report this warning, but putting it in the list anyway is a must!
– Gotcha #4: Async void lambda functions: I find it interesting how you can write code that compiles but doesn’t work as you think 😅
And above all, how the F# approach is much clearer and more secure. I find that F# should be a much more popular language, because it really has great potential.