Java Reference
In-Depth Information
classes—but we'll let the example on the first page of this chapter, which shows increased code
conciseness with Java 8, speak for itself in terms of clarity!
The Java 8 feature of passing code to methods (and also being able to return it and incorporate
it into data structures) also provides access to a whole range of additional techniques that are
commonly referred to as functional-style programming . In a nutshell, such code, called
functions in the functional programming community, can be passed around and combined in a
way to produce powerful programming idioms that you'll see in Java 8 guise throughout this
topic.
The meat of this chapter begins with a high-level discussion on why languages evolve, continues
with sections on the core features of Java 8, and then introduces the ideas of functional-style
programming that the new features simplify using and that new computer architectures favor.
In essence, section 1.1 discusses the evolution process and the concepts, which Java was
previously lacking, to exploit multicore parallelism in an easy way. Section 1.2 explains why
passing code to methods in Java 8 is such a powerful new programming idiom, and section 1.3
does the same for Streams—the new Java 8 way of representing sequenced data and flexibly
indicating whether these can be processed in parallel. Section 1.4 explains how the new Java 8
feature of default methods enables interfaces and their libraries to evolve with less fuss and less
recompilation. Finally, section 1.5 looks ahead at the ideas of functional-style programming in
Java and other languages sharing the JVM. In summary, this chapter introduces ideas that are
successively elaborated in the rest of the topic. Enjoy the ride!
1.1. Why is Java still changing?
With the 1960s came the quest for the perfect programming language. Peter Landin, famous
computer scientist of his day, noted in 1966 in a landmark article [ 2 ] that there had already been
700 programming languages and speculated on what the next 700 would be like—including
arguments for functional-style programming similar to that in Java 8.
2 P. J. Landin, “The Next 700 Programming Languages,” CACM 9(3):157-65, March 1966.
Many thousands of programming languages later, academics have concluded that programming
languages behave like an ecosystem: new languages appear and old languages are supplanted
unless they evolve. We all hope for a perfect universal language, but in reality certain languages
are better fitted for certain niches. For example, C and C++ remain popular for building
operating systems and various other embedded systems because of their small run-time
footprint and in spite of their lack of programming safety. This lack of safety can lead to
programs crashing unpredictably and exposing security holes for viruses and the like; indeed,
 
Search WWH ::




Custom Search