News for hackers. Stuff that matters.
Re:Clojure Tradeoffs by kleiba on Wednesday June 26, 2013 @01:07AM (#5944307)
Why does the iteration have to return copies? Can it not just return the object itself? Or are you talking about return-by-value versus return-by-reference (Java does the latter)?
Re:Clojure Tradeoffs by tel on Wednesday June 26, 2013 @01:14AM (#5944329)
Immutability means that if you're "modifying" the structure you must actually be "making a new copy with a small change". Structural sharing means that usually only the small change itself gets new allocation, but it's still more pointer-chasing than a continuous memory map.

Lots of algorithms don't work with this kind of copying semantics, but you have all of Purely Functional Data Structures [1] to help.

[1] http://www.amazon.com/Purely-Functional-Structures-Chris-Oka...

Re:Clojure Tradeoffs by kleiba on Wednesday June 26, 2013 @01:46AM (#5944400)
Fair enough, but I wasn't talking about modification, I asked about iteration.
Re:Clojure Tradeoffs by cgag on Wednesday June 26, 2013 @02:04AM (#5944435)
Just iterating doesn't make any copies. Replace iterating over with modifying.

Efficient immmutable data structures are easily one of Clojure best features. Easiest trade off ever (though the actual hit to performance isn't that bad) imo.

Re:Clojure Tradeoffs by dragandj on Wednesday June 26, 2013 @04:44AM (#5944830)
Not only that, but you can also make a persistent structure locally transient for the duration of the (modifying) iteration, so in lots of cases you do not have to pay the persistence penalty.
Re:Clojure Tradeoffs by tel on Wednesday June 26, 2013 @02:35AM (#5944499)
Oh, true—I jumped his point
Re:Clojure Tradeoffs by aphyr on Wednesday June 26, 2013 @02:09AM (#5944447)
It doesn't. I suspect the parent was thinking of mutation.