The linked Stack Overflow answer by Conal Elliott does a much better job explaining FRP. It has less to do with "linking" as via this destiny operator and more to do with manipulating values of "entire histories and futures" all at once. In other words, the heart of FRP is not in the operators, but the nouns. And not in an OO sense tied to ambient mutation, but instead as concrete, immutable values.
This gives me an great idea. What if we put these variables into a grid displayed on the screen? Then you will be able to enter some values into some of the cells, and the dependent ones update themselves automatically. The elements of the grid could be regarded as array elements indexed by coordinate, and use relative or absolute addressing to refer to each other's coordinates, making it easy to replicate dependency rules across rows and columns, to generate entire tables which update themselves.
Scaling would be quite difficult. I'm sure you could hack maybe a Turing machine out of this paradigm, but it would be ugly and mostly an esoteric exercise.
I've been slowly implementing my own functional reactive programming system over for a game engine I'm writing. A few months ago, I wrote a short blog post on the topic that includes a screencast to see how it all works. Maybe it will help someone understand (F)RP a bit better.
The "destiny" operator is just function definition. It might seem different if you're only used to languages where function calls and variable accesses are syntactically distinct.
a = 10
b = function() { return expensive_computation(a) }
Now, even if you can call b without parens, it still has to redo the expensive calculation every time you access it (because a might have changed... even if it hasn't).
The "destiny" operator is more like
a = 10
b = function() {
persistent cached_value = null
if is_null(cached_value) or has_changed(a) {
cached_value = expensive_computation(a)
}
return cached_value
}
but instead of that, you get to write (in this totally fictional programming language)
a = 10
b <- expensive_computation(a)
and have the compiler take care of the caching and updating for you.
I enjoyed the post, but I think the proposed scope of reactive programming is a bit limited. What the author describes is, I think, more related to the concerns of "bidirectional programming"[1] and lenses[2]. Granted, I think those concerns do fit broadly under the umbrella of reactive programming.
Below is Prof. David Harel's (the inventor of statecharts, formalized as UML State Machines) general characterization[3] of a reactive system; reactive programming would then be any programming methodology, language or environment which aims to service those characteristics.
* It continuously interacts with its environment, using inputs and outputs that are either continuous in time or discrete. The inputs and outputs are often asynchronous, meaning that they may arrive or change values unpredictably at any point in time.
* It must be able to respond to interrupts, that is, high-priority events, even when it is busy doing something else.
* Its operation and reaction to inputs often reflects stringent time requirements.
* It has many possible operational scenarios, depending on the current mode of operation and the current values of its data as well as its past behavior.
* It is very often based on interacting processes that operate in parallel.
The words "responding" and "asynchronous" seem to imply a particular execution model, in particular one which seems to contradict the original definition of Function Reactive Programming
[+] [-] tel|11 years ago|reply
[+] [-] amouat|11 years ago|reply
[+] [-] throwaway283719|11 years ago|reply
I should really learn what that means one day...
[+] [-] kazinator|11 years ago|reply
[+] [-] kyllo|11 years ago|reply
Seriously though, Angular gives you the ability to do this in the browser, here's an example of how to implement an Excel-like spreadsheet using Angular: http://thomasstreet.com/blog/legacy/spreadsheet.html
[+] [-] pjc50|11 years ago|reply
[+] [-] throwaway283719|11 years ago|reply
[+] [-] taylodl|11 years ago|reply
https://en.wikipedia.org/wiki/Lotus_Improv
[+] [-] seanmcdirmid|11 years ago|reply
[+] [-] ggurgone|11 years ago|reply
[+] [-] charlespwd|11 years ago|reply
[+] [-] davexunit|11 years ago|reply
http://dthompson.us/functional-reactive-programming-in-schem...
[+] [-] Vaskivo|11 years ago|reply
[+] [-] ef4|11 years ago|reply
[+] [-] throwaway283719|11 years ago|reply
The "destiny" operator is more like
but instead of that, you get to write (in this totally fictional programming language) and have the compiler take care of the caching and updating for you.[+] [-] michaelsbradley|11 years ago|reply
Below is Prof. David Harel's (the inventor of statecharts, formalized as UML State Machines) general characterization[3] of a reactive system; reactive programming would then be any programming methodology, language or environment which aims to service those characteristics.
* It continuously interacts with its environment, using inputs and outputs that are either continuous in time or discrete. The inputs and outputs are often asynchronous, meaning that they may arrive or change values unpredictably at any point in time.
* It must be able to respond to interrupts, that is, high-priority events, even when it is busy doing something else.
* Its operation and reaction to inputs often reflects stringent time requirements.
* It has many possible operational scenarios, depending on the current mode of operation and the current values of its data as well as its past behavior.
* It is very often based on interacting processes that operate in parallel.
[1] http://www.cs.cornell.edu/~jnfoster/papers/jnfoster-disserta...
[2] http://www.cis.upenn.edu/~bcpierce/papers/lenses-etapsslides...
[3] http://www.wisdom.weizmann.ac.il/~harel/reactive_systems.htm...
[+] [-] cpr|11 years ago|reply
[+] [-] RyanMcGreal|11 years ago|reply
Sigh.
[+] [-] kybernetikos|11 years ago|reply
[+] [-] willismichael|11 years ago|reply
[+] [-] factorialboy|11 years ago|reply
[+] [-] chriswarbo|11 years ago|reply
http://conal.net/papers/icfp97/
Perhaps a more neutral description would be:
Reactive = Values are parameterised by the current time