United Kingdom: +44 (0)208 088 8978

My journey from C# to CIT

Matt, the newest member of the CIT team, writes about how and why he became an F# developer.

I've recently joined Compositional IT, so now seemed like a good time to talk through how and why I switched from being a C# developer to being an F# developer. I'll discuss how I discovered F#, what I did to become more familiar with it and why I jumped at the chance to join the team!

Learning the basics

For a few years before joining Compositional IT, I worked on a variety of ASP.NET MVC web applications written in C#. In that time, I learnt about some concepts that I wanted to put into practice in my C# code: immutability for value objects; a type for potentially missing data (like option) to avoid nulls; a type for potentially errored data (like result) to avoid exceptions. After feeling frustrated with my experience of using these concepts in C# code, a friend recommended F# and Scott Wlaschin's blog, F# for Fun and Profit. I soon discovered that there was much less friction when using these ideas in F# than C# and many more benefits besides.

Having spent a few months getting comfortable with the syntax and concepts, I tried implementing a hobby project in F#. I'd just read Scott's book, Domain Modelling Made Functional, so was keen to solve a problem where the domain was non-trivial; I settled on an app that would help me keep track of cards while playing the board game Pandemic. My initial aim was to get familiar with implementing logic in F# and not worry about a user interface, so I wrote a class library and some unit tests. That done, it was time actually to make the app. I'd heard good things about the Elm architecture, so decided to try Elmish. I'm really glad I did: it allowed me to create a client-side web application (currently hosted on my personal GitHub Pages site) rendered using React, written exclusively in F#.

Converted

Now convinced that functional programming is a better fit for the software I work on—solving business problems, usually with a web app—I started sharing ideas from functional programming with colleagues. A few lunchtimes were spent talking about the benefits and trade-offs as compared to other paradigms. I even gave a presentation to the organisation's "coding discussion group" on the underlying principles; expect some related blog posts in the near future 😀

I was thrilled when I became aware of the opportunity at Compositional IT: if I got the job, I'd have the chance to program in F# full-time, using SAFE Stack to write F# across the whole stack! I got started on my job application almost immediately. Thankfully, I did get the job and have got stuck in using SAFE Stack within my first few weeks.

I'd just like to sum up by saying this: if you haven't yet taken the plunge, give F# and functional programming a try. If you want to use F# to write a web application, try SAFE Stack. Once you get past any initial differences, you may find the simplicity liberating and realise that you're having a lot more fun—I know I am 😊

Learning resources