04.06.2021 16:32, Ola Fosheim Grøstad пишет:
On Friday, 4 June 2021 at 12:44:07 UTC, Imperatorn wrote:
GC won't go away tho. What might happen is more flexibility. The
GC-phobia is irrational.
The topic doesn't fit in this thread, but it isn't irrational.
You have to wait for all participating threads to be ready to collect,
so it isn't only about collection speed. In essence you end up with some
of the same issues as with cooperative multitasking.
And it is also obvious that collection speed will drop as your
application grows and you start working with larger datasets.
So, you might initially think it is fine, but end up rewriting your
codebase because it only worked well with the simple prototype you
started with.
That's not a good strategy.
(but ok for batch programs)
I use GC when developing an algorithm to solve my problem. After I has
implemented the algorithm I can redesign it to avoid GC (if needed). It
works pretty nice in my case at least. Because initially I concentrate
on my domain problem and then I only deal with memory management. This
separation is very helpful.
Also there is no rewriting when you switch to manual management - you
just add new code, no replacing old code. Again often API is worse
after switching than in case of GC.