Java 8 in Action

Raoul-Gabriel Urma

出版时间

2014-08-28

ISBN

9781617291999

评分

★★★★★
书籍介绍

While the term "lambda expression" may sound abstract and academic, Java 8 Lambdas can have a big impact on how you program every day. In simplest terms, a lambda expression is a function—a bit of code—that you can pass to another method as an argument. Thus, you can cope with changing requirements by using a behavior, represented by a lambda, as a parameter. Java 8's functional programming features, like lambdas and the new Stream API that enables a cleaner way to iterate through collections, can help you write concise, maintainable code that scales easily and performs well on multicore architectures.

Java 8 in Action is a clearly-written guide to Java 8 lambdas and functional programming in Java. It begins with a practical introduction to the structure and benefits of lambda expressions in real-world Java code. The book then introduces the Stream API and shows how it can make collections-related code radically easier to understand and maintain. Along the way, you'll discover new FP-oriented design patterns with Java 8 for code reuse, code readability, exception handling, data manipulation, and concurrency. For developers also exploring other functional languages on the JVM, the book concludes with a quick survey of useful functional features in Scala.

Raoul-Gabriel Urma has worked as a software engineer for Oracle's Java Platform Group, Google's Python team, Ebay, and Goldman Sachs as well as for several startup projects. He's currently completing a PhD in Computer Science at the University of Cambridge and is a regular speaker and instructor. Mario Fusco is a senior software engineer at Red Hat working on Drools, the JBoss ...

(展开全部)

AI导读
核心看点
  • 深入讲解Lambda表达式与Stream API
  • 涵盖Optional、CompletableFuture等新特性
  • 提供Java 8代码重构与并行处理实战
适合谁读
  • 希望掌握Java 8新特性的Java开发者
  • 需要重构旧代码以提升简洁性的程序员
  • 对函数式编程思想感兴趣的初学者
读前提醒
  • 建议结合书中代码示例动手实践
  • 第四部分函数式思想较深,可酌情略读
  • 重点理解Stream API与并行流的使用
读者共识
  • 讲解通俗易懂,是Java 8入门首选
  • 内容全面,覆盖JDK 8所有核心新特性
  • 侧重实战应用,原理性知识讲解较少

本导读基于书籍简介、目录、原文摘录、短评和书评生成,不等同于全文精读。

精彩摘录
  • "In fact, using synchronized across multiple processing cores is far more expensive than we often expect, because synchronization forces code to execute sequentially, which works against the goal of parallelism."
  • "同步API与异步API 同步API其实只是对传统方法调用的另一种称呼:你调用了某个方法,调用方在被调用方 运行的过程中会等待,被调用方运行结束返回,调用方取得被调用方的返回值并继续运行。即 使调用方和被调用方在不同的线程中运行,调用方还是需要等待被调用方结束运行,这就是阻 塞式调用这个名词的由来。 与此相反, 异步API会直接返回,或者至少在被调用方计算完成之前,将它剩余的计算任 务交给另一个线程去做,该线程和调用方是异步的——这就是非阻塞式调用的由来。执行剩余 计算任务的线程会将它的计算结果返回给调用方。返回的方式要么是通过回调函数,要么是由 调用方再次执行一个“等待,直到计算完成”的方法调"
  • "并行——使用流还是CompletableFutures? 目前为止,你已经知道对集合进行并行计算有两种方式:要么将其转化为并行流,利用map 这样的操作开展工作,要么枚举出集合中的每一个元素,创建新的线程,在CompletableFuture内对其进行操作。后者提供了更多的灵活性,你可以调整线程池的大小,而这能帮助 你确保整体的计算不会因为线程都在等待I/O而发生阻塞。 我们对使用这些API的建议如下。 ❑如果你进行的是计算密集型的操作,并且没有I/O,那么推荐使用Stream接口,因为实 现简单,同时效率也可能是最高的(如果所有的线程都是计算密集型的,那就没有必要 创建比处理器核数更多的线程"
  • "第二,要求它是 Predicate<Apple>(目标类型)对象的第二个正式参数"
  • "名叫开放服务网关协议(open service gateway initiative, OGSi)"
作者简介
Raoul-Gabriel Urma has worked as a software engineer for Oracle's Java Platform Group, Google's Python team, Ebay, and Goldman Sachs as well as for several startup projects. He's currently completing a PhD in Computer Science at the University of Cambridge and is a regular speaker and instructor. Mario Fusco is a senior software engineer at Red Hat working on Drools, the JBoss rule engine. He created the open source library lambdaj, an internal Java DSL for manipulating collections in a functional way. Alan Mycroft is Professor of Computer Science at the University of Cambridge, where he researches programming languages, their semantics, optimization and implementation. He is a co-founder and Trustee of the Raspberry Pi Foundation. You can follow Raoul and Mario on Twitter at @raoulUK and @mariofusco.
目录
Table of Contents
PART I: FUNDAMENTALS
1 Java 8: why should you care? - FREE
2 Passing code with behavior parameterization - AVAILABLE
3 Lambda expressions - AVAILABLE

显示全部
用户评论
其实应该叫「FP in Java 8」更合适,CompletableFuture类大概是目前最实用的类了。
第4部分和附录看不下去,暂时放弃。函数式思想是重点,学习scala时再谈。
这个书 讲了java 8 新的几个特性,挺好的。看完基础可以看这个。 讲了lambda, stream, interface default method 这些新的东西。
函数式编程的讲解非常清晰。感谢
在java10发布的时候复习一下
写得真的细!JDK8的所有新知识点都说清楚了。 虽然要用17了,但8仍然没用利索。
Stream + Optional, improve readability and flexibility of java code
条理清楚,如果想基于java学习函数式编程,推荐这本。
有的地方为了追求浅显而放弃了系统,比如completableFututure那章,看的时候顺着作者思路都明白,但是实际工作中用的时候,还得去看文档。适合初次接触java8的人,后续体系化的理解需要借助其他资料。
收藏