Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
Garbage collection in C
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="Arthur J. O'Dwyer, post: 1672334"] Not Boehm. Jacob Navia's particular interface to Boehm. (Of course, maybe Boehm's GC is bad too; I'm not a GC expert.) I already said this in a personal email exchange with Jacob, but here's what I find annoying/incorrect about his GC: 1) GC in general does not fit into the C language. Because the C standard does not require GC, it is expected that a C program will be able to run properly with or without GC. If it doesn't clean up its own mallocs, then it's not properly-written standard C. And if a program *does* run correctly without GC, why on earth would you *add* GC to it? It's just library bloat at that point. 2) This particular GC has a non-standard interface. Jacob's first suggestion was to #define malloc GC_malloc. That is AFAIK an invocation of undefined behavior, and isn't guaranteed to work unless it is surrounded by #ifdef __THIS_COMPILER_HAS_GC__ - except that of course the macro __THIS_COMPILER_HAS_GC__ does not exist, so we're stuck with testing something defined by lcc-win32 (and, we hope, *only* by lcc-win32). A much better interface would have been a #pragma directive; for example, #pragma LCCWIN32_GC which requires much less thought by the programmer *and* has a better chance IMHO of passing muster with the standards police. :) 3) The original proposal had a bug in it. This is the #define free(a) (a=NULL) thing that several people pointed out. Sure, it's trivial to fix, but the fact that it was included in the proposal at all indicated that maybe Jacob hadn't put as much thought into his design as he could have. 4) Real Programmers(tm) don't do garbage collection. This one is a stereotype, of course, but you should realize that a lot of the regulars in c.l.c are (or seem to be) Real Programmers(tm). They program in C because they like the fine control, the clean interface, and the raw power that the language provides. Garbage collection is an attribute of higher-level Quiche Eater languages like Lisp and Java, and you just shouldn't expect a ticker-tape parade from the C programmers when you try to introduce it into C. It's the psychology of the thing. C's been around for more than 20 years now without GC; if you want GC that bad, use a language that has it built in. That's how it is. That pretty much sums up the points I've seen against this GC. HTH, -Arthur [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
Garbage collection in C
Top