Persistant data, pure functions and RAM

56 Views Asked by At

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 (methods?) 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 stack, 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!

0

There are 0 best solutions below