Alex Rivera | Logout

Was there a specific reason why garbage collection was not designed for C?

Asked 2010-10-28T02:30:05.920
27

I have heard that it was suboptimal for C to automatically collect garbage — is there any truth to this?

Was there a specific reason garbage collection was not implemented for C?

Edit
Report

1 Answer

2

Garbage Collection is not useful if you want to make hardcore optimisations, because if you decide the moment when it's best to free allocated space, then you can make a much better job in your project than the garbage collector does. In the 1970s I don't know the exact cause why the developers decided to not include a garbage collector to C, probably they wanted to have absolute control of deallocation, however I'm sure later they didn't even consider to add a garbage collector, because even if there is an integration of a garbage collector to the language which is very good, there were built a lot of C projects and the new versions of the language must have backwards compatibility.

EDIT: "There are also compilers, libraries and operating system level mechanisms for performing array bounds checking, buffer overflow detection, serialization and automatic garbage collection, that are not a standard part of C." This may be interesting for you, you can read more here.

answered 2010-10-28T02:40:03.530

Your Answer