Today I would like to share with you my view on learning Scala, what approach to take, what to do and not to do in order to maximise your learnings and minimise the frustrations. The article will be full of my personal experiences — yay for real life!

So I will start by talking about my own experiences and problems I faced to then conclude with a list of DO’s and DON’T’s. Let’s do it!

The infamous learning curve

Scala is well known to have a very interesting learning curve that to me looks something like this…

Image for post

Scala learning curve, Y axis — confidence, X axis — time. Star is where I think I am :)

So in practise it could look like this:

First you learn about vars and vals, Option, Either, pattern match — all makes sense. Calling map, flatMap, maybe even fold starts making sense. You think functional programming and Scala are not as challenging as everyone says. Happy days!

Next you learn about Scala’s for loop, first you’re hesitant but you eventually grow to like it — you use it to iterate through some collections and soon you realise that for some reason it works for Option and Either too. Awesome!

…but at some stage maybe you run into a strange problem with types not matching when you use it. So you Google the problem, and there they tell you that the “for loop” is actually not a loop but a syntactic sugar for a chain of flatMaps, maps and filters and that you need a monad transformer to make it work.

…so you Google monads tranformers (and probably monads while you’re at it), you see a lot of code that looks like typos: \/ <: F[_] _ [+A] <~<, some weird way of using generics, Readers, Kleislis, some EitherT, importing cats, scalaz. There is so many sources and so many opinions you don’t know where to start learning about it. It makes very little sense… and so you get discouraged, remove the for comprehension altogether and find a workaround. But don’t give up just yet!

#functional-programming #coding #scala #learning-to-code #function

Learning Scala — 8 DON’Ts and 7 DOs
1.55 GEEK