F# – In the Enterprise – I

This will be a series of posts on how-to use F# in the enterprise. I will strictly reduce this post to Windows based enterprise apps and it is not a debate about using F# over C#, it is more using Functional programming over pure OOP, And the ways in which we can use F# in different domains. Below are some common questions that you would see people asking around,

  • Who and how is F# being used in Enterprise
  • The tooling is not that good for Windows Forms / WPF platforms
  • What impact does this make in developing apps, Does FP reduces the time and effort that you put in?

We will also take a look at how F# can be used in all these different thick client application platforms that we normally use. And also, how and when F# can be used in these application platforms.

Windows Forms Client Apps

Most day-to-day work by WF programmers can be categorized as below,


Work is mostly with UI design using Visual Studio designer and develop apps real quick with minimal code behind. The DB layer also involves minimal code as the apps would normally use LINQ / DataSet designer to generate the middle layer.

Using F# right now with minimal designer support would be a heck lot of problems. There would be too much of code to write the connection between the UI and designer. This may be lot of work to get all the tooling support up and running in Visual Studio. May be we can expect this in VS2012 or future.

There are other kinds of apps in which it requires more technical analysis based on the problem domain. Consider writing apps for 3D, high-frequency stock trading, complex measurement units, high-level data-structures for charting etc., For these domains where you find the complexity needs to be addressed in a more concrete manner, F# is the right tool to use. As F# brings in more functional way of writing code, and easy abstraction over OOP to use with other languages.

Points to take from this,

  • Don’t use direct F# code if it is heavily relying on UI + DataBase. Unless you really want to take the pain of using it.
  • If you find a complex problem domain, then try identifying the complexity in it and see if F# can really help. To make this decision, You need to know how F# can be used, It is not a decision to be made by someone who is learning F# or not knowing the language.
  • Always build an OOP abstraction over F# code so it can be easily used with other languages (C# or VB.NET).

WPF Client Apps

WPF provides a new UX platform running on latest Windows OS. It’s core fundamental UX works with separation of UI code in XAML (a derivation of XML) and the Model provided to the UI. In 2005, John Gossman, currently one of the WPF and Silverlight Architects at Microsoft, unveiled the Model-View-ViewModel (MVVM) pattern on his blog. MVVM is identical to Fowler’s Presentation Model, in that both patterns feature an abstraction of a View, which contains a View’s state and behavior. Fowler introduced Presentation Model as a means of creating a UI platform-independent abstraction of a View, whereas Gossman introduced MVVM as a standardized way to leverage core features of WPF to simplify the creation of user interfaces. In that sense, I consider MVVM to be a specialization of the more general PM pattern, tailor-made for the WPF and Silverlight platforms.


F# fits very nicely when using MVVM pattern of development in WPF applications. Since most WPF developers prefer using MVVM as a pattern when developing WPF apps, it is really easy to use F# as the first-level language to build a full-fledged WPF app.

Of course, some developers may use heavy designer generated WPF app, but there is a difference in the way WPF designer works compared to Windows Forms. So once the WPF form gets designed, we can use pluggable F# code that can simply work out easily.

We will look into creating F# based WPF apps in the next post, and understand the small steps that we need to change to make it work.


6 thoughts on “F# – In the Enterprise – I

  1. Dmitri says:

    I don’t see any point in doing UI with F#, considering that C#/XAML are already there. There’s no direct benefit from using F# for defining very predictable, hierarchical UI structures. In fact, UI is initialized in a very mutable manner, which makes working with it in F# a bit painful.

    IMHO, F# is great for modelling particular problem domains. For example, in my MathSharp application, I use F# to define a MathML parser and pretty-printer. However, the rest of the application uses C# to create a WinForms/DX UI. That’s the kind of synergy that works for me, anyway 🙂

    • Fahad says:

      I was not encouraging to do UI in F#, My point is to use WPF with MVVM. I would be explaining more on this stuff in my next post. For WindowsForms, I do agree about what you say, and thats what I said too!

  2. […] the previous post we only looked into the problems we face in adopting F# as a language in our daily development […]

  3. […] our previous posts here and here, we looked at why and how F# can be used with WPF. Today we will check out how to create a […]

  4. Prathap Reddy says:

    @Fahad Amazing posts, Thanks for sharing 🙂

    I am very very very big fan of F#. I fell in love with it first time when i heard about this. I want to redevelop an application that is completely written using VB. The purpose of that application is to generate a webpage with Database support for each input element inside it. Can you please suggest me. I am ready to take pain in writing pain but i need stable and error free code.

    • Fahad says:

      What you are trying to do is a CMS, there are lots of them already available in the market, with SharePoint being the biggest CMS, you should rather try using them and then build components around it, that would be more fruitful!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: