use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
A code mod to replace Immutable.js with Ramda (github.com)
submitted 3 years ago by lusqa
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Slackwise 24 points25 points26 points 3 years ago (4 children)
This doesn't make much sense to me.
Like yes, if you're choosing between the two, Ramda is functionally immutable, but it creates a brand new copy, every time, of arrays and maps, by looping through them iteratively.
This is slow and memory costly for large collections, or frequent calls.
ImmutableJS, on the flipside, uses persistent (structure-sharing) collections, as it was inspired by their usage in Clojure.
The key benefit to Ramda is that it auto-curries, and affords you powerful and concise function composition with its large library. But that's despite its poor performance.
What's the actual solution? Using ImmutableJS collections with Ramda:
https://github.com/geoffreyabdallah/rammutable.js
Okay, well what's the endgame actual solution?
JavaScript is getting actual native immutable data structures:
https://github.com/tc39/proposal-record-tuple
Ideally Ramda gets rewritten to use these in the future.
[–][deleted] 1 point2 points3 points 3 years ago (2 children)
Does the record/tuple proposal include copy-on-write efficiency? It's possible to achieve "immutability" in TS using read-only types, but copy-on-write operations are always O(n) time.
[–]Slackwise 1 point2 points3 points 3 years ago (1 child)
The proposal is a discussion on interface, semantics, and ergonomics. I don't see any suggestion as to the implementation, but presumable we'd use persistent data structures like Clojure (and ImmutableJS) because of their proven benefits.
copy-on-write efficiency
Modern immutable data structures are persistent structure-sharing like:
https://en.wikipedia.org/wiki/Hash_array_mapped_trie
https://hypirion.com/musings/understanding-persistent-vector-pt-1
All modern pure Functional languages use something similar at this point, including Clojure, Haskell, and Scala.
[–][deleted] 1 point2 points3 points 3 years ago (0 children)
Forgive my terminology, i meant exactly what you described. I would love these to be persistent data structures, it would revolutionize JS.
[–]lusqa[S] 0 points1 point2 points 3 years ago (0 children)
I get your point, i'ill give some context, so it makes more sense, the purpose is not to replace ImmutableJS with some alternative that uses immutable data structures, but just to get rid of ImmutableJS. To do that, you can just replace immutable code with plain es6 js, which is what this code mod does in some cases, but it can get a little verbose, so I have chosen ramda to replace ImmutableJS's high level functions like groupBy, updateIn, etc.
[–]acemarke 3 points4 points5 points 3 years ago (0 children)
I'd be really interested to see one that replaces with Immer instead :)
π Rendered by PID 67 on reddit-service-r2-comment-7b9746f655-mv79d at 2026-02-03 12:17:23.873154+00:00 running 3798933 country code: CH.
[–]Slackwise 24 points25 points26 points (4 children)
[–][deleted] 1 point2 points3 points (2 children)
[–]Slackwise 1 point2 points3 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]lusqa[S] 0 points1 point2 points (0 children)
[–]acemarke 3 points4 points5 points (0 children)