|
Real programmers don't fear pointers; it's just a number. Are you afraid of the phone book? No? You will be.
Real programmers can clean up after themselves - garbage collection is for spoiled brats who've never had to take responsibility for anything ever in their pathetic little lives. If you use it, put it back when you're done. Someday, Mommy won't be around to clean up after you.
Frameworks ensure that your app looks just like every other app. Yay! Maybe round buttons will help? Nope, sorry.
(oh, b.t.w., )
-c
Smaller Animals Software, Inc.
|
|
|
|
|
I take it this thread is meant to spark some sort of debate. Well, let's get it on!
1. Imagine if C++ didn't have stack allocation of objects, just like Java or C#, where all objects must be allocated with new. Since C++ also doesn't have a garbage collector, you'd then need to remember to call delete for every object allocated. That would really suck! Everytime you'd need a string object, you'd need to do: string str = new string;, then you'd need to use the * and -> notation, and finally call delete str; before the block's end. Thankfully, the vast majority of objects used inside a typical C++ program can be allocated on the stack which: (a) cleans the objects memory, (b) calls the object's destructor, and (c) is very fast. However, for those times when the stack can't be used because the object needs to live outside the block, you need to use new and then remember to call delete afterward. I guess my point is that garbage collected languages completely eliminate this requirement, thereby making the code smaller and easier to write.
2. There are times in C++ when you need to retrieve an object from a function. The most common example is a string object. In garbage-collected languages this is a trivial operation since only the object's "handle" is passed back. In C++, it's more complicated because you want to avoid the overhead of calling the object's copy constructor. So you have to resort to elaborate schemes such as Copy-On-Write to minimize the overhead.
3. In C++ when you have a method that returns a pointer to an object (i.e., to avoid the overhead of copying), there's nothing to indicate whether this pointer should be deleted or not (short of making it const). Even worse, there's nothing to stop you from deleting that pointer and causing other code to break. With garbage collected languages this is not an issue since you're not allowed to delete anything. Only the gc knows when things are safe to be deleted.
4. I love C++! It has great features which I miss in Java and VB. However, as good as I've gotten at manual memory management, with smart-pointers, etc., I'd much rather have it all be done automatically for me, even if causes my app to run a little bit slower. Now, if I could have a language like that which would also give me deterministic finalization, I'd be in programming heaven.
Regards,
Alvaro
|
|
|
|
|
Personally I don't have any extreme view on the subject of GC. I don't think C++ language itself is against the concept of GC. GC may not be part of formal / standard C++ language spec, but there are dozens of C++ GC implementations we can find on the web.
The thing that really bothers me about GC driven frameworks is the absence of deterministic finalization, it's so convenient to use.
// Fazlul
Get RadVC today! Play RAD in VC++
http://www.capitolsoft.com
|
|
|
|
|
Fazlul Kabir wrote:
Personally I don't have any extreme view on the subject of GC. I don't think C++ language itself is against the concept of GC. GC may not be part of formal / standard C++ language spec, but there are dozens of C++ GC implementations we can find on the web.
Stroustrup actually considered garbage collection for C++, but knew he had to deliver a language within 5% of the speed of C or it would be stillborn. Given that it's obvious GC results in a speed hit, I think having the option to add the facility is the best solution all round.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Christian Graus wrote:
Stroustrup actually considered garbage collection for C++,
Exactly, here is the link where he talks about GC in C++. The link also discusses how C++ supports programming techniques that allows memory management to be safe and implicit without a garbage collector.
// Fazlul
Get RadVC today! Play RAD in VC++
http://www.capitolsoft.com
|
|
|
|
|
Testify to that, bro.
Sincerely Yours,
Brian Hart
"And that's the news from Lake Wobegon, where all the women are strong, the men are good-looking, and the children are above-average." - Garrison Keillor
|
|
|
|
|
Chris Losinger wrote:
Real programmers don't fear pointers;
<rant>
And real men don't fear knives; but... if i've got a fork handy, then i'll use that, rather than the knife, to eat with. Similarly, even though i can usually get by with a small flat-head screwdriver, having one that fits the screw i'm using is nice.
Pointers, gotos, long jumps, in-line assembler, mice, GUIs, modular languages, OO languages, structured exception handling, garbage collection, self-modifying code, jump tables, loops, recursive routines, interpreted languages...
The toolbox for programmers is large. Arguing that one tool should never be used, or that another should always be used is pointless, and insulting to the rest of us. If i'm developing a web page and the design calls for an animation, i could write a specialized native-code plugin, or i could just use an animated [.png/.gif] file. Depending on the situation, either might be appropriate, or one might be terribly, terribly wrong.
Finally, please remember: it is always a danger if the person using a language/library/framework does not understand what he/she is doing. Miss-using pointers is not the only way to corrupt data.
</rant>
farewell goodnight last one out turn out the lightsSmashing Pumpkins, Tales of a Scorched Earth
|
|
|
|
|
You are perfectly right.
Nothing other to say.
|
|
|
|
|
The poll has been up for most of the day, 128 people have voted, but only two comment have been submitted.
I'm amazed.
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Probably because CP was unusably slow last night. I would have been the first comment if I could get the page to load. I could read, but when I hit new comment it would just time out.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Someone had to say it.
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
.NET = more breasts at the office?
Change is gooood.
/Magnus
|
|
|
|
|
"No one knows what power lies yet undeveloped in that wiry system of mine."
Ada Lovelace 1815-1852
|
|
|
|
|
Cup-size too.
Nish
p.s. last time too it was you who started it and me who made into an epic thread, so thought this would be symbolic
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
Heaving breasts are even better
Normski. - Professional Windows Programmer
|
|
|
|
|