Memory Management Mismanaged
Memory Management Mismanaged
- Subject: Memory Management Mismanaged
- From: Karl Goiser <email@hidden>
- Date: Wed, 07 May 2003 16:32:24 +1000
G'Day Peoples,
I am going to have a bit of a spit about memory management in Cocoa, so
you should probably move on to the next message now!
I think that this retain count system is very bad for two reasons:
1. It is a barrier for new people. From the regular messages on this
issue I see in this group, it seems to be a difficult concept to
understand (I think so). It's like icon design - if you have to keep
explaining to people how that squashed bug on the screen is emblematic
of your great magnum opus, there's probably something wrong with your
design - you certainly can't (shouldn't) blame them. I think it is
quite possible that this has turned people off Cocoa as a whole,
meaning that they haven't had the great experiences of working with
such rich tools, and, possibly Mac development altogether. This is a
shame.
2. It gets in the way.
a) You have to take care of the pointer objects in your objects with
the dealloc method.
b) You have to write special accessor methods
c) There is no standardisation of what these accessor methods should
look like (I use the three statement, retain, assign, release variety
for setting, but think that they may not be thread safe...).
- If you have to take care of things yourself, is it any less work than
the standard C style do it yourself technique?
- It is definitely more work than an environment that has automatic
garbage collection.
Programming is about taking ideas that are in yours or others' heads,
sometimes specified in documentation (!), and creating code that brings
those ideas to reality. It is like, you are 'here', with the ideas,
and you want to be 'over there' where the program runs - like a path.
Anything that slows you down or side-tracks you just delays delivery of
the program.
C++ is one of those great delaying languages where you have to worry
about whether your classes and methods are going to be virtual and/or
base and references and whether somebody has redefined (overloaded) =
under you etc etc. To use collections, you have to use templates
(which only seems to exist to get around the strong type checking in
the language that Objective-C doesn't suffer from). I often wonder how
much of a C++ programmer's time is spent 'fighting' the language!
[But I digress..]
Memory management is something today's programmers should not have to
deal with. It has been around as an issue for more than fifty years
and we still can't come to grips with it! It gets in the way of the
programmer who has to constantly worry about what will happen with each
piece of memory they have allocated. And if you scrimp on the time
during development, you end up paying for it through the bugs you give
to your customers. Lengthening the time to develop means projects get
dropped, they overrun targets, unnecessary bugs get introduced etc etc.
- We have really powerful machines today and what do they do? Sit
around while we type in our code and wait for the bugs!
What's the solution? Well, Lisp since the sixties, Smalltalk since the
eighties, Java since the nineties, plus any number of other languages
have had automatic garbage collection...
Phew! Now I can move on.
Regards,
Karl
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.