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

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.

主站蜘蛛池模板: 固镇县| 丹棱县| 锡林浩特市| 秦皇岛市| 宾阳县| 丰城市| 中江县| 三亚市| 铜山县| 弥勒县| 彰化市| 哈尔滨市| 公主岭市| 绥中县| 砚山县| 清远市| 海阳市| 丹江口市| 榆林市| 禹城市| 章丘市| 余庆县| 海阳市| 光山县| 西华县| 诸城市| 通城县| 确山县| 奈曼旗| 福泉市| 崇明县| 吉首市| 天水市| 抚松县| 梁平县| 泰兴市| 阳东县| 揭东县| 始兴县| 陆川县| 富顺县|