Reputation: 891
I'm currently reading Eloquent JavaScript, and I don't really understand the interest of using persistent data structures like indicated in this paragraph.
If I get it right, we are using pure functions in this example, as the this.move
method returns a new VillageState
object without affecting the state of the original VillageState
.
This way all the objects created until the problem gets solved are stored somewhere in the RAM, right? Then, should this extra data storage slow down the program too?
I don't really understand how it might be simpler to understand than using mutable data in this case. So I'd be glad if some of you could clarify this out for me, thanks.
And please correct me if I'm wrong somewhere!
Upvotes: 2
Views: 65