烂翻译系列之Rx.NET介绍第二版——前言

Reactive programming is not a new concept. Any kind of user interface development necessarily involves code that responds to events. Languages like SmalltalkDelphi and the .NET languages have popularized reactive or event-driven programming paradigms. Architectural patterns such as CEP (Complex Event Processing), and CQRS (Command Query Responsibility Segregation) have events as a fundamental part of their makeup. 

响应式编程并不是一个新概念。任何类型的用户界面开发都必然涉及响应事件的代码。像SmalltalkDelphi语言和.NET语言已经普及了响应或事件驱动范式。诸如 CEP (复杂事件处理)和 CQRS (命令查询责任分离)等架构模式将事件作为其基本组成部分。

Reactive programming is a useful concept in any program that has to deal with things happening.
响应式编程在任何处理正在发生的事情的程序中都是一个有用的概念。

The event driven paradigm allows for code to be invoked without the need for breaking encapsulation or applying expensive polling techniques. There are many common ways to implement this, including the Observer patternevents exposed directly in the language (e.g. C#) or other forms of callback via delegate registration. The Reactive Extensions extend the callback metaphor with LINQ to enable querying sequences of events and managing concurrency.

事件驱动范式使您无需破坏封装或应用代价高昂的轮询技术来调用代码。有很多常见的方法来实现这一点,包括观察者模式、编程语言(例如 C #)直接公开的事件或其他形式的通过委托注册的回调。Reactive Extensions(响应式扩展)使用 LINQ 扩展了回调标志,使得可以查询事件序列和管理并发性。

The .NET runtime libraries have included the IObservable<T> and IObserver<T> interfaces that represent the core concept of reactive programming for well over a decade now. The Reactive Extensions for .NET (Rx.NET) are effectively a library of implementations of these interfaces. Rx.NET first appeared back in 2010 but since then, Rx libraries have become available for other languages, and this way of programming has become especially popular in JavaScript.

.NET 运行时库已经包含了IObservable<T>和IObserver<T>接口,意味着响应式编程的核心概念已经超过十年了。.NET 的响应式扩展(Rx.NET)实际上是这些接口的实现库。Rx.NET 最早出现在2010年,但是从那时起,Rx 库已经可以用于其他语言,这种编程方式在 JavaScript 中变得特别流行。

This book will introduce Rx via C#. The concepts are universal, so users of other .NET languages such as VB.NET and F#, will be able to extract the concepts and translate them to their particular language.

本书将通过 C # 介绍 Rx。这些概念是通用的,所以其他.NET 语言,如 VB.NET 和 F# ,将能够提取这些概念,并将它们转换成特定的语言。

Rx.NET is just a library, originally created by Microsoft, but now an open source project supported entirely through community effort. (Rx's current lead maintainer, Ian Griffiths, is also the author of the latest revision of this book, and indeed the author of this very sentence.)

Rx.NET 只是一个库,最初是由 Microsoft 创建的,但现在是一个完全通过社区工作支持的开源项目。(Rx 目前的主要维护者 Ian Griffiths 也是本书最新修订版的作者,也是说这句话的人。)

If you have never used Rx before, it will change the way you design and build software. It provides a well thought out abstraction for a fundamentally important idea in computing: sequences of events. These are as important as lists or arrays, but before Rx there was little direct support in libraries or languages, and what support there was tended to be rather ad hoc, and built on weak theoretical underpinnings. Rx changes that. The extent to which this Microsoft invention has been wholehearted adopted by some developer communities traditionally not especially Microsoft-friendly is a testament to the quality of its fundamental design.

如果您以前从未使用过 Rx,它将改变您设计和构建软件的方式。它为计算机领域中一个非常重要的思想(事件序列),提供了一个成熟的抽象。它们和列表或数组一样重要,但在 Rx 之前,库或语言几乎没有直接的支持,而且支持往往是临时性的,建立在薄弱的理论基础之上。Rx改变了这一点。微软的这项发明在很多大程度上被一些非微软传统的开发者社区忠实地采用,这证明了它的基础设计的质量。

This book aims to teach you:    本书的目的是教你:

  • about the types that Rx defines    关于 Rx 定义的类型
  • about the extension methods Rx provides, and how to use them    关于 Rx 提供的扩展方法,以及如何使用它们
  • how to manage subscriptions to event sources    如何管理对事件源的订阅
  • how to visualize "sequences" of data and sketch your solution before coding it    如何可视化数据的“序列”,并在编码之前勾勒出解决方案
  • how to deal with concurrency to your advantage and avoid common pitfalls    如何以对您有利的方式处理并发,并避免常见的隐秘风险
  • how to compose, aggregate and transform streams    如何组合、聚合和转换流
  • how to test your Rx code    如何测试您的Rx代码
  • some common best practices when using Rx    使用 Rx 时的一些通用最佳实践

The best way to learn Rx is to use it. Reading the theory from this book will only help you be familiar with Rx, but to fully understand it you should build things with it. So we warmly encourage you to build based on the examples in this book.

学习Rx的最佳途径是使用它。阅读这本书中的理论只会帮助你熟悉 Rx,但是要完全掌握它,你应该用它来构建应用。因此,我们强烈建议您根据本书中的示例进行构建。

posted @ 2023-12-30 18:38  菜鸟吊思  阅读(41)  评论(0)    收藏  举报