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?
View all comments
Show parent comment
1
u/ragnese May 26 '21
Back when I last did Scala, cats was the hot new shit that the cool kids were using, but I've never used it. I've heard a bit about ZIO from here and the scala subreddit. So, I can't honestly speak to those at all.
But, if I had to just guess, I'd say they each provide some monads for Futures/IO/whatever and you have to use monad-transformers to compose different types of IO. I feel like even the most ardent FP advocate isn't going to say that monad transformers are the pinnacle of ergonomics or simplicity. So there is a cost- nothing controversial there. But the question becomes whether that cost is worth it.
I haven't watched the video (1.5 hours is a commitment I can't make at the moment). Can you explain with slightly more detail how something like ZIO is helping you with "executing requests with n parallelism, retrying, timeouts, racing and other concurrency problems"? At the end of the day, you're going to communicate with the outside world- how can an effect monad make that any safer to parallelize? If you fire off 10 requests to a REST API, they can either be done in parallel or not, but that depends entirely on your business logic. Furthermore, you can't do them transactionally (unless the API supports that, but that's outside your language anyway), so if one of them fails, you have to think about what that means for the ones that already succeeded and the ones you haven't fired off yet. I just don't see how wrapping these operations in a monad could possibly be preventing bugs for you. If it's by simply having a marker for which functions do IO, then that isn't very impressive- you can easily define your own object or module and know that "every method of FooAPI object does IO". Then you can do dependency injection with an interface or whatever to test the pure business logic functions.
So, again, I just don't understand how effect monads are actually better than non-pure implementations. What bugs is it preventing? What problems are easier to express? In my mind, effect monads are a necessary evil when you're working in a pure-functional environment to basically sneak through the enforced purity. I can't quite figure out why Scala people are purposely doing this to themselves when they don't have to. At least a pure functional language, like Haskell, can do fancy optimizations at compile time when it knows what has side-effects and what doesn't. But Scala, itself, isn't pure, so it doesn't do any of that. So we're paying a cost and I really don't know what benefit we'd be getting.