DEV Community

Discussion on: How React isn't reactive, and why you shouldn't care

Collapse
 
peerreynders profile image
peerreynders • Edited

Its most famous incarnation in JavaScript is RxJS ...

From the ReactiveX Introduction

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. (See Conal Elliott’s work for more-precise information on functional reactive programming.)

Essentially ReactveX ceded the "FRP" (Functional Reactive Programming) moniker to Conal Elliot's work stating:

(Reactive Programming + Functional Programming) !== Functional Reactive Programming

Back in 2014 - Comment

UPDATE: there's been a lot of confusion around the terms Functional Reactive Programming and Reactive Programming [1] [2].

Sorry, my bad. I guess this sort of confusion happens easily with new paradigms in computing.
Replace all the occurrences of "FRP" with "RP" in the tutorial. Functional Reactive Programming is a variant of Reactive Programming that follows Functional Programming principles such as referential transparency, and seeks to be purely functional. Other people are better at explaining this than I am. [3] [4] [5]

Collapse
 
ryansolid profile image
Ryan Carniato

I see.. I read Staltz' articles but missed his correction. I see I'm a victim of the same confusion. So FRP is yet a different concept. In some ways though this only continues to add to the confusion here. I don't even know what to name it then.. In JS we tend to mainly have the 2 forms Rx and Fine-grained (I've also heard it called SRP). Mind you that description makes FRP sound more like what I've been calling fine-grained.

Someone in academia will probably have to correct us. This has propagated to the point there is even some ambiguity in later white papers. Most of the language I use I reference from this paper on Elm: elm-lang.org/assets/papers/concurr...

But admittedly I'm a little grey where the exact distinction lies. Which is really the heart of the problem here. Calling out reactive or not is more about marketing than anything else.

Collapse
 
peerreynders profile image
peerreynders • Edited

With xstream Staltz converged on the term "reactive streams". And while I personally like "Rx" it's likely going to be associated with ReactiveX specifically or worse constantly have people quip about "medical prescriptions".
Conal Elliot actually stated this about Elm:

I may have said that Elm was an offshoot of E-FRP iiuc. Sort of inspired-by-inspired-by-FRP.

A Survey of Functional Reactive Programming (2013)

Once signals were dropped in Elm 0.17 (May 2016) that discussion simply faded.


OK that is what this is about!

Truly reactive

No more complex state management libraries — Svelte brings reactivity to JavaScript itself.

Yes, there is a case here that the terminology is imprecise and perhaps even sloppy for the purpose of hype and marketing.

Unfortunately for the target audience "reactive" expresses exactly the message that Svelte wants to convey - "change propagation analogous to that perceived with spreadsheet cell formulas" on the language level - right in your Java(Svelte)Script (which reminds me of Simon Peyton Jones referring to Excel as The world's most popular functional langauge).

But Svelte's difference isn't due to reactivity but because its compiler separates create/update paths allowing skipping on a VDOM.

This description is far more accurate - but it's my sense that in terms of a DX-obsessed audience it's just not as catching to accuse React of doing too much work at run-time when it could be doing it much more effectively at compile time.

So I guess Svelte's claim to reactivity is just as valid as React's claim that it isn't a framework (sorry, it is).

Thread Thread
 
ryansolid profile image
Ryan Carniato

Yeah exactly my point and thanks for digging a bit more. I'm going to edit the terminology in the article. It was my mistake for taking the FRP thing at face value. I will stick with our JavaScript made up terms rather than academic ones to avoid further confusion. I'm having a similar discussion on reddit where someone was really put off by me calling Rx FRP and even calling these different things. In JavaScript there are really 2 different types that have developed out but they are only small part of the spectrum.

I believe it is:
Reactive Streams - Asynchronous Events in continuous time
Fine Grained - Synchronous Behaviors in discrete time

But realistically you can have different combinations of these I suppose.

Thread Thread
 
trusktr profile image
Joe Pea

Qt's used-to-be-fine-grained reactivity just went from sync to async in a major version bump. Naming aside, I still look at it as the same thing, just everything is batched now.

Thread Thread
 
ryansolid profile image
Ryan Carniato

I've continued this line of thought over to a follow-up article: dev.to/ryansolid/what-the-hell-is-...