STL and newbies

Started by
129 comments, last by ChaosEngine 18 years, 10 months ago
Just a question - does the lack of regard for the Standard Library arise because it's not seen as an integral part of the C++ language?

Jim.
Advertisement
Quote:Original post by JimPrice
Just a question - does the lack of regard for the Standard Library arise because it's not seen as an integral part of the C++ language?

Jim.


To be honest, I just think a lot of people have no idea it's there, so they don't use it. I'm just saying this because I had NO idea it existed until someone had said something on GameDev to me about using it.
Quote:Original post by Zahlman
Quote:Original post by doho
Quote:Original post by Oluseyi
C++ is not a beginner language. That is, it is not targeted at beginners, nor does it have features that make it particularly well-suited to beginners, so when used by a beginner there are a lot of risks that come with it. But that is all beside the point.

This is actually exactly the point I was trying to make! When a question is asked about copying a string or something other in the line of this, it is safe to assume that questioner is a beginner. And as you say, C++ is not a beginner language and as such I don't see why the "experts" are calling advanced C++ features out loud as some cure to everything.


That would be because using those features is easier and results in working code.



Quote:I am just trying to fight the right for the pitty beginner that is having great difficulties with his/her first tictactoe game when they have just been suggested to use tons of advanced C++ features.


They only seem advanced because you know something about C and/or because of C++'s bend-over-backwards-compatibility.


In all fairness, the STL -is- advanced, if only for the reason doho describes above: template compiler errors are more... arcane than those that are not. The majority of a beginner's time is spent debugging, not coding. But perhaps I am not understanding you correctly?
Stickied. Keep the good stuff coming.

I pretty much agree with Drew and Oluseyi. Using the C++ Standard Library isn't and advanced topic (even though its implementation is). There are a couple things you've got to learn (instanciating containers with the desired element type, iterating, using the standard algorithms), but it is much simpler than 'pointers' and 'strings' - as beginners tend to approach them (the C way).

Before even bothering to learn how to implement any given data structure, a programmer should learn how to use it. I see too many people struggling to create a linked-list class and then slap an (inefficient!) indexing operator onto it. This only shows that not only they don't understand the data structure they've implemented (countering the "learning experience" argument), but then, they use it in production code (their "game engine") and end up with a slow, often buggy program. Then, what's the point?
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Quote:Original post by Telastyn
In all fairness, the STL -is- advanced, if only for the reason doho describes above: template compiler errors are more... arcane than those that are not.


Beginners often don't even *read* error messages, much less try to understand them. Most 'template' errors involving the STL, as opposed to templates you roll out yourself, are just plain type mismatch (which generally pop up as "can't convert FOO to BAR"), or unavailable operations (when you've got the wrong kind of iterator). Granted, they're often more verbose, due to the sheer length of STL type names, but they're not arcane. (Use the boost::mpl and you'll see arcane errors).
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Highly effective sir! I was like what is that red stuff at the top now [lol] As for error messages with STL, there is always: STL Error Decryptor for C++. A lot of people do not know about that as well.
Quote:Original post by Fruny
Quote:Original post by Telastyn
In all fairness, the STL -is- advanced, if only for the reason doho describes above: template compiler errors are more... arcane than those that are not.


Beginners often don't even *read* error messages, much less try to understand them. Most 'template' errors involving the STL, as opposed to templates you roll out yourself, are just plain type mismatch (which generally pop up as "can't convert FOO to BAR"), or unavailable operations (when you've got the wrong kind of iterator). Granted, they're often more verbose, due to the sheer length of STL type names, but they're not arcane. (Use the boost::mpl and you'll see arcane errors).


Eh, I'm not sure I'd agree with that. Most beginners seem to at least try and resolve their errors, even if most also give up quickly. I'd argue that the verbosity [indeed, perhaps a better term than arcane in this case] disuades most beginners from even that cursory investigation.

But still, that's not an argument anyone can win, and probably is best left to its own thread.
Quote:Original post by JimPrice
Just a question - does the lack of regard for the Standard Library arise because it's not seen as an integral part of the C++ language?

Jim.


Perhaps.

Personally, I think it's because it's always at the back of the book [at least the books I've seen], after "worse" things that do the same function. People tend not to want to relearn how to do something. And learning the STL is harder [imo] too at that point, since many of the ways it does things are very different from the "worse" ways.
Quote:Original post by Oluseyi
Quote:Original post by flangazor
(This should probably be in For Beginners)
My thoughts exactly.

Probably a good idea so that we can hear the beginners experiences with C++ and the Standard C++ Library. After all it is their views that are important.
I'll just respond with a short response. ( Remember, this is coming from someone who knows the basics of C++. o_O )

Well, I rarely use the 'advanced' features of the STL because I've never needed to. ( Example:

template< typename Ty_ >class Foo{   Ty_ Bar;};


( that's a -basic- example. ) )

But, all in all, I found nothing hard about the basics. Yes, I have gotten errors while using templates, but they were only because of stupid typos. (ex. forgetting to close a brace. )

This topic is closed to new replies.

Advertisement