Introduction

After writing the previous article on F# and web scraping, I got a ton of email & reddit messages on learning F#, particularly if you have no previous experience with the .NET ecosystem.

Googling ‘Learn F#’ lands you on the F# Software Foundation’s website with a comprehensive list of learning materials arranged in no particular order. This article will instead define a more structured learning path that doesn’t assume specific previous knowledge.

Motivation

In case you weren’t already on board, here is some motivation to learning F# that you’ll need on this journey.

F#…

  1. is being used commercially by companies such as Jet
  2. is the third most loved language globally
  3. is the highest paying tech worldwide
  4. could be used for desktop apps (WPF, Eto, etc.), web apps (ASP.NET, Suave, Nancy, etc.), frontend apps (Fable, Websharper), native mobile apps (Xamarin), and more
  5. has no nulls (more correctly, they’re present but optional & opt-in)
  6. interops with C#, so it works with all existing .NET libraries
  7. has been nominated as the language of choice by the creator of Xamarin, Mono, and Gnome
  8. will always be a superset of C# in terms of features
  9. makes illegal states unrepresentable
  10. produces correct & super-concise code quickly

I’m new to programming

If you’re new to programming and determined to start with a functional language, I recommend you start by looking into OCaml or Elm. You’ll use those languages as stepping stones into F#.

OCaml is very, very similar to F# (although there are of course some differences); however, OCaml is known for being used as a teaching language, this means it has much more beginner-friendly teaching materials available, which is very important as you’ll have lots of questions when going down this path. Don’t consider your time ‘wasted’ while learning OCaml (as preparation to F#), it is indeed a useful language to know and is in fact being used by a large array of companies.

Elm is more similar to Haskell than F#, and is intended for use on the frontend as an alternative to JavaScript. The reason I’m suggesting Elm is because of its design philosophy. Elm cares about not introducing too many concepts at once and being friendly to the programmer. In fact, sixth-graders have had success using the language!

If you can’t make a choice, I suggest you just start with OCaml.

But I’m only new to functional programming

You may still find those languages helpful to learn. Personally, I was able to dive into F# (coming from C#/Python/JS) directly with no stepping stones but that maybe different for you.

@yawar_amin just brought to my attention that edX offers an F# course for those familiar with basic programming concepts. Also there is a Coursera course revolving around ML & functional programming that you might find useful.

I’m new to .NET/C#

Arguably, you don’t need knowledge of C# to get into F#. Sadly most F# resources assume you are a .NET developer looking to learn some F#, even those that explicitly say otherwise (too many C# examples being thrown around!). There are some intricacies that may require knowledge of how .NET works, and usually F# resources won’t go into those. That’s because you really don’t need to know that much about it, given the F# ecosystem seems to evolve separately from the C#/.NET one.

If you are a methodical learner as I am, and want to know how everything works (even if it won’t be of much use), I recommend you learn about the .NET Common Language Infrastructure (CLI); particularly how your code is compiled into the CIL and the how the underlying CTS works. If you’ll be using some OO features also have a look at this nice summary of C# types which might be helpful given that you may have to use these types in your F# code.

If you want to know even more (especially if you’re writing libraries for consumption from C#), you can read the learn C# in Y minutes page that’ll get you familiar with C# in less than a day. Again, this is not necessary but just helpful to know.

Finally, you’ll want to understand what .NET Core is and how it fits with .NET Standard. These technologies will allow you to write truly cross-platform software that runs on any OS without worry. F# support for .NET Core isn’t there yet (VS2017 crashes & the cli tool fails) but is being worked on by the community.

I’m new to F# #

Now comes the hard part, actually learning F#. As I have previously mentioned, there is a considerable amount of resources. I will not be compiling all of these into a list, instead, I’ll only mention those that I have found to be really helpful. If you just need a list, see the learning F# page.

I want to read a book

When it comes to books, the best one is Expert F# 4.0. It is the most up-to-date F# book out there and one of the authors is the language designer Don Syme. The book goes into more topics besides F#, such as web programming (Websharper), and functional GUIs (Eto.Forms). You may find some outdated topics but that’s the inevitable consequence to F#’s fast evolution.

If you want a more recent book, have a look at Learn F#. The book is in ‘early access’ (MEAP) meaning it is still being written but you could have a read at the completed chapters. I haven’t had a look at it but heard good things.

Finally, there is the timeless F# for fun and profit blog that discusses so much more (so this is a much slower route). The author is really passionate and dedicated to getting you to understand everything. The blog has been recently formatted into a free ebook (gitbook) if you want that.

If you can’t choose, I suggest you read Expert F# 4.0 while using F# for fun and profit as reference for extra details on a specific topic.

I want to watch video courses

Pluralsight is undoubtedly the best when it comes to F# courses. You can get a free pluralsight subscription through the VS developer essentials program (just sign-in with your Microsoft account) or through DreamSpark if you’re a student.

Once you have the subscription, have a look at Liam McLennan’s F# fundamentals. It goes through F#, explaining all the key concepts with a focus on functional style. Next, watch Kit Eason’s F# Data Structures course for in-depth coverage of F#’s data types. Finally, I recommend Mark Seemann’s A Functional Architecture with F# which covers how to write good F# code (using commands & queries). Personally, I was unable to understand most of the code presented in that course (I’m a long way from proficiency) but I learnt lots of interesting architecture.

There are more F# courses (on testing & type providers) that I haven’t tried but those are the ones I found interesting (and were not too old). There’s also Fsharp TV & Fsharp works, which offer paid courses that I also haven’t tried. Note: I’m not affiliated with any of these.

Community

F# has a very friendly community. If you happened to need any assistance with an F# project, you can easily get in contact with the project’s creators who’ll be happy answer (in fact, not once have my convluted questions not been answered!). F# is maintained (amongst other things) by the F# foundation, which I recommend that you join. Once you’re in, you’ll be invited to their slack channels where you can ask to your heart’s content (there’s a begginers channel). The foundation also has a mentorship program that maybe helpful if you can join. There’s also an F# channel on the ‘functionalprogramming’ slack but I haven’t tried that. If you still need more assistance, have a look at /r/fsharp which is a smaller community where you’re guaranteed to get an answer.

Gripes

At this point, you must have come across some of F#’s negatives. It can be easy to just decide to quit and go with an easier language, especially given that learning F# is not an easy feat, but I encourage you not to. F# is certainly not a perfect language but it is much better compared to others. The tooling maybe mediocre but it is the best for a functional language out there. I have been searching the functional programming landscape for long, looking for the perfect language that does everything, and I can assure you that language is F#. None others have the same capabilities that .NET provides, and the disadvantages are mostly a product of the fact that functional languages have a small community: something that isn’t specific to F#.

Conclusion

I hope I have provided you with the needed motivation and materials to start exploring F#, regardless of your previous experience or future goals. If you’d like to practice what you’ve learnt (and you must!), checkout reddit’s daily programmer, my go-to for programming practice! If you have any questions or feedback don’t hesitate to leave a comment or send me an email; I am not even close to being a proficient F# developer (and the F# community has some really bright minds), so if I’ve made a mistake do notify me! Thanks for reading!