Scala lets you write code in an object-oriented programming (OOP) style, a functional programming (FP) style, and even in a hybrid style, using both approaches in combination. I assume that you’re coming to Scala from an OOP language like Java, C++, or C#, so outside of covering Scala classes I haven’t written any special sections about OOP in this book. But because the FP style is still relatively new to many developers, I will provide a brief introduction to Scala’s support for FP in the next several lessons.
Functional programming is a style of programming that emphasizes writing applications using only pure functions and immutable values. As I wrote in Functional Programming, Simplified, rather than using that description, it’s more accurate to say that functional programmers have a strong desire to see their code as algebra — to see the combination of their functions as a series of algebraic equations. In that regard, you could say that functional programmers like to think of themselves as mathematicians. That’s the driving desire that leads them to use only pure functions and immutable values, because that’s what you use in algebra and other forms of math.
Functional Programming, Simplified is a large book, and there’s no way I can condense all of that FP knowledge into this little book, but what I can do is give you a little taste of functional programming, and show some of the tools Scala provides for developers to write functional code.