On Friday, 12 October 2018 at 19:43:02 UTC, Stanislav Blinov
wrote:
On Friday, 12 October 2018 at 18:50:26 UTC, Neia Neutuladh
wrote:
Over the lifetime of the script, it processed more memory than
my computer had. That means I needed a memory management
strategy other than "allocate everything". The GC made that
quite easy.
Now *that* is a good point. Then again, until you run out of
address space you're still fine with just plain old
allocate-and-forget. Not that it's a good thing for production
code, but for one-off scripts? Sure.
People demonstrably have trouble doing that. We can do it
most of the time, but everyone occasionally forgets.
The GC isn't a cure for forgetfulness. One can also forget to
close a file or a socket, or I dunno, cancel a financial
transaction.
By lines of code, programs allocate memory much more often
than they deal with files or sockets or financial
transactions. So anything that requires less discipline when
dealing with memory will reduce bugs a lot, compared with a
similar system dealing with sockets or files.
My point is it's irrelevant whether it's memory allocation or
something else. If you allow yourself to slack on important
problems, that habit *will* bite you in the butt in the future.
Freeing your mind and the codebase of having to deal with memory
leaves it in an easier place to deal with the less common higher
impact leaks: file descriptors, sockets, database handles ect.
(this is like chopping down the forest so you can see the trees
you care about ;) ).