Re:A General Theory of Reactivity
by cowbertvonmoo on Friday March 27, 2015 @07:41PM
(#9279760)
My use of the word "general" was more a joke than the scope of my intent. I meant "general" in the sense of "general relativity", meaning that I’ve proposed relationships among concepts that are often understood to be unrelated. Specifically, I wanted to debunk the notions that one of these tools is categorically better than the others or that any one of them should subsume the others.
What is "reactivity"? This document defines it as "the process of receiving external stimuli and propagating events". Ok, then -- I wouldn't call it a very rigorous definition, but I can roughly grasp what the author means (more or less; I think). Now, please show me why callbacks, promises or observables are more "general" approaches to "reactivity" than, say, threads, blocking queues and blocking futures? I chose those because they happen to be the duals of the aforementioned constructs. If A is a dual of B, how can you say A is the "general theory" while B is a "cultish view"? This is what is very much rejectable.
Now that we've firmly established that A (callbacks, promises, observables) is no more general than B (threads, futures and queues) -- yet the document focuses on one while completely ignoring the other -- I express my opinion (that I can support[1]), which is that in imperative languages, constructs B are far superior to their no-more-general constructs A. That, however, unlike my previous statement (about the document confusing goals with implementations, which was a statement of fact), is just a statement of opinion.
> Observers, contracts, data-flow are real, graspable concepts and if they closely model how you want to think about a problem then they are most definitely good concepts, and it's up to the platform to have good ways to express natural thought.
Sure they are, but this document mentions some antipatterns to implementing these abstractions (which is why I said it confuses implementation with abstraction). Queues are definitely a dual of observables, and in my (and many others') opinion, they are a far superior way of implementing dataflows in imperative languages (they provide implicit backpressure, and they make concurrency clear). Same goes for futures vs callbacks, or threads vs monadic composition (threads preserve stack traces, control flow and exceptions, while monads/promises don't -- they require a shadow implementation of all those basic constructs).
I model many problems with a dataflow abstraction, but when I want to implement it, I reach for a blocking queue (aka, channel) rather than observables. Don't confuse abstraction with implementation.
[1]: https://www.usenix.org/legacy/events/hotos03/tech/full_paper...