quote:Original post by tok_junior
All i'm saying is that he should learn the pros and cons of (for example std::vector) and the "old" way of doing it.
When learning a language, one has to be selective about which features to learn when. It makes most sense to learn the techniques which are going to produce good results quickest. In this case, std::vector has very real benefits over an array, as detailed here. And not only is it wise for learners to prefer std::vector, it's also what clueful professionals do too, such as myself. I haven't used a plain array in my C++ code in a long time, and I've certainly not suffered any ill-effects.
quote:
A regular array is for example a lot faster than std::vector
As ever, the rule here is to profile before deciding what's "faster" for a given situation. If, for example, you have a section of code where a vector is processed during 0.01% of your program, then it is going to incredibly naive to want to optimise that code, possibly at the expense of significant time and effort. Another thing to consider is that, for the functionally equivalent intersection of array and vector characteristics, it's fairly unlikely that there will be any noticeable performance difference, since a vector *is* an array behind the scenes. For operations which can't be performed with an array, there is no comparison to be made.
quote:
it's WAY easier to debug
A debugger is a facility of your compiler toolset, not of the language. You can't make the claim that you know a vector is "easier" to debug on all debuggers in existence, since I'm very sure you don't know of all such debuggers. Furthermore, without setting out the criteria for what you mean by "easier", it's not clear exactly what you are talking about. Debugging is a high-cost technqiue for getting programs to function correctly, and there is far too much emphasis put on hacking programs into shape through such ad-hockery. We should emphasise achieving correctness early, through approaches like test-first or design-by-contract. It is easier to achieve correctness early on when you use the language features that are easier to use correctly.
quote:
and a lot less complicated to profile.
Huh? How so? And what does a newbie want to be running profilers for? Once you are the stage where you can make effective optimisations in your code, then you are no longer a newbie.
quote:
If you want to learn a language, you're better off learning it, instead of just learning enough to achieve what you want in an easy way that you don't understand.
Given that there's no possibility of learning *everything* in one hit, it makes great sense to learn the language features which achieve what you want in the easiest manner possible. That's the economics of learning for any topic. You don't suddenly dive in and make life as difficult for yourself as possible when there's an easier alternative well within reach. How exactly do you justify making things harder than they need to be?
quote:
Your way of thinking is why games of today won't run anywhere near to smoothly on a system without tons of ticks and a dx8+ gfxcard.
I'm not talking about making million dollar games, you numbskull. I'm talking about doing what is best for StormUK's program. That said, I'll wager use of std::vector won't impose a significant performance penalty for the majority of uses.
quote:
If people were actually interested in learning, and took the extra day o two, a lot of the software of today would be of a lot higher quality.
Right. It wouldn't have all the array overruns, buffer overflows and the like. You get better quality through making it easier for the programmer to achieve correctness, not harder. Your attitude of obsessing over efficiency before even having a correct program is far more responsible for bad quality s/w than probably any other factor (the decision to use C or C++ is another significant factor). StormUK's program doesn't work. What does it matter how fast it can go wrong? Premature optimisation is the root of all evil.
quote:
One example, take the standard A* pathfinding algorithm, which in 99% of the cases are implemented using linked lists.
What does that have to do with it?
quote:
STL aren't the answer to everything.
I've already pointed out that such a comment is insipid rhetoric. Please stay away from such debating devices.
quote:
Sure, the templates are wonderful for a lot of things, but to actually make the computer perform it's best, you need to know when to use them, and when not to. And without learning the basics first, you won't be able to.
The basics are the things which offer the required functionality in the simplest manner possible, not in the most brain-damaged manner possible.
[edited by - SabreMan on March 9, 2003 9:53:16 AM]