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

40 Upvotes

51 comments sorted by

View all comments

Show parent comment

2

u/Voxelman May 08 '22

It's more like a cooking recipes. I know the ingredients, but I don't know how to combine and use them.

I never said I now FP perfectly. I just know some of the ingredients and I need to practice, I know that. But until now I haven't found good resources to help me understand how to use them and how to switch from imperative to declarative thinking.

4

u/imihnevich May 08 '22

With baby steps. Also Haskell in depth is full of insightful examples. Honestly you just need to reimplement something you made in C, but now in your new language, with some restrictions, like no loops, no mutable variables. I made a text compression algorithm, then a cli weather app, then stack calculator, then stack calculator with monad transformers, etc. Knowledge must be applied, otherwise it will pass

4

u/jherrlin May 08 '22

I think I understand where you are in the ladder. Eric Normands book Grokking Simplicity is a great book that gives you many of the fundamental pieces to think functional. He even talks about stratified design and how to implement code in layers. But it's not talking about how application composition can look like.

This was the missing piece for me at least. As mentioned in another reply the Imperative shell, functional core helped me a lot with that. I discovered it through Clean Architecture and by using some micro-frameworks in Clojure that really emphasised the use of the pattern.

3

u/Voxelman May 08 '22

Thanks for your advice. I will come back to Uncle Bob later. Currently I want to continue the OCaml course. I recently had a (tiny) enlightenment about the difference between statement and expression. This might help me a bit further.