In JS we don't have native persistent data structures and the ES6 const keyword 
only gives us shallow immutability without any of the gains of persistent data 
structures. ImmutableJS is nice but existing libraries expect regular JS maps 
and arrays. So what i have been thinking is to use ES6 Proxy with a Frozen 
reference and that way all writes go to the Proxy object while all reads come 
from a diffing operation on Proxy and original object, thus giving us some form 
of immutability. For now, however, I've implemented it as deep freezing the 
referenced object and using HTML5 structured cloning algorithm for when a 
mutable clone is desired. This is admittedly half assed but it allows me go 
cleanly isolated all shared mutable state into an atom like structure in JS. So 
far so good and it has helped a lot with my D3 app since D3 charts can be 2000 
lines long with a ton of global var use, which makes them very hard to debug, 
which is now all eliminated. 

Without that i couldnt implement the great ideas I'm learning from 
ClojureScript in my JS work. 

Sent from my iPhone

> On Jul 12, 2015, at 8:44 AM, Matt Ho <[email protected]> wrote:
> 
> What problem are you looking to solve here?  
> 
> My take is that immutability is a design pattern rather than something 
> enforced by the language constructs.  If you want the language constructs to 
> enforce immutability, Haskell is an excellent choice.  Even Elm (a Haskell 
> like language) treats immutability as a design pattern rather than a language 
> construct.
> 
> For me, immutability is a design pattern, much like FP, intended to simplify 
> how we reason about apps.  I think Om, Reagent, Flux, and Elm are all 
> excellent examples of the power of immutable thinking.  For comparison, the 
> mutable frameworks would be Ember, Angular, and Backbone.
> 
> M
> 
> -- 
> Note that posts from new members are moderated - please be patient with your 
> first post.
> --- 
> You received this message because you are subscribed to the Google Groups 
> "ClojureScript" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/clojurescript.

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to