TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Immutable Data Collections for Javascript

204 pointsby gagan2020almost 11 years ago

15 comments

leebyronalmost 11 years ago
Hey, I'm the author of this library. It's definitely inspired by mori (and clojure and Haskell) and the reason I ended up building something different was to present a more JavaScript friendly API (and academically, to learn about HAMT). I've built this over the last couple weeks, and we are not using it internally yet - but I wanted to ensure development of it happened in public.
评论 #8111090 未加载
评论 #8110031 未加载
评论 #8108806 未加载
评论 #8118513 未加载
评论 #8109451 未加载
评论 #8108984 未加载
falavaalmost 11 years ago
There is also Mori[1], a JavaScript API for using ClojureScript&#x27;s persistent data structures:<p><pre><code> [1] http:&#x2F;&#x2F;swannodette.github.io&#x2F;mori&#x2F;</code></pre>
评论 #8108265 未加载
评论 #8108108 未加载
评论 #8108396 未加载
评论 #8108974 未加载
abacoalmost 11 years ago
Bit confused (ignorant actually) here. Can someone give a &#x27;real world&#x27; example of the benefits of immutabile objects in js?
评论 #8108394 未加载
评论 #8108553 未加载
评论 #8108038 未加载
dreamdu5talmost 11 years ago
The original npm package &quot;immutable&quot; was <a href="https://github.com/hughfdjackson/immutable" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;hughfdjackson&#x2F;immutable</a> (npm install immutable@1.4)<p>Did Facebook buy the npm name from hughfdjackson, did he give it to them, or did NPM switch ownership?
评论 #8108933 未加载
vineetalmost 11 years ago
Sounds like more of the pieces of React&#x2F;Flux are being opensourced. :-)<p>Interesting to see references to TypeScript. Is it prevalent at FB?
评论 #8108977 未加载
评论 #8111977 未加载
ScottBursonalmost 11 years ago
If anyone is interested in functional collections for Common Lisp or Java, have a look at FSet: <a href="http://www.ergy.com/FSet.html" rel="nofollow">http:&#x2F;&#x2F;www.ergy.com&#x2F;FSet.html</a>
derengelalmost 11 years ago
So you can use the Clojurescript&#x2F;Om&#x2F;Reagent&#x2F;React model without Clojurescript, nice for people who don&#x27;t want or can&#x27;t jump into Clojurescript right now.
jannesalmost 11 years ago
I wish the README would tell us a little bit more about how to use it in conjunction with React. Especially the logic for shouldComponentUpdate() would be interesting.
评论 #8108255 未加载
Kiroalmost 11 years ago
I don&#x27;t understand this whole immutable thing... Why not just avoid changing the data once created? Why do you need a library?
评论 #8109051 未加载
评论 #8109078 未加载
Strilancalmost 11 years ago
I have to admit, I find it odd that we name immutable data structures based on what they don&#x27;t do instead of what they do.<p>Of course, what they do is <i>efficient persistence</i>. You want a snapshot of the data? You want a non-volatile reference? You&#x27;ve already got one! <i>That&#x27;s</i> the feature. They should be called persistent data structures.
评论 #8111645 未加载
评论 #8111668 未加载
评论 #8111484 未加载
colinramsayalmost 11 years ago
React&#x27;s documentation also discuss their immutability helpers [1]. This new library looks like a better way of implementing this though. Will the documentation be amended to discuss use of immutable-js?<p>[1] <a href="http://facebook.github.io/react/docs/update.html" rel="nofollow">http:&#x2F;&#x2F;facebook.github.io&#x2F;react&#x2F;docs&#x2F;update.html</a>
评论 #8108887 未加载
33aalmost 11 years ago
Also relevant (and not included in this collection) is the following functional red-black tree implementation:<p><a href="https://github.com/mikolalysenko/functional-red-black-tree" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mikolalysenko&#x2F;functional-red-black-tree</a>
collywalmost 11 years ago
Can someone give me a good example of where immutable data structures are better than mutable ones. I know that you are more likely to mess up and have side effects with mutable data structures, but so far all I have heard is theory.
评论 #8113689 未加载
评论 #8113646 未加载
boubiyeahalmost 11 years ago
What&#x27;s the use of immutable data collections if you have to constantly revert to mutable arrays to render anything? Any gain from the persistent collection is lost in wasteful Array creating (Poor gc)
nawitusalmost 11 years ago
Hmm, it seems to be written in TypeScript, but the source is only provided in JavaScript.
评论 #8108764 未加载
评论 #8108403 未加载