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

Dataflow programming

The previous example has an interesting property: the value of mean clearly has a dependency on the contents of sum.

Dataflow programming makes this relationship explicit. It models applications as a dependency graph through which data flows from operation to operation, and as values change, these changes are propagated to its dependencies.

Historically, dataflow programming has been supported by custom-built languages such as Lucid and BLODI, and as such, have been leaving other general-purpose programming languages out.

Let's see how this new insight would impact our previous example. We know that once the last line gets executed, the value of mean is assigned and won't change unless we explicitly reassign the variable.

However, let's imagine for a second that the pseudo-language we used earlier does support dataflow programming. In that case, assigning mean to an expression that refers to both sum and count, such as sum / count(numbers), would be enough to create the directed dependency graph that's shown in the following diagram:

Note that a direct side effect of this relationship is that an implicit dependency from sum to numbers is also created. This means that if the numbers change, the change is propagated through the graph, first updating sum and then, finally, updating mean.

This is where Reactive Programming comes in. This paradigm builds on dataflow programming and change propagation to bring this style of programming to languages that don't have native support for it.

For imperative programming languages, Reactive Programming can be made available via libraries or language extensions. We don't cover this approach in this book, but should the reader want more information on this subject, please refer to dc-lib (see https://code.google.com/p/dc-lib/) for an example. It is a framework that adds Reactive Programming support to C++ via dataflow constraints.

主站蜘蛛池模板: 竹北市| 乡城县| 马鞍山市| 西青区| 青州市| 孟州市| 孟州市| 治县。| 广汉市| 禄丰县| 德保县| 湘乡市| 锡林郭勒盟| 黎川县| 高邮市| 高邮市| 丽江市| 景德镇市| 绥芬河市| 土默特右旗| 镶黄旗| 城固县| 安福县| 乃东县| 如皋市| 即墨市| 富川| 六枝特区| 广南县| 昭苏县| 祁门县| 西昌市| 苗栗市| 西丰县| 鄂托克前旗| 卫辉市| 昌宁县| 酉阳| 黔东| 高碑店市| 阜平县|