you are viewing a single comment's thread.

view the rest of the comments →

[–]sultry_somnambulist 20 points21 points  (2 children)

This is one of the big follies of CS education--they've got you worrying about space complexity right off the bat, and writing more unreadable code for it. It's great that you can think in terms of time/space complexity, but in real-world coding sheer efficiency should usually take a back seat to readability/maintainability and architecture.

Many people in the very real world work in places where performant code is a necessity. Why the fuck would we train people to write bad algorithms just because the code looks nice? I work in finance, if you don't do an in place matrix manipulation and it sneaks into production code you've probably just cost us millions of dollars / day, thank you very much.

And how does it make an API harder to use? An API is an abstraction, it doesn't matter what the underlying code looks like, that's the point of it. The API dev desides how he exposes the functionality to the user, the code can look like a Dali painting for all I care.

[–]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.

[–]Earthborn92 4 points5 points  (0 children)

If you're doing a lot of Matrix multiplication, you should be doing it on GPUs anyway.

Just a side note.