16
|
Preface
With functional language constructs, it is possible to automate some concurrency very
efficiently. Programs can potentially make use of multiple cores without much effort on
the side of the programmer. Functional constructs have other advantages—more elegant
expression for certain problems and often clearer readability—but it is the ability to deal
with parallelism that will ensure that functional aspects of programming are going to stay
with us for a long time to come.
Every teacher who wants to prepare their students for the future should give them some
understanding of functional aspects as well. Without it, one will no longer be able to become
a master programmer. A novice certainly does not have to master all of functional program-
ming, but a basic understanding of what it is—and what we can achieve with it—is rapidly
becoming essential.
Exactly when functional techniques should be introduced is an interesting question. We
do not believe that there is a single right answer for this; various sequences are possible.
Functional programming could be covered as an advanced topic at the end of the traditional
corpus of this book, or it could be addressed when we first encounter the topics where it
is applicable, as an alternative to the imperative techniques. It could even be covered first.
An additional question is how to treat the traditional style of programming in those areas
where functional constructs are now available: should they be replaced, or do both need to
be covered?
For this book, we recognize that different teachers will have different constraints and
preferences. Therefore, we have designed a structure that—we hope—allows different
approaches, depending on the preference of the learner or teacher.
■ We have not replaced the “old-style” techniques. We cover the new, functional approach
in addition to the existing material. Functional constructs in Java are most prominent
when working with collections of objects, and the mastering traditional approach—using
loops and explicit iteration—is still essential for any programmer. Not only are there
millions of lines of code out there that are written in this style—and will be continued
to be written in this style—but there are also specific cases where it is necessary to use
these techniques even if one generally favors the new functional constructs. Mastering
both is the goal.
■ We present the new functional-construct-oriented material in the book where we discuss
the problems that these constructs address. For example, we address functional collection
processing as soon as we encounter collections.
■ Chapters and sections covering this new material are, however, clearly marked as
“advanced,” and are structured in a manner that they can safely be skipped on first read-
ing (or left out altogether).
■ The previous two points enable different approaches to studying this book: if time per-
mits, it can be read in the sequence it is presented, covering the full scope of material—
including functional approaches as alternatives to imperative ones—as the problems are
encountered which they address. If time is short, these advanced sections can be skipped,
and emphasis can be placed on a thorough grounding in imperative, object-oriented
programming. (We should emphasize that functional is not a contradiction to object-
oriented: whether the functional material is included in the study, or the course emphasis
A01_BARN7367_06_SE_FM.indd 16 4/15/16 6:10 PM