3 ms·
So when I update ship, that means a new ship was created right? What happens to the old ship? and how is recreating the universe for every iteration efficient?
by crimsonalucard 11y ago
So when I update ship, that means a new ship was created right? What happens to the old ship? and how is recreating the universe for every iteration efficient? Is there something tricky going on in the background?
- angersock 11y agoConsider that in many cases, you don't need to recreate the whole universe--lots of stuff may stay the same. Also, to get to the old ship, you just rewind the events, because the state can be fully reconstructed (no weird side-effects).
- zimbatm 11y agoA new ship is created and the old ship is sailing towards garbage-collection unless other objects are still holding references to that value. This is going to add more pressure on the garbage-collector for sure.
- rtfeldman 11y agoThere is indeed something tricky going on: Elm uses persistent data structures behind the scenes. See this previous HN discussion about Elm's persistent data structures: https://news.ycombinator.com/item?id=7686272 https://news.ycombinator.com/item?id=7686272