r/functionalprogramming • u/Feldspar_of_sun • Dec 02 '24
Question What languages to start learning FP?
The purely functional languages I know off the top of my head are Haskell and Elixir, but I know there’s plenty more.
What’s generally recommended as the best language to learn pure FP?
Note that I’m not a complete beginner in programming. I’m far from experienced but I know more than just the basics
30
Upvotes
2
u/MaxHaydenChiz Dec 02 '24
There are different things people mean by "FP". What is the goal here?
19
u/unlessgames Dec 02 '24
elm is fun and manages to be quite practical without relying on all the bells and whistles while still teaching you a lot of concepts around FP.
17
u/rauschabstand Dec 02 '24
Clojure! Not "purely functional" but Lisps in general are worth learning. With Clojure you profit from a huge eco system of mature libraries and tools!
12
u/logaan Dec 02 '24
There is a spectrum of pureness in FP languages. Haskell is quite pure, Elixir is less pure. It sounds like you're open to both.
I've had a good time with Gleam lately, it's a small language that shouldn't take long to learn. But the community is small, so you might not find a lot of help if you get stuck.
If you enjoy learning through traditional lectures you might like Scheme, which was used as the CS101 language at some big universities.
I think Elixir is probably a good choice though. A pretty easy language to learn, and well established enough for you to get help if you get stuck.
5
u/Tempus_Nemini Dec 02 '24
Haskell of the way
4
u/mister_drgn Dec 02 '24
I think there are significant differences between statically typed functional languages like Haskell or Ocaml and dynamically typed functional languages like some lisps--though of course there are commonalities as well. So it depends what you're looking for.
4
u/kikofernandez Dec 02 '24
Erlang. Elixir runs on top of the Erlang VM. Erlang is a really simple FP language, and it will help you understand why Elixir has also processes and its distribution system
4
u/Petersmith2459 Dec 02 '24
Don't be afraid to experiment with different languages like Clojure, Lisp, or Erlang. Each language has its own unique strengths and weaknesses.
4
u/ElmForReactDevs Dec 02 '24
i thought i knew what FP was till i picked up Elm.
4
u/Tbetcha Dec 04 '24
It would be helpful to know what you’re familiar with. I know these languages aren’t pure FP languages but if you know C# then F# would be good since they share libraries and other commonalities, same with Java and Scala. My option would be to try F#. Once again it’s not a pure FP language but you’ll still learn the concepts and it does allow for some leniency which is helpful if you’re a beginner to writing functional code.
Another thing which makes it a good choice is the REPL. It allows you to run pieces of the code and see the result without having to run the entire program. This was extremely helpful for me when it came to debugging and learning the language and concepts. It allowed me to see results of various sections of code to see what’s really going on while comparing that to what I thought it would be testing my understanding.
It also has a syntax derived from OCaml. If you want to learn a pure FP language like Haskell down the road, which most people think of as the pinnacle of FP, you will already understand some of the syntax because it also shares a lot with OCaml.
3
u/dgeurkov Dec 02 '24
https://learnyouahaskell.com/
3
u/lunjon Dec 02 '24
I love both Haskell and Elixir so I recommend both. However, Elixir is not a pure functional language like Haskell but I think learning FP programming is really fun from both. I started with Learn a Haskell for Great Good and think that's a really fun approach to learning Haskell.
3
u/p_bzn Dec 02 '24
The one which has learning materials which “click” for you.
3
u/ailof-daun Dec 02 '24
Just a quick question. Are there any FP languages that open up positions to you?
3
u/DataPastor Dec 02 '24
Generally you could start learning functional JavaScript, reading Eric Normand’s Grokking Simplicity, then the JavaScript version of the SCIP book.
If you want to learn a purely functional language, I also believe that any LISPs are quite a good choice, thanks the outstanding literature it comes with – Clojure is also a good idea in this genre.
2
u/Apart_Technology_841 Dec 02 '24
Ramda maybe?
2
u/PotentialBat34 Dec 02 '24
I learned FP with Scala and cats ecosystem. The red book is an amazing source for beginners.
Gleam and Roc looks very interesting although both do not offer any stable releases as of yet if I am not mistaken.
2
u/Key_Sea_7034 Dec 02 '24
Scala red book along with 99 problems in Scala.
2
u/Hoastl5838 Dec 02 '24
Scala=scalable+laconic!
2
u/Primary-Wave2 Dec 20 '24
Ocaml
3
u/huenhuen811 Dec 02 '24
I think the best way to learn FP is firstly try to integrate FP concepts right in your current language. Just use type first approach, try to create strong type (e.g. Amount(int) with smart constructor to validate x > 0 instead of plain int type for the attribute “transaction.amount”)