all Technical posts

.NET 6 & Visual Studio 2022: Why There's No Longer Any Reason to Disregard F# in Your Next Project

There's no excuse anymore. For a long time, tooling and accessibility were reasons to disregard F#. Until now.

Recently, .NET 6 was released together with an IDE update, Visual Studio 2022. This post will quickly run over some updates that make interoperability between C# and F# better.

For more information on F# updates, see this blog post.

Bridging the Gap With C#

One of the hurdles to C# interoperability is asynchronous programming, as the Task Async conversion is rather difficult to keep track of. With the new version, we have a built-in task builder to make this easier. For projects where both frameworks are used, it’s advised to use tasks; but for a purer development, we can still use our great async builder.

Many open-source projects were already implementing a similar task builder, so it’s great to see this adopted in the core library.

Another great update for better interop is the implicit conversions. Both for assignment and return types, we can now relax and let the type system take care of the rest. These features were already in C#, and it’s great to see them implemented here.

Debugging Functions

Debugging F# code is something that was sometimes troublesome too, as the function composition can sometimes make things a bit complicated. Although test-driven and type-driven developers would probably tell me to discard debugging altogether, I’m reluctant to agree.

Nevertheless, the Visual Studio update has improved on pipeline debugging and also shows shadowed values, which make debugging F# a lot more comfortable.

shows how Visual Studio locals window has values from the F# pipeline

In-Memory Cross-Project Reference

In the newest version, you can reference a C# project in a F# project without having to compile it first. This is by-default in C#/F# projects from the same language, but is also now available in cross-language projects. What this means is faster and more comfortable development. For me, this shows that the .NET development now grows towards a cross-language system where we take the best of both worlds.

The next step would be to do the opposite: making F# projects in-memory references in C# projects. Let’s all hope that that’s included in the next version.

Conclusion

F# sometimes seems to be something that people directly disregard in projects. The argument that it’s ‘not readable’ is often used. Let me take this opportunity to explain that ‘readability’ is not the same as ‘familiarity’. Object-Oriented Programming seems to be always in favor. That is, in my opinion, a mistake, which disregards the benefits of change — how it can make some parts better and more readable. Take your time, educate yourself, and hopefully you can help me make Functional Programming and F# more integrated within projects. Trust me, it’s a wonderful world once you fall down that rabbit hole!

Thanks for reading!
Stijn

Subscribe to our RSS feed

Hi there,
how can we help?

Got a project in mind?

Connect with us

Let's talk

Let's talk

Thanks, we'll be in touch soon!

Call us

Thanks, we've sent the link to your inbox

Invalid email address

Submit

Your download should start shortly!

Stay in Touch - Subscribe to Our Newsletter

Keep up to date with industry trends, events and the latest customer stories

Invalid email address

Submit

Great you’re on the list!