Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can F# teach me good functional programming practices?

I am planning to immerse myself in the functional programming paradigm and make the thought process second nature to me. The .Net/Mono is the only framework/objectmodel I am familiar with and I dont want to learn any other type system. That makes F# an obvious consideration since the burden of learning a new type system will not be a distracting factor.

But my concern is about the language itself. Will it be as good as any other classical functional programming language (e.g. Haskell) in drilling FP into my skull ?

like image 382
explorer Avatar asked Nov 22 '10 02:11

explorer


2 Answers

Yes, it can. Especially helpful and germane here is Real World Functional Programming which comes at FP from both the C# and especially the F# perspective. You'll love it.

like image 162
jason Avatar answered Sep 18 '22 15:09

jason


I think the benefit of learning functional programming with F# (especially if you already have experience with C# and .NET) is that you'll find it a lot easier to create some fun project.

  • One reason is that you're already familiar with .NET libraries (that are easy to access from F#)
  • Second reason is that F# is not pure, so you can start writing code that works and then improve it to make it more functional.

F# supports multiple paradigms, but it is mainly a functional language (compared to Python or C# that support multiple paradigms too, but aren't primarilly functional). This makes it easier to force yourself to use the functional style. It is easier to avoid imperative patterns, because they are more difficult to write in F# (and the code looks worse).

I think that once you "get" the basics functional programming, it will be easier to learn other functional languages if you'll still be interested. It is definitely nice to know a little bit about Haskell or Scheme, because they are more radical (in some ways).

If you're good at understadning concepts without actually using them in some real projects then starting with some classic language using some classic book may be a good option too (e.g. Haskell School of Expression or Structure and Interpretation of Computer Programs). I don't mean this in any negative sense - I personally quite like reading technical books without trying examples, because I can still take the interesting concepts from just reading (and for practice, there is always Google). Of course, you can write some code in Haskell or Scheme, but as a .NET programmer, you'll probably find writing F# code more fun...

like image 20
Tomas Petricek Avatar answered Sep 18 '22 15:09

Tomas Petricek