On Friday, 12 October 2018 at 16:26:49 UTC, Stanislav Blinov
wrote:
On Thursday, 11 October 2018 at 21:22:19 UTC, aberba wrote:
"It takes care of itself
-------------------------------
When writing a throwaway script...
...there's absolutely no need for a GC.
True. There's also absolutely no need for computer languages
either, machine code is sufficient.
In fact, the GC runtime will only detract from performance.
Demonstrably untrue. It puzzles me why this myth persists. There
are trade-offs, and one should pick whatever is best for the
situation at hand.
What this means is that whenever I have disregarded a block of
information, say removed an index from an array, then that
memory is automatically cleared and freed back up on the next
sweep. While the process of collection and actually checking
Which is just as easily achieved with just one additional line
of code: free the memory.
*Simply* achieved, not *easily*. Decades of bugs has shown
emphatically that it's not easy.
Don't be a computer. Do more with GC.
Writing a throwaway script there's nothing stopping you from
using mmap or VirtualAlloc.
There is: writing less code to achieve the same result.
The "power" of GC is in the language support for non-trivial
types, such as strings and associative arrays. Plain old arrays
don't benefit from it in the slightest.
For me, the power of tracing GC is that I don't need to think
about ownership, lifetimes, or manual memory management. I also
don't have to please the borrow checker gods.
Yes, there are other resources to manage. RAII nearly always
manages that, I don't need to think about that either.