Re: GC pros and cons
Re: GC pros and cons
- Subject: Re: GC pros and cons
- From: Andy Lee <email@hidden>
- Date: Wed, 24 Jun 2009 13:48:06 -0400
On Wednesday, June 24, 2009, at 12:14PM, "Philip Aker" <email@hidden> wrote:
>Like Gwynne, I'm comfortable with the traditional "reap what you sow"
>philosophy. This has benefits in that the basic policy spills over
>into other areas of programming and gradually, one learns as a matter
>of habit, to account for things all the time.
I can appreciate having an elevated sense of responsibility, but if you take this to the extreme you'd insist on programming in assembly because you don't trust compilers to properly put things on the stack on entering a function and remove them on exiting. I suppose you trust malloc() and free()? But you're trusting those to do a lot of stuff behind the scenes as well (like glomming together contiguous blocks of free memory) -- and you're trusting yourself to balance them properly.
As we adopt higher-level languages, we trust them to do things for us so that we're freed to think at higher levels of abstraction. Even the NewHandle() and DisposeHandle() Gwynne referred to (I remember them fondly!) -- if I recall correctly, the reason for handles in the first place was to allow memory blocks to be moved around behind the scenes. Someone who never trusts automatic memory management would never trust such a scheme.
The current implementation of GC in Objective-C may not reach a high enough level of trust for you, but to rule out GC as inherently irresponsible is kind of silly IMHO.
> This is good but can be
>lumped in with many other things learned from the school of hard
>knocks. With GC, the attitude is like one could fire a shotgun into a
>crowd and the walk away because the system will take responsibility
>for the consequences. Maybe you could say that's a moral issue. But
>it's certainly not something children should be taught in school.
>
>In a nutshell, for folks like me who regularly use CFCreate …
>CFRelease in loops, what are the benefits of GC?
I think it's pretty obvious what the benefits are: not having to manually manage memory, which eliminates one class of bugs and frees up time and mental effort so you can concentrate on avoiding and fixing other classes of bugs. I'm not sure if you were expecting more than the obvious? The more relevant question is whether the risks around some edge cases is worth it. There is anecdotal evidence on both sides.
FWIW, I haven't adopted GC either. Like Gwynne, I freely admit I've refrained partly out of habit. At first I also had a certain amount of technical wariness around the implementation of GC -- would it be buggy? would it be painful? -- but the more I wait and see, the more I'm convinced I'd have absolutely no GC problems in the vast majority of apps I'm likely to write.
--Andy
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden