Chapter 3. Functional programming primer

 

This chapter covers

  • Core functional programming principles
  • Practical tools for working with immutable state and data structures

Before going further into the realm of Play, let’s take a detour and talk about a few functional programming fundamentals at the core of asynchronous programming in Scala. If you’re already familiar with functional programming concepts and their application in Scala, you may want to skip over this chapter or skim through it quickly. If you’re a newcomer to functional programming, this chapter will help you get up to speed with the most important principles and tools that you’ll need to understand and write asynchronous code in Scala.

3.1. A few words on functional programming

Functional programming is a vast topic, and there are entire books dedicated to the topic.[1] I won’t try to present all aspects of functional programming in just one chapter, nor will we get to the core of it. In this chapter we’ll only look at the most important concepts that you’ll need to get started with asynchronous programming: immutability, functions, and manipulating immutable collections.

1See, for example, Functional Programming in Scala by Paul Chiusano and Rúnar Bjarnason (Manning, 2014) or Scala in Action by Nilanjan Raychaudhuri (Manning, 2013).

3.2. Immutability

3.3. Functions

3.4. Manipulating immutable collections

3.5. Making the switch to a declarative programming style

3.6. Summary

sitemap