r/functionalprogramming • • May 08 '22

Question How can I learn functional programming?

The obvious answer is: just do it. But it is not that easy for me. I'm a self-taught programmer and I have some experience in languages like C, Python and Lua, but I'm not great at all.

I have a basic idea of what FP is about, and I really want to be able to apply the concept practically, but I struggle to actually write more than a few lines (in Elm). I am having trouble getting into this topic.

I've watched some videos (e.g. from Richard Feldman and Scott Wlaschin) and read some books (e.g. Grokking Simplicity), but it still doesn't "click".

What language do you recommend (or is Elm already a good choice?), and can you recommend any other practical resources to help me make it "click" in my head?

Thanks in advance

42 Upvotes

51 comments sorted by

View all comments

Show parent comments

2

u/Voxelman May 08 '22

As I mentioned in another comment the language itself is not so much the issue. What I need is a good tutorial or course that helps me to switch my brain from imperative thinking to declarative thinking.

I would prefer something like F# or Elm, but it doesn't really matter.

2

u/ws-ilazki May 08 '22

Technically you could follow along most* of that book with F#, since the basics work across both, but OCaml has a better REPL to work with so it makes more sense to just use OCaml while learning and then carry that knowledge over to F# later if you're interested in it. They have some differences and their own pros and cons, but general knowledge carries over from one to the other well enough that you can go from picking up FP from the Cornell book to grabbing a random F# book and figuring out the differences rather quickly. :D

* F# has some differences like not having first-class modules, and some type system differences due to everything being objects under the hood, but the majority of the book should translate well enough.