"Alf P. Steinbach" <alfps@start.no> writes:
* Chris Thomasson:
"Juha Nieminen" <nospam@thanks.invalid> wrote in message
news:47fd9bda$0$8159$4f793bc4@news.tdc.fi...
Richard Heathfield wrote:
1) It forces the user to write unsafe code even if he didn't want
to (in
other words, even if in his case it would be enough to use a local,
stack-allocated object of type 'point').
I disagree that this is unsafe.
You are seriously claiming that allocating objects dynamically with
malloc is no more error-prone than using local instances of objects?
Please explain why you think so.
I don't have to explain. Just look at the amount of memory-leaking C
programs out there.
[...]
Well, IMO, that's not the languages fault... Perhaps you should
rethink your comment; something like:
'Just look at the amount of programmers creating memory-leaking
programs out there.'
Would that be okay? Or, am I totally misrepresenting your thoughts?
I think yes, you're a bit off, but at the same time speaking truth.
A bit off: I think Juha's point was that C++'s support for smart
pointers means that it's enormously easier to avoid memory leakages in
C++ than in C.
Yet speaking truth: programmers still manage to leak memory by the
simple expedient of doing things the hard C way, manually, with a lot
of complexity, rather than automated with simple code. In my humble
opinion it's just a symptom of the general inability of people to
understand a future, abstract and "merely" statistical advantage of
doing a little bit more /now/. The future cost of trying to avoid
memeroy leakages when coding and designing, and of fixing them when
they occur, is somehow blocked from consideration, sort of like people
who smoke manage to not think about the monetary and health cost.
do things "properly" .... rumour has it that some can debug 50,000 lines
out of the code. Thats the kind of guys you are dealing with
here. Because Kernighan doesn't use a debugger, they don't either.