r/functionalprogramming • u/3rdRealm • Oct 23 '21
Question Which Language?
Here is my story:
A few months ago, I started gaining interest in the functional programming paradigm, and I wanted to start learning. I started off with Haskell, which I am sure most people do. But, nothing seems to click. I was learning with Phillipp Hagenlocher's YouTube series, which seems to be a good place to start. Even though I don't understand everything, I can tell he is explaining well. Anyways, I started losing it after video 5 or so. I really just did not get what he was talking about.
Recently, I started trying out other languages, like Clojure, Scala, Elm, Elixir, Racket, and others. Before I go deeper, I want to make sure I am learning something useful and worthwhile. Elixir and Elm seem to be interesting, and I really like Lisp syntax, so Clojure and Racket might be good choices as well.
Or should I go to more imperative languages that have good ability in functional programming like Rust, Python, Nim, Go, and others?
I am not looking for a job in these languages, and am just learning as a hobby.
5
u/mwgkgk Oct 23 '21
Try Exercism/hackerrank. Elixir exercises specifically was the first thing that helped me snap into functional mode of thinking, as it's based on Erlang's pretty rigid pseudo-Prolog model of FP. Exercism's recent 3.0 update adds a "Learning mode" for many of the languages, which has exercises grouped around learning concepts.
4
u/Collaborologist Oct 23 '21
Clojure
4
u/ventuspilot Oct 24 '21
I'd suggest you consider Common Lisp as well. E.g. sbcl is a free high-performance actively maintained implementation of Common Lisp.
3
u/pfurla Oct 24 '21
What do you missing or can you elaborate on "But, nothing seems to click."?
I think this particular course doesn't elaborate enough the points where Haskell is different from imperative languages, like
Pet peeves of mine are guards and list-comprehension, they are at best distractions to students.
18
u/bas_mh Oct 23 '21
IMO the best way to learn functional programming is by using a language that is primarily functional. In the end, I find it unlikely that you will FP to its potential if you stick only with 'imperative' first languages.
Given your explanation I would recommend to stick with Haskell for a bit, but start building something. The best way for something to click is simply experience IMO. If you still feel that it does not click yet I suppose you could something that is less strict like Clojure or Elixir.
13
u/HellsMaddy Oct 23 '21 edited Oct 23 '21
For me, the language that made things 'click' was OCaml. As compared to Haskell, OCaml feels far less magical to me. There’s an excellent free textbook / video lecture course for learning OCaml from Cornell University.
Learning OCaml can also kill two birds with one stone because it’s extremely similar to Microsoft’s F#, so if the .NET ecosystem interests you then that’s a direction you could go later on.
If OCaml piques your interest, and if you have any interest in front-end web development, I also recommend you check out ReScript (formerly ReasonML).
ReScript is essentially "Functional JavaScript", similar to Elm. It’s built on top of the OCaml compiler and is similar in syntax and semantics (ReasonML started out as an alternative syntax for OCaml but ReScript seems to be trying to cut that association), so learning OCaml will help you a bit with learning ReScript.
I’m building a complex project with ReScript right now and having a lot of fun.
5
u/jmhimara Oct 23 '21
This is an excellent course for OCaml: https://cs3110.github.io/textbook/cover.html .
I think OCaml (or the very similar F#) is a great start. Racket is also pretty good and has great documentation, though it doesn't necessarily focus as much on FP (but it totally supports that style).
7
u/jimeno Oct 23 '21
I was in the same situation some months ago, and in the end, after A LOT of back and forth between like 5 different languages, I chose F#. Why? Because:
Elmish);The dynamically typed languages like clojure/elixir were cool, but ultimately the type inference is too good to pass up, specially when learning. In case you want a dynamic language, I'd personally pick elixir; the programming style is the same, abusing atoms and tuples/maps, but I find lisps very hard to read (and I don't know the JVM)
3
u/downrightcriminal Oct 25 '21
I'd recommend Elixir, it has the best tooling out of any functional language. Solve exercism track with Elixir.
Next recommendation would be Elm, it works in the browser, and really easy to get started.
After that, I'd recommend Haskell for some hardcore FP.
Pick any of the above, or other recommendations in the thread, but do solve exercism track with the one you choose.
Don't pick a non-FP language to learn FP (like JS, C#), learn FP in an FP language and then apply the principles to non-FP ones.
3
u/SnooCompliments7527 Oct 26 '21 edited Oct 26 '21
I would try Racket. There is a lot of entry-level friendly material around on the web for Racket and it can be a nice way to eventually transition to Clojure.
There are also a ton of Racket journal articles.
Neither of these languages are as fanatically FP as Haskell but that is what makes them more approachable.
I would also add there are a lot of fun features that Racket has (first-class composable continuations, hygienic macros) that are not FP but probably nice to explore.
2
u/quote-nil Oct 23 '21
They are all worthwhile. What are your main inclinations? I too started learning Haskell, but eventually my math background led me to Agda.
A really nice book is The Little Schemer, and since you like the lisp syntax, it may serve you well
2
u/ojledojle Oct 24 '21
The language doesn't matter that much, try to learn the concepts and the functional approach, so any functional language would be fine at the end.
The YouTube videos didn't work well for me too. This is what I went with instead:
1
u/-----____L____----- Nov 18 '21
What's your background? If you know JS and have done frontend I would recommend Elm. It will help you understand things like monads, functors, and functional design overall... It would be an incremental step in a sense, and after that, you can try something like Haskell.
3
u/[deleted] Oct 23 '21
[removed] — view removed comment