Note that there are some explanatory texts on larger screens.

plurals
  1. POFP: Reflecting state in absence of actual state change?
    primarykey
    data
    text
    <p>I am new to some of the advanced functional programming ideas, in particular: how to work with immutable data. Data structures are often composites, composed of smaller data structures. For instance, if we have a Family collection which is made up all of the Members of a household. We might construct the family:</p> <pre><code>var flintstones = new Family(). add(new Member({name: 'Fred'})). //returns new instance of family add(new Member({name: 'Wilma'}). // " add(new Member({name: 'Pebbles'})); // " var fred = flintstones.get({name: 'Fred'}).set({lname: 'Flintstone'}); flintstones = fred.family(); //new instance of family with latest fred. </code></pre> <p>Notice how changing <code>fred</code> did not actually change <code>flintstones</code>. I can grab a fresh reference to <code>flintstones</code> but for what purpose? As all objects are mere snapshots I can't see the point of retaining a reference. State changes have been abstracted away, so we're not going to use the Observer pattern. Thus, how are dependent things like GUIs that care about state changes handled? What is the functional alternative to observation for keeping things in sync? I don't see the objects themselves as having any business in rendering themselves. How might a functional program handle keeping the state of a single-page webapp GUI in sync? </p> <p>For what it's worth <a href="http://qconlondon.com/dl/qcon-london-2009/slides/RichHickey_PersistentDataStructuresAndManagedReferences.pdf" rel="nofollow">Rich Hickey's talks</a> inspired me to explore functional programming. I get his concepts, but I struggle with leaping to a practical implementation (in JavaScript).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload