Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Immutability by default is the right idea, but the nature of arrays as a data structure is that they are (should be) less expensive to transform in-place than by creating a copy.

Mutation per se isn't harmful — if our ape brains were better able to think like a digital computer, we'd never have created functional programming (or even procedural, but I digress). What's harmful is our ape-brain habit to use mutation incorrectly (i.e. a buggy implementation). So a very large part of the problem can be solved with a (standard) library that provides (in theory) correct, performant implementations of common mutation patterns (such as Ruby's `Array#reject!`).

(I realize you were taking the devil's advocate; I sort of am too, since I rarely use mutating methods when I write Ruby).



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: