Reactive Programming with RxJava,介绍一本书和Rx

标签(空格分隔): book RxJava


Who Should Read This Book

Reactive Programming with RxJava targets intermediate and advanced Java program-
mers. You should be fairly comfortable with Java; however, prior knowledge of reac-
tive programming is not required. Many concepts in this book relate to functional
programming, but you do not need to be familiar with it either. There are two distinct
groups of programmers that can benefit from this book;

RxJava的响应式编程适用于中高级Java工程师。你应该熟悉Java语言,但却不必要熟悉响应式编程。
这本书中的很多概念涉及到了函数式编程,但是你同样不必要去掌握它。有两种程序员能够从中受益:

  • Craftsmen who seek improved performance on the server or more maintainable code on mobile devices. If you fal into this categroy, you will find ideas and solutions to real problems, you will find ideas and solutions to real problems as well as practical advice. In this case, RxJava is just another tool that this book will help to master.
  • Curious developers who’ve heard about reactive programming or RxJava in particular and want to get a fair understanding of it. If this is you, and if you are not planning to take advantage of RxJava in production code, you will significantly broaden your horizons.

  • 目标是在服务器和移动设备上提高性能或者更好的程序扩展性的工程师,如果你属于这类人,在本书中你能发现解决问题的办法以及实用的建议。本书讲帮你掌握这一工具。

  • 对流行起来的响应式编程或RxJava感兴趣并且希望有一个清晰的认识的人,如果你属于这类人,并且不准备将RxJava的优点应用在产品代码中。你可以显著的拓宽视野。

Additionally, if you are a hands-on software architect, this book will likely help you.
RxJava influences the overall architecture of entire systems, so it is worth knowing.
But even if you are just beginning your adventure with programming, try to go through the
first few chapters, which explain the basics. Underlying concepts like transformations and
composition are quite unversal and not related to reactive programming.

除此之外,如果你是一个软件架构师,这本书可能会帮助到你。RxJava以及影响到了整个软件架构,这是值得学习的。但是如果你刚刚开始编程的道路,尝试阅读基础的前几章。基本的概念比如转换和组合是通用的概念和响应式编程没有关系。

The book was struvtured such that you will derive the most from it by reading it from cover
to cover. If you can not afford that much time, however, fell free to cherry pick only the parts that are most insteresting. If there s a concept that was introduced earlier, you will most likely find a back reference to it. Following is an overview of each chapter:

这本书是循序渐进的,顺序阅读你可以掌握大部分。如果你没有充足的时间,也可以自由的选择感兴趣的部分。如果存在前文的概念,你可以到前文寻找。下面是章节概览。

  • Chapter 1 very briefly goes through the inception of RxJava, basic concepts, and ideas(Ben).
  • Chapter 2 explains how RxJava can appear in your application and how to interact with it. This chapter is very basic, but, but understanding concepts like hot versus cold sources is tremendously important(Tomasz).
  • Chapter 3 is a whirlwind tour of many operators provided by RxJava. We will introduce you to the expressive and powerful functions that are a foundation of this library(Tomasz).
  • Chapter 4 is more practical, showing how to embed RxJava in various places across your codebase. It also touches on concurrency(Tomasz).
  • Chapter 5 is advanced, explaining how to implement reactive applications from top to bottom.
  • Chapter 6 explains an important problem of flow control and backpressure mechainisms in RxJava that support it (Tomasz).
  • Chapter 7 shows techniques of unit testing, maintaining, and troubleshooting Rx-base applications(Tomasz).
  • Chapter 8 shows a few selected applications of RxJava, especially in distributed systems(Tomasz).
  • Chapter 9 highlights future plans for RxJava 2.x(ben).

  • 第一章简要介绍了RxJava的起步,基本概念,和想法。

  • 第二章阐述了如何将RxJava集成并运用在项目中,本章非常基础,同样理解如 动态编程和静态编程是风场重要的。
  • 第三章浏览了RxJava的很多操作符。我们会展示给你基于RxJava基础库强力有效的功能。
  • 第四章偏向与实战,展示了如何将RxJava的代码应用到你的代码中。RxJava同样样涉及并发。
  • 第五章是高级,阐述了如何将响应式程序应用到各个层面。
  • 第六章阐述了重要的流处理问题和RxJava支持的反压机制。
  • 第七章演示了RxJava程序如何进行单元测试,扩展和调试技术。
  • 第八章展示了使用RxJava的项目,特别是在分布式操作系统。
  • 第九章标注了第二版RxJava的功能概览。

CHAPTER 1 Reactive Programming with RxJava

RxJava is a specific implementation of reactive programming for Java and Android that is influenced by functional programming. It favors function composition, avoidance of global state and side effects, and thinking in streams to compose asynchronous and event-base programs. It begins with the observer pattern of producer/consumer callbacks and extends it with dozens of operators that allow composing, transforming, scheduling, throttling, error handling, and lifecycle management.

RxJava is a mature open source library that has found broad adoption both on the server and on Android mobile devices. Alone with the library, an active community of developers has built up around RxJava and reactive programming to contribute to the project, speak, write, and help one another.

This chapter will provide an overview of RxJava-what it is and how it works-and the rest of this book wull take you through all the details of how to use and apply it in your applications You can begin reading this book with no piror experience with reactive programming, but we will start at the beginning and take you through the concepts and practices of RxJava so that you can apply its strengths to your use cases.

RxJava被函数式编程的影响,是响应式编程针对Java和Android的一种具体实现。支持函数式编程,规避了全局变量和负面影响,并且以流的形式去编写异步的,事件型驱动编程模式。RxJava以生产者/消费者回调的观察者模式开始,并扩展了数十个允许编写,转换,调度,限制,错误处理和生命周期管理的运算符。

RxJava是一个成熟的开源库,已经在服务器和Android设备得到了广泛的应用,围绕RxJava,响应式编程 一个活跃的开发者社区已经被建立起来,提供项目,交流,写作和互相帮助。

本章提供了RxJava的概览-是什么,如何工作,其余部分介绍了如何应用到项目的详细介绍。你可以在没有响应式编程的经验,我们从头开始会为你讲解RxJava的概念和实例以便可以将其优势应用在你的项目当中。

Reactive Programming and RxJava

Reactive programming is a general programming term that is focused on reacting to changes, such as data values or events. It can and often is done imperatively. A callback is an approach to reactive programming done imperatively. A spreadsheet is great example of reactive programming: cells dependent on other cells automatically “react” when those other cells change.

响应式编程是一种面向变化传播编程范式,例如数据值或者事件。经常以命令式的完成,通过回调完成响应式编程。电子表格就是非常好的响应式编程的例子:表格根据其他表格的变化而’变化’。

On today’s computers everything ends up being imperative at some point as it hits the operating system and hardware. The computer must be told explicitly whtat needs to be done and how to do it. Hunmans do not think like CPUs and related systems, so we add abstractions. Reactive-functional programming is an abstraction, just like our higher-level imperative programming idioms are abstractions for the underlying binary and assembly instructions. The fact that everything ends up imperative is important to remember and understand because it helps us with the mental model of what reactive-functional programming is addressing and how it ultimately executes-there is no magic.

现代的计算机在某一时刻会将运行在操作系统和硬件上的所有的东西命令化。计算机必须被确切的告知么,如何去做。人类的思维不同于CPUs和操作系统,因此我们增加抽象。响应式编程是一种抽象,类似于我们更高层次的命令式编程是底层二进制和汇编语言的抽象。事实上,所有最终都是指令,记住和理解是非常重要的,他可以帮助你建立响应式编程范式是如何寻址和最终的指令没有魔法。

Reactive-functional programming therefore is an approach to programming-an abstraction on top of imperative systems-that allows us to program asynchronous and event-driven use cases without having to think like the computer itself and imperatively define the complex interactions of state, particularly across thread and network boundaries. Not having to think like the computer is a useful trait when it comes to asynchrony and event-driven systems, because concurrency and parallelism are involved, and these are very challenging characteristics to use correctly and efficiently. Within the Java community, the boooks Java Concurrency in Practive by Brian Goetz and Concurrent Programming in Java by Doug Lea(Addison-Wesley), and forums, and communities since I started using RxJava has convinced me even more than before of how difficult it really is to write high-performance, efficient, scalable, and correct concurrent software. And we haven’t been brought in distributed systems, which take concurrency and parallelism to another level.

响应式函数式编程是一种在命令式编程系统之上的抽象,他允许我们异步和事件驱动编程,而不必考虑计算机本身和命令式编程在状态交互,特别是跨线程和网络编程。因为并发和并行涉及到异步和事件驱动系统,所以不必像电脑一样去思考如何实现,正确有效的使用非常具有挑战性。自从我开始使用Rxjava,比以前更加相信在Java论坛,书籍《Java并发性》和《Java并发编程》和一些论坛,社区中,编写高性能,可扩展和正确的并发软件真的是很困难。我们还没有进入分布式系统,它将并发和并行提升到另一个层次上。

So, the short answer to what reactive-functional programming is solving is concurrency and parallelism. More colloquially, it is solving callback hell, which results from addressing reactive and asyncronous use cases in an imperative way. Reactive programming such as that implemented by RxJava is influenced by functional programming and uses a declarative approach to avoiding the typical pitfalls of reactive-imperative code.

所以,简要的说,响应式函数式编程就是解决了并发和并行。更通俗的说,它解决了结果返回通过寻址和命令式的异步编程的回调地狱。响应式编程范式比如RxJava,被函数式编程影响,使用声明式编程避免典型的响应式编程的陷阱。

When You Need Reactive Programming

Reactive programming is useful in scenarios such as the following:

  • Processing use events such as mouse movement and clicks, keyboard typing, GPS signals changing over time as users move with their device, device gyroscope signals, touch events, and so on.
  • Responding to and processing any and all latency-bound IO events from disk or network, given that IO is inherently asynchronous(a request is made, time passes, a response might or might not be received, which the tiggers further work.
  • Handling events or data pushed at an application by a producer it cannot control(system events from a server, the aforementioned user events, signals from hardware, events triggered by the analog world from sensors, and so on).

响应式编程在下面的情景是适用的:

  • 处理用户事件,比如鼠标移动和点击,键盘编辑,GPS信号随着时间的变化当用户移动自己的设备,陀螺仪信号,触摸时间等等。
  • 响应和处理任何磁盘或网络相关的异步IO事件(执行一个请求,时间执行,一个响应可能或者不能被收到,然后继续执行下一步工作)。
  • 处理被程序生产者推出的不可控时间或者消息(服务器发出的系统消息,上面提到的用户事件,硬件信号,传感器模拟事件的触发等等)。

Now, if the code in question is handling only on event stream, reactive-imperative programming with a callback is going to be fine, and bringing in reactive-functional programming is not going to give you much benefit. You can have hundreds of different event streams, and if they are all completed indendent of one another, imperative programming is not likely to be a problem. In such straightforward use cases, imperative approaches are going to be the most efficient because they eliminate the abstraction layer of reactive programming and stay closer to that for which current operating systems, languages, and compilers are optimized.

现在,如果所涉及处理事件流的代码,带有回调的响应式编程很不错,但是响应函数式编程并不会给你带来太多好处。你可以拥有数百个不同的事件流并且他们都是独立完成的,命令式编程不会有问题。在这种直接的情况下,命令式的编程时最有效的,因为他们没有响应式编程的抽象层并且容易被操作系统,语言和编译器优化。

If your program is like most through, you need to combine events(or asynchronous responses from functions or network calls), have conditional logic interacting between them, and must handle failure scenarios and resouce cleanup on any and all of them. This is where the reactive-imperative approach begins to dramatically increase in complexity and reactive-functional programming begins to shine. A nonscientific view I have come to accept is that reactive-functional programming has an initially heigher learning curve and barrier to entry but that the ceiling for complexity is far lower than with reactive-imperative programming.

如果你的程序是顺序的编程,你需要合并事件(或者来自函数和网络请求的异步响应),具有条件逻辑交互,而且必须处理失败的场景并且对其中任何一个进行清理。这时响应式编程范式开始急剧的复杂起来,但响应式函数式编程开始绽放光芒。我开始接受一个非科学的观点,响应式函数式编程有更高的起步曲线和入门的困难,但是编程难度比响应式编程要小很多。

Hence this is where the tagling fo Reactive Extensions(Rx) in general and RxJava specifically comes from, “a library for composing asynchronous and event-based programs”. RxJava is a concrete implementation of reactive programming principles influenced by functional and data-flow programming. There are different approaches to be “reactive,” and RxJava is but one of them. Let’s dig into how it works.

因此,Rx系列有一个总的标语,“一个为异步和事件编程的库”。RxJava是一个被函数式和数据流编程影响的响应式编程范式的具体实现。和”一般响应式“有一些实现的区别,但是RxJava属于其分支,让我们看看RxJava如何工作。

Reactive Programming with RxJava,介绍一本书和Rx相关推荐

  1. 响应式编程Reactive Programming

    作者: @andrestaltz 翻译:@benjycui.@jsenjoy 作者在原文后回答了不少人的疑惑,推荐一看. 在翻译时,术语我尽量不翻译,就算翻译了也会给出原文以作对照.因为就个人观察的情 ...

  2. 什么是反应式编程? 这里有你想要了解的反应式编程 (Reactive programming)

    理解反应式编程 你曾有过订阅报纸或者杂志的经历吗?互联网的确从传统的出版发行商那儿分得了一杯羹,但是过去订阅报纸真的是我们了解时事的最佳方式.那时,我们每天早上都会收到一份新鲜出炉的报纸,并在早饭时间 ...

  3. 设计模式--谈谈Reactive Programming 响应式编程

    1. Reactive Programming 响应式编程 1.1. 什么是什么是响应式编程 维基百科的解释如下: In computing, reactive programming is an a ...

  4. Principles of Reactive Programming 之Actors are Distributed (1)

    week7中的前两节课的标题是"Actors are Distributed",讲了很多Akka Cluster的内容,同时也很难理解. Roland Kuhn并没有讲太多Akka ...

  5. 未来:spring响应式编程 Hands-On Reactive Programming in Spring 5(二)------Basic Concepts

    看完这篇文章你会有很大收获! 好学近乎知,力行近乎仁,知耻而后勇. The previous chapter explained why it is important to build reacti ...

  6. 未来:spring响应式编程 Hands-On Reactive Programming in Spring 5 ,为啥需要响应式编程

    Why Reactive Spring? 为什么 使用响应式 的spring In this chapter, we are going to explain the concept of react ...

  7. 什么是响应式编程(Reactive Programming)

    1.什么是响应式编程(Reactive Programming) Wikipedia上这样说: In computing, reactive programming is an asynchronou ...

  8. 响应式编程(Reactive Programming)是什么?

    简介 在计算中,响应式编程(Reactive Programming)是一种面向数据流和变化传播的声明式编程范式. 这意味着可以在编程语言中很方便地表达静态或动态的数据流,而相关的计算模型会自动将变化 ...

  9. reactive programming

    In computing, reactive programming is a declarative programming paradigm concerned with data streams ...

最新文章

  1. opencv对图像是软解码_在图像识别上深度学习和opencv有什么不同啊,我只用过opencv,对深度学习不了解...
  2. 太空将成为数据中心冷却新前沿
  3. DNS子域授权及view(三)
  4. [转] C#异步操作
  5. 贪心 Codeforces Round #273 (Div. 2) C. Table Decorations
  6. 组策略:交互式登录:不显示最后的用户名
  7. 一款APP设计的从0到1之:Android设计规范篇(转载)
  8. java spring 数据库_JAVA - SpringBoot项目引用MyBatis操作数据库
  9. jdk1.6-64下载
  10. 微软服务器同步软件,SkyDrive 本地同步工具(SkyDrive Synchronizer)
  11. 归纳学习(Inductive Learning),直推学习(Transductive Learning),困难负采样(Hard Negative)
  12. python绘制图像并渲染_用Python的Matplotlib模块绘制3D图像
  13. 见证成长,PostgreSQL线上沙龙感谢有你
  14. 深入浅出——MVP模式
  15. 【推荐系统】协同过滤
  16. php去下划线,html怎么去除字体下划线?去除字体下划线方法
  17. Win7(Win10)+Ubuntu18.04(16.04)双系统安装心得
  18. Spring Cache,从入门到真香
  19. 计算机组成原理第八章知识导图,计算机组成原理第八章课后部分答案图文.pdf...
  20. JAVA定时任务时间配置

热门文章

  1. 互动直播系统源码 直播系统源码
  2. 【UN-JS-工具类】懒加载的实现 -- 两种方式 --- 一种5行JS实现懒加载
  3. 修改Mendeley的界面字体
  4. 下列实型常量不符合c语言,C语言程序设计考试题答案
  5. 华为AP4050DN瘦转胖(MAC版)
  6. Blender入门级使用
  7. 编程小知识之 Lua split 函数
  8. 如何加快 Synology Drive 的同步过程?(外网速度极慢)
  9. 咦,咋没加volatile,变量也可见的呢?
  10. TCP/IP第一卷读书笔记