- Hands-On Reactive Programming with Clojure
- Konrad Szydlo Leonardo Borges
- 297字
- 2021-07-02 14:03:51
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.
- 揭秘卒中后非運(yùn)動障礙:失眠 抑郁 認(rèn)知障礙
- 健康快車的故事
- 醫(yī)學(xué)統(tǒng)計(jì)學(xué)實(shí)戰(zhàn)指導(dǎo)
- 白內(nèi)障及眼科整形手術(shù)精選
- Hands-On Functional Programming with C++
- 眼科手術(shù)操作與技巧(第2版)
- 圖說災(zāi)難逃生自救叢書:海嘯
- 意識障礙康復(fù)評定與治療學(xué)
- 放射診斷學(xué)讀片:北京協(xié)和醫(yī)院放射十年影像薈萃
- 學(xué)習(xí)睡覺
- 針灸學(xué)基本概念術(shù)語通典(上下冊)
- 結(jié)直腸癌老年患者治療與康復(fù)
- 龍層花健脊防癌方案
- 冠心病介入處置爭鳴
- 名老中醫(yī)治療優(yōu)勢病種診療方案選