官术网_书友最值得收藏!

Summary

In this chapter, we introduced many of the features that constitute a functional programming language. These included functions and the idea that they can be combined in more powerful ways than are possible in an imperative type language.

Functional languages frequently allow the expression of program logic using a fluent style where function invocations build upon each other. The expression of parallel behavior is simplified in functional programming languages allowing better optimization of code.

An important goal of functional programs has been to minimize the use of mutable data and avoid side effects. This also promotes certain optimizations and makes functional code more maintainable. Recursion is central to functional programming languages, and we hinted at how it can be used. The use of optional types and monads were also introduced.

Java 8 introduced several new language features that support the use of functions. These include lambda expressions, which underlie functions and functional interfaces with type inferences. The introduction of default methods enables the newer functional techniques to be used with older interfaces and classes. Method and constructor references provide a way of using these constructs where lambda expressions are expected.

With many of these topics, we provided simple examples of how Java can support these concepts. The remainder of the book provides a much more detailed discussion of how Java can be used.

Java is not a pure functional programming language. However, it supports many functional style techniques, which a knowledgeable developer can use. The use of these techniques require a different way of thinking about and approaching problems. We will convey these techniques in this book starting with a more detailed discussion of functions in Chapter 2, Putting the Function in Functional Programming.

主站蜘蛛池模板: 兴义市| 牙克石市| 扶风县| 南澳县| 顺平县| 高邮市| 沾化县| 文成县| 金堂县| 苏尼特左旗| 吉首市| 牟定县| 太康县| 平远县| 石台县| 安泽县| 马公市| 潜江市| 威远县| 达尔| 滨州市| 建水县| 宁晋县| 淮北市| 西藏| 尖扎县| 博客| 富民县| 哈密市| 星座| 襄樊市| 沧州市| 海宁市| 锦州市| 和顺县| 天水市| 通州区| 内乡县| 漯河市| 海口市| 宁南县|