This is part 2 of a 3 part series to learn Scala. We will learn what is Functional programming and introduce you to a few functional programming concepts
So you know of functions in a programming language. But what is a functional programming language? It is exactly the same as creating functions in your code but with few superpowers (and some limitations)
Superpower: Functions can be used everywhere — functions can be stored in a variable, functions can be a parameter to another function, functions can be the return value. This sounds typically possible in other programming languages — however the key difference is in other languages, functions are processed and stored to a variable as soon as they are assigned. However, in Scala, they are stored as a programming construct with no inputs passed yet.
Limitation: We mentioned that in Scala, your code goes to data — but this happens one function at a time (and not your entire code). That means there is no way your function has access to the rest of your code. This eliminates the concept of global variables and the persistence of processed info.
Here are 6 key functional programming concepts:
Like we mentioned earlier, Scala is Functional Programming (FP)+ Object-oriented (OO) programming. So let’s review some OO concepts — Class (Generic/Abstract), Object
Now that we learnt about the FP & OO concepts, we will learn how a typical Scala code would like in part 3