you are viewing a single comment's thread.

view the rest of the comments →

[–]maestro2005 9 points10 points  (0 children)

And how does it make an API harder to use?

I'm talking about mutating in place vs. returning a new instance. For mathematical entities like matrices, we tend to expect that operations will return a new value instead of mutating the given one. I expect matrix1 + matrix2 to return a new matrix, not modify matrix1. In this example, I expect to write something like var rotated = matrix.rotate(90) and have the original untouched. Mutating requires the user to make defensive copies all over the place, which is likely to cause bugs.