United Kingdom: +44 (0)208 088 8978

How do I get started with F#?

You want to learn more about F# - great! But how what practical steps can you take to start building confidence and belief in it? Isaac takes us through some useful steps and exercises.

I often get asked this question by developers that are curious about F# and want to take that next step, but don't know how. I've written a three-part series that covers the topic from a commercial point of view - getting buy in from colleagues and so on, but for those of you that aren't at that stage yet - those that are firmly in the "curious" camp and yet to have the confidence to use F# in a commercial sense - then this post covers a number of tips and ideas for getting over that initial hurdle.

Use educational material

Don't struggle on your own. When I started learning F# several years ago, there really weren't many good resources available - a couple of books and not much more. Nowadays there's plenty, from YouTube channels, blogs (including this one!), websites (such as Scott Wlaschin's F# for Fun and Profit), plus several relatively modern F# books including mine, Kit's and Scott's. All target different aspects of F# - my personal advice would be that Get Programming with F# would best suit people looking to start using F# for commercial development as this is the audience I specifically aimed for.

The main point is that's there's a wealth of good learning materials out there - don't go it alone.

Install the right tooling

Tooling has come a long way with F# and there is now - especially with .NET Core / .NET 5 - a very good story around it. I would suggest any of the main three or four IDEs are fine - each have their own strengths and weaknesses. Visual Studio (for Windows or Mac - although I have no experience with the Mac version myself), JetBrains Rider and Visual Studio Code (with the Ionide extension) are all worth trying. There are also YouTube video series on this - for example, this series demonstrates installing VS Code on Windows and Mac, and even though it's slightly out of date, it's still worth going through.

Connect with the community

Many people are unaware of just how active the F# developer community is. There are a mulititude of ways to make connections and seek support - from Twitter (hashtag fsharp) to the official fsharp.org Slack channel and Forums. There are also user groups and meetups - so plenty of opportunities to chat to others and learn more - whilst the F# Foundation also offers a regular free mentorship programme.

Practice, practice, practice

This is probably the most important tip of all. If you want to learn F#, you have to do F#. You can't learn it just from writing a book or watching a video. Writing F# will not only increase your capabilities with the language, but just as importantly will also dispel the fear and uncertainty around it. When I first started using F#, I thought that its best place would be as a DLL that would be consumed by C# for the "hard" parts of development. However, I quickly realised that you could use F# for pretty much everything on the server (and today with Fable, on the client, too), from data access to web hosting with ASP .NET to business logic, caching - anything really.

How do you start? I would give a few ideas:

  • Pick a domain that you know well - perhaps something on a project that you are writing at work in whatever language you're comfortable in now - and try to implement it in F#. Don't try to port it line-by-line - this will end in frustration - but simply try to implement the same functionality and capabilities - so perhaps an API which offers several functions that can be called. Doing this will mean you already know the outcome and end goals - it's "simply" a matter of trying to implement it in a new language and paradigm.

  • The next time you're going to start a hobby project or similar - bite the bullet and do it in F#. You'll flail around at first, and ask yourself how much quicker it would be doing it in your current language of choice. This is totally normal! However, once you've gotten over that hurdle, you'll fine it's pretty much plain sailing.

If you're still struggling, there are other options out there, such as picking a programming kata or perhaps the Google Advent of Code etc. Essentially, pick some challenge to develop some system that you might today use e.g. C# for - but then use F# to solve it.

Make it a habit

Learning something - and having it stick - requires repetition on a regular basis, and learning F# is no different. Consider setting aside time once a week (or daily) to work on your F# project - just 15-30 minutes will do wonders to ensure that you don't forget, and continue to learn, the skills you pick up with F#.

Have an open mind

Don't assume anything about F# aside from the fact that it's a functional-first general purpose programming language! You can run it on different runtimes and environments and apply it in different scenarios - ones that you may never have considered. You might think it's difficult to learn, or as a functional language must be slow, or that it's just C# with a terser syntax. Try to throw all of those pre-conceptions out of the window and start from scratch. This will both help you more easily adopt a different way of doing things, but also avoid you trying to simply implement functionality using the same patterns that you've always applied - which may not take advantage of where F# is strongest.

Don't give up

Here's a confession from me: I needed three attempts to finally "get" F#. I tried twice and gave up - partly because of the lack of learning resources out there, but also because I simply didn't know where I was going with it. I'm incredibly glad that I stuck with it, because it re-invigorated my love for software development and solving challenges customers were facing. If you find yourself at a brick wall, reach out for help (we also offer free Office Hours for Q&A, for example).

Conclusion

If you want to learn F#, it's today easier than ever. There are a multitude of ways to start and help you get up to speed - as long as you're willing to put in a little work yourself. Just like learning to drive a car, you can't simply read a book and then the next day pass your driving test - you'll need to practice with hands-on exercises. The best form of these, in our opinion, are ones that you can come up with yourself and that you find fun and interesting, but you can find online resources and opportunities for to get your hands dirty in a variety of ways.

Have fun.

Isaac