Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is ReactiveX considered reactive programming? [closed]

Tags:

From ReactiveX introduction page:

It is sometimes called “functional reactive programming” but this is a misnomer. ReactiveX may be functional, and it may be reactive, but “functional reactive programming” is a different animal. One main point of difference is that functional reactive programming operates on values that change continuously over time, while ReactiveX operates on discrete values that are emitted over time.

Meanwhile, from Wikipedia's Functional Reactive Programming page, ReactiveX is listed in the "Implementations" section:

Implementations[edit]

  • cellx, Ultra-fast implementation of reactivity for javascript
  • Elm, FRP language that compiles to HTML, CSS, and JavaScript
  • Frappuccino FRP implementation in Ruby
  • Flapjax, behavior/event FRP implementation in JavaScript
  • Reactive.jl, FRP implementation in Julia
  • ReactiveX, FRP implementation in multiple languages, including Java, JavaScript, Python, Swift and many more
  • reactive-banana FRP implementation in Haskell
  • ReactiveCocoa FRP implemented in Swift and Objective-C
  • ReactiveKit FRP implemented in pure Swift
  • Reflex FRP implementation in Haskell
  • Scala.Rx FRP implementation in Scala (and Scala.js)
  • Sodium, FRP implementation in C#, C++, Haskell (deprecated[12]), Java, > Rust, and Scala
  • Yampa FRP implementation in Haskell

I quite understand what ReactiveX does, and also did some researches about "Reactive Programming" and "Functional Reactive Programming", but I still can't distinguish the relationships between them.

In fact, I kind of believe that Wikipedia page is a misnomer, or incorrectly listing the examples in the "Implementations" section since I know that cellx and ReactiveX (which is both listed in the examples) is built to solve completely different problems.

like image 427
Tony Dinh Avatar asked Feb 26 '16 07:02

Tony Dinh


People also ask

What is reactive programming example?

Reactive programming is a programming paradigm that deals with data flows and the propagation of change. It means that when a data flow is emitted by one component, the change will be propagated to other components by reactive programming library.

Is Rx functional programming?

ReactiveX or Rx is the most popular API for reactive programming. It's built on the ideologies of the Observable Pattern, Iterator Pattern, and Functional Programming. Rx has libraries for different languages, but we will be using RxJS.

What is the difference between reactive and functional reactive programming?

Functional programming paradigm is built upon the idea that everything is a pure function. Reactive programming paradigm is built upon the idea that everything is a stream observer and observable philosophy.

What is ReactiveX used for?

ReactiveX, also known as Reactive Extensions or RX, is a library for composing asynchronous and event-based programs by using observable sequences. This is perfect for Android, which is an event-driven and user-focused platform. The library is widely available for different programming languages.


1 Answers

Author of the reactive-banana library here.

The key distinction between functional reactive programming (FRP) and reactive programming (RP) is that the former has a well-defined denotational semantics, usually obtained from the types

type Behavior a  ~=  Time -> a
type Event    a  ~=  [(Time, a)]

while the latter does not have a well-defined denotational semantics. In particular, all implementations of RX that I know suffer from the problem that merging event streams is non-deterministic: When the streams contain simultaneous events, then sometimes one occurrence is merged before the other, and sometimes the other way round.

Moreover, the statement that "FRP operates on values that change continuously over time" is both subtly incorrect and not the key difference:

  • First, the most probable parse for this statement is that "Behaviors are continuous functions Time -> a", which is not true: Behaviors can be discontinuous, for instance they can be step functions. What is true instead is that Time in FRP is usually taken to be a real number, i.e. a continuum of values.
  • Second, it is perfectly possible to have FRP where time is discrete. That is not the key difference to RP, instead it is all about whether your operations on values have a well-defined denotational semantics or not.
like image 76
Heinrich Apfelmus Avatar answered Sep 24 '22 03:09

Heinrich Apfelmus