F# for C# people

To start with

EDIT1 Microsoft have addressed this F# is too niche misconception a little bit themselves, in a non-committal way.

EDIT2 Daniel Lazarenko has compiled an interesting list of potential gotchas in F# for C# developers.

Let’s keep things familiar and non-scary. The things that would come for free if Microsoft had devoted more than a fraction of means towards F# in Visual Studio is mainly the templating that makes C# so easy to use when creating websites and web services. To achieve that ease-of-use we have to rely on the community, and they have despite the odds come up with a few competitive options over the years.

Extensions

Visual F#

After downloading Visual F# you need to leverage the fantastic community contributions by installing plugins in Visual Studio to support your normal ASP.NET workflow:

F# MVC Templates

F# MVC Templates from fsharp.org will allow you to create MVC5 and WebApi2.2 in the same way you would a C# project.

Visual F# Tools Templates

NuGet packages

To help you develop you will rely at least initially on Nuget as before. Paket, as mentioned initially seems better suited to F# but you can keep using Nuget until you notice you need Paket.

FSharp.Data

This package lets you into the wonderful world of type-safe access to dynamic data. F# will use sample data to compile-time generate F# types that you can then use to access things like databases or web services. Popular demos are accessing world bank statistics and creating graphs on that.

SqlProvider

To connect to a SQL Server Database, please use the F# Type Provider (see above) named SqlProvider that gives you structured access to SQL Server stored procedures and tables. You can then query using Linq or call stored procedures as if they were F# functions.

Azure Storage Type Provider

In order to manipulate blobs and queues in Azure, this type provider is quite excellent.

Eventually

Extensions

Paket

For package management with F#, consider Paket, as it has full backward compatibility but a bigger featureset and is easier to understand.

FAKE

For build definitions you can benefit from using FAKE over Rake or MSBuild. Very nice way of documenting build dependencies.

Packages

Suave.IO

This web framework is very light-weight and uses monad composition to build web pipelines in a very succinct way. The only reason I wouldn’t start you off with this is that you need to be more naturally familiar with F# syntax, otherwise it becomes a bit hard to follow. Conceptually it makes a whole lot of sense, but it may not appear that way until you know your |> from your >=> et c. There is now a book out, with forewords from the excellent Henrik Feldt and the creator of F# Don Syme, that alleges to take you from intermediate F#er to hero. I shall get a hold of this book.

 

 

Advertisements