Ari King wrote:
Most of the threads here discuss how/when FP is a better implementation choice than OO. Are there any circumstance where the opposite holds?
The book is organized into four parts. In part 1, we proceed from a startling premise--that we restrict ourselves to constructing programs using only _pure_ functions with no _side effects_ such as reading from files or mutating memory. In the first chapter of part 1 we will explain exactly what that means, and give you some idea of the benefits you might reap from that. This idea, of programming with pure functions, leads to a very different way of writing programs than you may be used to. We therefore start from the very beginning, relearning how to write the simplest of programs in a functional way. The chapters in part 1 give an overview of fundamental techniques like how to organize small functional programs, define purely functional data structures, handle errors, and deal with state.
Building on this foundation, part 2 is a series of tutorials on _functional design_. We work through some examples of practical functional libraries, laying bare the thought process that goes into designing them.
While working through the libraries in part 2, it will become clear to you that these libraries follow certain patterns and contain some duplication. This will highlight the need for new and higher abstractions for writing more generalized libraries, and we introduce those abstractions in part 3. These are very powerful tools for reasoning about your code. Once you master them, they hold the promise to make you extraordinarily productive as a programmer.
Part 4 then bridges the remainder of the gap towards writing real-world applications that perform I/O (like working with databases, files, or video displays), and make use of mutable state, all in a purely functional way.
Throughout the book, we rely heavily on programming exercises, carefully sequenced to help you internalize the material. To understand functional programming, it's not enough to learn the theory abstractly. You have to fire up your text editor and write some code. You have to take the theory that you have learned and make it a part of yourself, and of your work.
This book is intended for readers with at least a little bit of programming experience. We had a particular kind of reader in mind while writing the book--an intermediate-level Java or C programmer who is curious about functional programming. But we believe this book is well suited for programmers coming from any language, at any level of experience.
Prior expertise is not so important as motivation and curiosity. Functional programming is a lot of fun, but it's a challenging topic. It may even be especially challenging for the most experienced programmers, because it can be such a different way of thinking than they might be used to. No matter how long you have been programming, you must come prepared to be a beginner once again.
This book does not require any prior experience with Scala, but we won't spend a lot of time and space discussing Scala's syntax and language features. Instead we will introduce them as we go, with a minimum of ceremony, mostly as a consequence of covering other material. These minimal introductions to Scala should be enough to get you started with the exercises. If you have further questions about the Scala language, you should supplement your reading with another book on Scala[1] or look up specific questions in the Scala language specification.[2]
[1]: http://www.scala-lang.org/documentation/books.html
[2]: http://www.scala-lang.org/files/archive/nightly/pdfs/ScalaReference.pdf