rtfeldman / seamless-immutable

Immutable data structures for JavaScript which are backwards-compatible with normal JS Arrays and Objects.
BSD 3-Clause "New" or "Revised" License
5.37k stars 195 forks source link

README: Why to prefer dev build, how to switch #86

Closed holyjak closed 8 years ago

holyjak commented 8 years ago

It should be stated what build is used by default and provide a justification for it. A newcomer would be likely confused by why we use dev build in production, so I have copied the justification from #50 and referred to it regarding info about how to switch. I suppose this is going to evolve but we should document the current status.

rtfeldman commented 8 years ago

Love it, thanks @jakubholynet !

InsomniacFury commented 8 years ago

Along those lines, I am confused. The production version seems to me that it effectively leaves objects immutable, which invalidates the concept of this library. I understand that the production version is useful when performance is a problem, but from what I can tell it stops delivering making objects immutable.

I could be missing something fundamental.

rtfeldman commented 8 years ago

@InsomniacFury Correct - the production build does not make objects immutable.

The idea is that in development you will have used the immutable guarantees to end up with code that does not mutate anything, and by the time you reach production, the guarantees are implicit by the code you've written, and no longer need to be enforced.

If you want stronger guarantees in production, there's absolutely no reason you can't keep using the dev build. In fact, when the library was first released, the dev build was all there was! :smiley:

InsomniacFury commented 8 years ago

@rtfeldman thanks for the response. That makes sense. I saw that in the docs Safari was called out as having a slow Object.freeze(). Are there any other performance implications that has lead to the production version not enforcing the immutability?

rtfeldman commented 8 years ago

@InsomniacFury Just that it does extra work on instantiation - namely freezing and banning methods.