Garbage Collection and Concurrency
It was not always obvious to me, but Concurrency and Garbage Collection are like PB+J, or french fries and ketchup; they make a kick-ass pair!
In non-GC languages and a concurrent piece of code, it’s not really straightforward when the last thread has finished using some resource so it can be released; this might mean performing manual book-keeping, or using specific data-structures and patterns which ensure proper cleanup.
On the other hand, GC languages are able to circumvent this whole class of bugs abstracting it from the programmer’s view. Even the trivial case of using some background thread to perform a periodic action is simplified.
Writing correct concurrency in Go can be easier, than for example in C++ where you’d have to think about things such as RAII.
Disclaimer : My C++ knowledge is sketchy at best. I’ve only used it for academic work narrowly centered around a framework, either Fluka, OpenMP or Mad-X.This post included some examples to showcase this issue, but they were not up to par, so they were removed, until I find some time to practice my C++ and write some new ones.
I’m still looking for a better way to explain this concept with an example. Feel free to reach out if you have any good ideas!
I also recommend watching MIT’s 6.824 class on distributed systems where this issue was mentioned, if you’re into this kind of stuff.