Do languages with garbage collectors necessarily have to be object oriented?
Are there any non-OO languages that have GCs?
Any language which allows you to allocate and reserve memory resource in the heap, will require garbage collection, either a built-in garbage collector handles it, or you do manual memory management. In other words, if a language allows dynamic memory allocation, GC will be involved. Non-OO languages which allows dynamic memory allocation exist, and hence GC and memory management of the likes is not specific to OO languages. Doesn't sound like my cup of tea, but this existed. https://www.linuxjournal.com/article/6679 also, https://stackoverflow.com/questions/9952602/does-haskell-require-a-garbage-collector
Hatsy Rei thanks for the articles. I particularly like the quote which says "C programmers think memory management is too important to be left to the computer. LISP programmers think memory management is too important to be left to the user.” Jared Bird yes it seems that there is no direct relationship between OOP and automatic GC apart from similar timing of when they became popular/widespread. It also seems to me that one challenge of adding an automatic GC to C is it's weakly typedness. So maybe there is more a link between automatic GCs and strongly typedness than between automatic GCs and OO-ness?
Schindlabua seems like strong typedness is not at all correlated with auto GC then. I was just going by the statement in the above article about the DBW collector algorithm which is only one implementation of a GC BTW, where it has to make assumptions due to not being able to completely determine which variables are actual pointers to dynamic memory and which ones are not. I am not tempted to assume any link between GC'd languages and systems programming either as someone can always come up with a counter example. But maybe it's a necessary condition of a language used for systems programming to not be GC'd. So I think you're right.
Hatsy Rei That's not my my cup of tea either. Apparently someone thought it was a good idea to add a GC to gcc (written in c++), this has been suggested as the biggest reason gcc takes twice as long to compile code as clang. I think the reason GC and OOP, seem to match up is timing. Both became popular around the same time. Notice that some languages allow you to use OO designs or not, but treat GC in the same way.