r/functionalprogramming • u/daredevildas • Oct 16 '18
Question Path to learn functional programming
Background - After my internship, my supervisor told me that I needed to work on my program design and learning functional programming would be a step in the proper direction as it would force me to think in a particular way.
Steps taken - He suggested learning scala, but since it is not strictly functional I was not really "forced" to program in a functional style.
Programming Language Experience - Java, Python, Scala
Most functional programming language tutorials/books out there focus on the language and not "functional programming" (The language is always the easy part - It does not take that much time to pick it up).
I would love any suggestions on how to go about learning functional programming. Thanks.
8
Oct 16 '18
Full time elixir/erlang dev here. I found this to be quite good on the subject- https://github.com/MostlyAdequate/mostly-adequate-guide
1
u/daredevildas Oct 16 '18
Does this assume Javascript knowledge?
3
u/mercerist Oct 16 '18
I can second the recommendation! I also rather like (most of) Dave Thomas' talks on FP and Elixir. He's got a nice approach to things, and most of his talks are sort of 'general' when it comes to FP and focused on education, where Elixir is just the particular language he uses to explain things.
2
2
14
u/doodlehaus Oct 16 '18
http://haskellbook.com/ is a great intro to both Haskell and FP concepts. As a strictly functional language, Haskell is a great way to force yourself to work in a functional way. The downside is that Haskell syntax can be pretty terse and not always as approachable as elixir.
3
u/Vaglame Oct 17 '18
Can't recommend that book enough! And then Real World Haskell in very nice to see, well, real world applications
5
u/nasoloaina Jan 17 '19 edited Jan 17 '19
I think "Functional programming in Scala" by Paul Chiusano and Runar Bjarnason is really good in teaching FP concepts. Scala is used as a mean here but the concepts of FP and their use can be applied and translated to other languages as well. You should give it a shot.
Another book that's worth mentioning is "The Joy of Clojure" though it's more tied to FP and programming the "Clojure way". It's definitely not a beginner book since you have to have a prior experience with Clojure to fully get a grasp of the concepts. What I'd suggest if you're interested in reading that book is to get a general purpose Clojure book first, practice a little bit then read it after you've got the fundamentals of the language.
In terms of language, I'd rather go with Scala first or any language whose syntax is more familiar to you (algol family language). The reason is that if you try to learn syntax and more abstract (foreign) concepts at the same time (like Lisps), the cognitive load can make you can feel discouraged in the end and you would give up. So begin with something you're familiar with first, but as soon as you want/need more do not hesitate to go further and explore other things. And by further, I am talking about Lisps for example (talking about Clojure earlier )...it can rewire your brain in very strange ways... but for the good hopefully.
To sum it up :
learn the FP concepts
apply the concepts with a language you're familiar with
review the concepts (you need this feedback : the aha!! moment should happen here )
apply the concepts to other languages as well : it seems that variation in learning helps a lot because it somehow trains your brain to "translate" and "transfer" knowledge based on contexts... which is the goal anyway 😊
remember, learning takes time...have patience
Good luck and more importantly have fun ^
4
Oct 17 '18
The Little Schemer series and the book An Introduction to Functional Programming Through Lambda Calculus ?
4
u/yokode_kyusu Oct 17 '18
While I second the https://github.com/MostlyAdequate/mostly-adequate-guide and http://haskellbook.com/ suggestions, I've also enjoyed the https://www.manning.com/books/real-world-functional-programming book. The approach taken by the authors is to present a problem and then compare a solution in F# to a solution in C# which, I think, is quite helpful if one is familiar with an object-oriented language like C# and wants to see how one would tackle a familiar problem in a functional language like F#. In contrast to the two books mentioned above, it is also not mentioning any category theory (which, depending on your view, can be a good or bad thing).
7
u/couchjitsu Oct 16 '18
For me, learning elixir was what made the switch. I had played with Haskell off and on. But elixir's focus on people enjoying the language as they were writing it, helped me stick with it.
That combined with the way it encourages you to think about processes etc coming from erlang drove home the FP principles.
I have a Pluralsight course on Elixir.
3
u/Zinggi57 Oct 17 '18
No mention of elm yet?
I think elm is a great language for learning functional programming, as it's purely functional (like Haskell), but is a much simpler language to master.
Some here might think that learning elm will not teach you about more advanced functional concepts (like monads), because in elm there is no way to abstract over these concepts. However, by just using elm you will actually get familiar with these concepts without actively knowing them. So later when you want to learn more and have a look at Haskell, most concepts will be very familiar to you.
2
u/infinitehigh Oct 26 '18
https://ocaml.org/learn/tutorials/99problems.html
That'll help you with applying functional programming features to problems.
3
u/Herku Oct 16 '18
I really liked the PureScript book knowing already a lot of programming. It aims at people with prior programming knowledge. Most language intro books start at zero.
2
u/vietthang0705 Oct 17 '18
Maybe some Category Theory concepts?
https://en.wikibooks.org/wiki/Haskell/Category_theory#Functors
1
u/i_have_a_gub Oct 22 '18
He suggested learning scala, but since it is not strictly functional I was not really "forced" to program in a functional style.
Well, why not force yourself to write it in a functional style? If you already have some experience with Scala, it seems like the obvious choice. Scala with Cats is a great place to start and should put you in a place to start writing functional programs. If you want a deeper dive, you can tackle The Red Book.
1
u/sahand-javid Mar 19 '23
Exactly as my problem! All courses are focusing on Language rather than the FP concepts.
I love TypeScript so I forced myself to learn Functional Programming using TypeScript (My background is on front end engineering).
I feel you. That's why I started a Playlist on my YouTube channel to teach Functional Programming, and the focus is Functional Programming. I'm using TypeScript to demonstrate concepts. My assumption is that you are completely beginner in FP but you love to get really good at it. I'm creating something similar to fp-ts, which is a really popular library for Functional Programming in TypeScript. I'm adding a video every 2 week to a month.
My YouTube channel name is "Web Village Voyage" and it's at "https://www.youtube.com/@webvv".
Let me know what you think if you ever take a look.
9
u/spreadLink Oct 17 '18
Not to bash haskell, but I can not believe that, in a question specifically asking for non-language books, the haskell book gets recommended and SICP remains unmentioned.
You should try "Structure and Interpretation of computer Programs", it's free online and v v good.
It uses scheme as the teaching language, but really can be worked through with any language supporting basic recursion and higher order functions.
It will also not just teach functional programming, but generally good principles for writing good programs in any environment.
Also, don't be scared by the mathy examples in the beginning, they only look scary because of the Greek symbols.
Good luck.