2

I am trying to understand functional reactive programming for a long time (since I have participated in the Reactive Coursera course a year ago) but I still don't understand the essence of it.

Here I am going to describe my current understanding about functional programming vs. functional reactive programming and I would like know if I am on the right path towards understanding the essence of functional reactive programming or not, if not then why not ?

I want to know if it is a good analogy to think about functional reactive programming as programming with differential equations.

In other words, specifying how the system evolves in terms of equations (declaratively).

In functional programming computations are described using static, time-independent equations, in contrast in functional reactive programming everything becomes time dependent. So instead of describing a simple function, one describes a function that depends on time explicitly.

For example, in traditional functional programming one is programming using pure functions without side effects. Just like mathematical functions (maps from one set to another set).

For example f(x)=x^2.

However, in functional reactive programming, to my understanding, and I am not sure if I understand it correctly so please correct me if I am not, one describes computations in terms of time dependent discrete differential equations.

For example, if I want to describe the user interacting with a ball on the screen, which can move along one dimensions (x) then I write the following equations:

x(t)/dt=v(t)

v(t)/dt=a(t)

a(t)=F(t)/m

where F(t) is the force exerted by the user onto the ball.

If I understand correctly, the essence of functional reactive programming is to go from static functions to time dependent functions and express the computations/algorithms in terms of (discrete) differential equations.

Is this understanding of mine correct ? Is this really the essence of functional reactive programming, or is there more to it ?

jhegedus
  • 18,516
  • 11
  • 84
  • 147

1 Answers1

2

See my answer here (containing the two essential founding properties of FRP) and follow the links you find.

Conal
  • 18,206
  • 2
  • 34
  • 40
  • Note that one of the two essential founding properties is *continuous* time, to remedy inherent problems in discrete models. – Conal Jul 06 '15 at 16:03