On Apr 21, 3:14 pm, NickC <[EMAIL PROTECTED]> wrote: > On Apr 15, 1:46 pm, Brian Vanderburg II <[EMAIL PROTECTED]> > wrote: [...] > Yeah, C++ does try to be helpful, and all of those automatic copy > constructor, assignment operator and destructor implementations screw > up royally when confronted with pointers (and being able to use > pointers is basically the whole reason for bothering to write anything > in C or C++ in the first place). Code which relies on these default > method implementations is almost certain to be rife with memory leaks > and double-free bugs. So instead of being a convenience, they become a > painfully easy way of writing code that silently does some very, very > wrong things.
When a class includes a pointer data member, there is no single, right way to handle it. C++ automatically generated member functions are defined so as to be consistent in dealing with *values*. Any C++ programmer that hasn't learnt this simple fact, shouldn't be trusted with any programming language. Python and especially Java will only make it harder to spot the mess he is making. > Other things like methods (including destructors!) being non-virtual > by default also make C++ code annoyingly easy to get wrong (without it > obviously looking wrong). I can see how that might be confusing for programmer coming from Python, but it's more natural for those coming from C. > The whole design of C++ is riddled with premature optimisation of > speed and memory usage in the default settings, instead of choosing > safe defaults and providing concise ways of allowing the programmer to > say "I know optimisation X is safe here, please use it". I absolutely agree. > And the result? Any serious project in the language has to adopt it's > own techniques for avoiding all those traps, and those techniques are > likely to eliminate any supposed optimisations provided by the choices > of the C++ committee, while filling a code base with boilerplate that > only exists for the purpose of working around defects in the language > design (Scott Meyers has written at length about the worst of these > issues, far more clearly and eloquently than I ever could [1]). Did you give up on C++ in the early nineties? Things have changed a lot since then. Many standard/commonly accepted solutions to the problems you mention can be found in the C++ standard library and in Boost (http://boost.org). With std::vector and boost::shared_ptr you can go an extremely long way without giving pointers any special considerations. Cheers, Nicola Musatti -- http://mail.python.org/mailman/listinfo/python-list