A typical conversion:
Me: “Did you take a look at F#?”
Paul*: “No, it’s just too hard to learn!”
Me: “Why?”
Paul: “I don’t understand anything because of the syntax.”
*Paul = Person assuming unyielding learning
F# isn’t hard to learn. But you probably have to learn four concepts that you may never have seen before**
**unless you have experience in other functional programming languages
Let’s see these concepts and how you can learn F# quickly.
Different concepts, but fewer of them
When I started to learn F#, I struggled to read examples because of these four concepts: significant whitespace, function arguments, pipes and computation expressions.
That’s why it’s a good idea to start with a tutorial, book or course that covers the basics first. When I learned C# – after programming C++ – I could take a lot of my understanding of C++ along, especially the syntax. So C# seemed easy to learn. When learning F#, you must take a step back and start with the syntax. That doesn’t take long, but it makes understanding the rest of F# much easier.
I would even consider F# one of the simpler languages to learn. My experience is that I learned F# much quicker than, for example, TypeScript. The reason is that while F# has some concepts that are probably new to you (the ones mentioned above), the language overall has fewer concepts than, for example, C# or TypeScript. The reason is that F# has some higher-level concepts that are reused for different scenarios, whereas C# invented a new concept for every use case. Computation Expressions can be used for asynchronous computing, query syntax, dealing with results, etc. One concept for three problems. C# has async/await, LINQ and exception handling—three different solutions for three problems.
If you don’t believe me, then compare the language documentation of F# and TypeScript 🙂
Good resources to start learning
Okay, you want to give learning F# another try. Here are some good resources:
- F# in Action (manning.com) (book)
- F# for fun and profit (fsharpforfunandprofit.com) (website)
- F# From the Ground Up | Udemy (course)
- F# on Exercism (tutorials)
- F# docs – get started, tutorials, reference. | Microsoft Learn (official documentation)
- (178) F# Fundamentals Tutorial | Learn Functional Programming | Step-by-Step Guide – YouTube (all basics in one video)
Final thoughts and a book recommendation
And always keep in mind that we find simple what we are used to at first. Even if it isn’t. If you want to understand how our brains work when coding and learning to code, there is an excellent book for you: The Programmer’s Brain (manning.com)
So long, and thanks for the fish reading 😉
[…] Myths about F#: F# is hard to learn! No, it’s just different than C#. (Urs Enzler) […]
I’ve learned dozens of programming language. I’ve written hundreds of thousands of lines of code in famously difficult languages like Rust, Typescript and C++. I’ve written a few lines of code in Elm and Scheme too. I’ve never struggled like I struggle with F#. The error messages vary from opaque to misleading. I’m currently stumped on how to call a function in a loop. https://stackoverflow.com/questions/77341323/how-to-call-writebytesasync-in-a-loop
I find F# to be truly harder than the rest.
Interesting. My experience is quite different. I found learning F# much easier than learning, for example, C++ or Type Script. But I agree with your point regarding error messages. Some are really cryptic – especially when type inference goes astray.