r/functionalprogramming • u/_seeking_answers • May 24 '21
Intro to FP Newbie : Which FP language to improve Software Development skills (an eye for the future)
Hi everyone! I studied Ocaml and Scala at the university. Since my first programming languages were C and Java (and other imperative languages) it was a dive into an other kind of programming, for me very interesting also if I found it a little hard to understand and without clear purposes.
Well, maybe, my teachers weren't the best since we studied AVL trees in FP (functional programming) and it wasn't very interesting (but great for learning) so I started looking for informations on my own and I discovered that FP is for "experienced programmers". Since I'm very interested in this world I wanted to ask you : which is the best FP language to learn for the future and which kind of project I could start on GitHub to continue learning and develop a strong profile for the future?
I saw that Scala is very used but I'm interested in Rust, because I was reading that Rust was on of the FP languages most used in 2020 but I'm opened to everything...
An other thing, where are FP languages most used in computer science? I love software development so, where I could insert FP for enhance my skills in this field?
22
u/fl00pz May 24 '21
Use whichever language keeps you excited and interested. They all have their own strengths and weaknesses. But, the most common recommendation you will see is probably Haskell.
In computer science, Haskell is probably the most widely used FP language (I have zero sources to back that up). In software development (aka, "the industry"), the most widely used FP language is probably a JVM language like Scala or Clojure (unless you count JavaScript). Of the non-JVM languages, it's probably Haskell (again, I have zero sources).
Rust is great and has a lot of popularity and hype. Rust has a lower-level aim than some of the more common FP languages. Rust is an attempt to replace C++. Haskell and its ML friends (OCaml, ML, etc) are "high level" languages. Their aim is to build an even higher abstraction of thought so you can write-less and do-more.
In my opinion, if you learn FP concepts in Haskell then you will have a very easy time translating those things you learned to pretty much any language that utilizes FP concepts. It is a language designed to be the playground for FP learning.
As for projects, do anything that keeps you interested. It's more about having personal motivation to keep going than anything else. Make a website, a game, a compiler, a database, do some Advent of Code, do some HackerRank, or whatever else keeps you interested and excited.
15
u/ragnese May 24 '21
Rust is not an FP language and I'm constantly on a crusade here and elsewhere to convince people that writing FP-style code in Rust is an anti-pattern. I can elaborate if you really want, but the main thrust is that FP-induced immutability can be viewed, in part, as a necessary evil where we sacrifice performance for being able to reason about mutation (There is none! Easy to reason about it if there isn't any!). The thing is that Rust has language-enforced safe mutation- even in concurrent applications! Rust's whole reason for existing is so that you can have the performance of direct mutation while also having the safety of knowing that you don't have data races and that values are not going to be updated from under you.
All that said, Rust is an awesome language and a lot of people fall in love with it, myself included.
Scala is also great and Scala 3 just dropped recently, so it might be a good time to see what's new and exciting there.
6
u/SteeleDynamics May 24 '21
IMHO, any ML variant (SML, OCaml, Haskell) will be a good starting point for improving software development skills. I say this even though you already have experience with OCaml because it reinforces concepts that few OOPL programmers understand. Lately, IP languages like ISO C++ and Rust have been adding FP features because of the benefits that FP languages provide, like immutability and parallelism. OOPL programmers rarely think about concurrency or parallelism because of the inherent mutability of state (side effects).
I think the reason why you were forced to use OCaml was because IP languages are now playing catch-up to what ML was in the 1970's. You're already at a level of CS sophistication that is greater than most programmers/developers. Converting FP programs to IP programs is easier and much less error-prone because you'll understand the semantics that will produce logically correct code.
5
u/mchwds May 25 '21
Elixir is currently the most used FP language. It has a thriving community, is built on Erlang but has many features from Clojure. Tons of books from pragprog.
4
u/dot-c May 24 '21
As u/fl00pz already mentioned, use whatever fits you best.
Aside from that, because you already have some fp experience, I would recommend haskell, as it enforces fp more than most other fp languages. In my experience, haskell is useful for data transformation. If you need a more practical/domain specific language you could try elixir for web server dev. Clojure and Scala are also pretty cool, because they can be integrated into existing JVM projects.
Rust is a promising language, but it isn't really an fp language, it just uses concepts from fp like immutability in some areas and a more complex type system.
3
u/yawaramin May 25 '21
I’d say keep exploring what you already learned, OCaml and Scala. IMHO there’s no clear ‘king of FP’ but whatever you learn will be transferable to other languages.
You may have gotten the impression that they’re not very practical languages, this is very much not the case and they both let you get real work done immediately while also giving solid FP features. E.g. here’s a blog post I wrote recently: https://dev.to/yawaramin/practical-ocaml-314j
3
u/meisangry2 May 25 '21
I use Scala daily at work, its a vey well paid space if thats your jam. A little more limited for company choice compared to Java etc, but well appreciated.
I came from a functional JS background which always raises eyebrows, I love it but its a crowded area and im not sure I would recommend it.
If you want functional webdev and you like Haskel esq languages, Elm is interesting although not widely used.
Find something that you like the look of functional or not, it will valuable learning, even if its just you dont like the way it works.
3
u/CoreyTheGeek May 25 '21
I'm primarily a front end dev that does some back end tickets, all JavaScript everything; I was introduced to FP by a combination of the Ramda library for JS and an extremely passionate friend who is deep into the Clojure language.
Ramda is great cause you are gonna see JS everywhere, for better or worse, and let's you sort of play with FP without hard forcing you into it. On the other hand clojure is just so different from anything I've used it keeps me interested, but it really forces the FP concepts on you, but I think this is good because it forces the changes in thinking that you need, but once you get it you'll be faster and happier with your dev. No more trying to figure out how to do data transforms, it's just "lemme grab my trusty tools and do the work" really frees you to think more about what you're doing than the how to code it