STL and newbies

Started by
129 comments, last by ChaosEngine 18 years, 11 months ago
Quote:Original post by Drew_Benton
True, but then if you say that, if the programmer is unable to see for themselves what is the best way, does it matter what way is suggested then?

Yea I kinda think it does. The programmer might be able to understand the concepts presented in the one solution and apply them later to solve some other problem where as the other solution not might be so usable except for this very special case.

Quote:Original post by Drew_Benton
I mean by you saying that "all kinds of not-related or missleading information should be avoided as far as possible" goes against the point of asking for help.

I was just trying to say that missleading information is far worse than none. "The only bad comments are incorrent comments." Sorry if I was beeing unclear.
Advertisement
Quote:Original post by doho
One shouldn't count on that a 12 year old newbie would investigate a highrated user posting about C++ features. I think that all kinds of not-related or missleading information should be avoided as far as possible.
You're talking about incomplete problem specification. Software development is problem solving, period. If you say you are trying to solve a problem and someone gives you the most efficient solution, you should be done unless you have a specific reason to prefer an alternative solution. And unless you share that constraint, or at least state that you have that constraint, the other individual has no reason to encourage you to learn inefficient methods of solving problems.

And before you argue that learning all the methods is good for general knowledge, the truth is that you will learn all the methods over time as you try to solve various problems with a variety of constraints. So, no.
Quote:Original post by Oluseyi
Quote:Original post by doho
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.
Stop whining. Use the standard library and get over your failures. We all have them, and that's why we encourage you to avoid them by using battle-tested components. That doesn't mean you don't need to learn how to use them properly, which is why documentation exists.

I simply started this thread because I was curious if many beginners had the same problems as I had. It has nothing to do with "getting over my failures".

Quote:Original post by Oluseyi
And before you argue that learning all the methods is good for general knowledge, the truth is that you will learn all the methods over time as you try to solve various problems with a variety of constraints. So, no.

That's a good point.
Quote:Original post by doho
Quote:Original post by Drew_Benton
I mean by you saying that "all kinds of not-related or missleading information should be avoided as far as possible" goes against the point of asking for help.

I was just trying to say that missleading information is far worse than none. "The only bad comments are incorrent comments."


You have an excellent point, but I am going to counter once again. If no misleading information was ever presented, then no one would bother to check out alternatives to what they have been told. Misinformation is the key to becoming a better thinker. If someone tells me that I can do something one way, and it is the easiest way, and it turns out that I thought it was quite hard, then someone else says there is an easier way by doing this and it turns out a lot easier, I am going to think twice before I take the first word for something again.

Sadly, most people do not do this, but ideally, it is what gets people to start 'thinking' about a problem rather than just accpeting what is told. A lot of beginners like being spoon fed, so it is a big hump to get over, but once they can get over that, then they are on the path of becoming a better programmer.

It should also ideally get to the point where a programmer can just try out the options rather than even ask about them. I mean each person is different and no one knows what someone else likes/dislikes. I mean it is always convient to have other people give you assistance on a problem, but you have to understand tha fact that these responses are biased and potentially incorrect. We are all human.

Anyways, Doho, I think you have a great thread as it raises a lot of good questions to what approaches should be taken when giving help. These are just my opinions, so I am by no means disagreeing with what you have said, I just like adding some other 'possibilities' to the frey for discussion [wink]. And ot go back to your first post:

Quote:I once started using STL without a good understanding of C, and it didn't take long before I was stuck in the corner with some difficult to read (probably template related) compiler error.


I am at that point right now! I started trying out STL and I have missed some very curcual pointscrucial points to where I am doing a lot of revising. Luckily though there are a lot of people on this forum with more Standard C++ Library experience that can help me out. [smile]

- Drew

[edit] Don't know how I butchered that word [lol] [/edit]

[Edited by - Drew_Benton on March 26, 2005 6:57:13 PM]
Quote:Original post by Drew_Benton
Anyways, Doho, I think you have a great thread as it raises a lot of good questions to what approaches should be taken when giving help.

Thanks Drew, I'm happy you also find these questions interesting.

Quote:
And ot go back to your first post:
Quote:I once started using STL without a good understanding of C, and it didn't take long before I was stuck in the corner with some difficult to read (probably template related) compiler error.


I am at that point right now! I started trying out STL and I have missed some very curcual points to where I am doing a lot of revising. Luckily though there are a lot of people on this forum with more Standard C++ Library experience that can help me out. [smile]

Yey :) I'm not the only one.
I think learning about some basic STL containers is doable. You don't have to become an expert on C++ to use them. If you need to modify them then that might be bit more involved and probably not suited for newbie. However I strongly recommend you buy a STL book in any case. One that shows you how to use STL by providing you with examples and clear explanations. If there was a need for only one book, then it would be for STL because there is so little about usage/modification of STL on the net or in docs. I think in the end you would want your own containers to be templated to be reusable across projects. I think STL is the best thing that has happened to C++ and it's just amazing in what short time it was implemented into the lang. The best thing is that STL abstracts pointers and memory manipulations and that is where lot of bugs happen if you write your own containers in C. Severely reduces memory leaks in my experience. You still have lots of opportunities to write your own data structures that STL doesn't provide and STL just takes some work from you and saves you time.
As many here might be aware, I am fundamentally against C++ as a language for beginners. It was never intended for beginners. It was intended for C programmers who wanted to make use of some aspects of object orientation. As it wasn't designed for beginners, why would anyone use it as such? A bit like using a screwdriver on a nail, if you ask me.

If you're having difficulties with data structures or algorithms, I suggest the following:
Learn Scheme (It was designed for beginners).
Read this book (The price is high, but the content per page is very high. Based on the net content, it's actually very cheap)

gl hf

(This should probably be in For Beginners)
Quote:Original post by flangazor
(This should probably be in For Beginners)
My thoughts exactly.
I'm not sure if I'm a beginner still or not.

Anyways, I think that beginners should be brought up exclusively on the STL. I certainly wish I'd been. Maybe I'd've been working on games for a while now instead of working for years learning how to properly build lists, and how to properly handle strings just so I could sort of get to game making. Only then to realise that the lists were not generic enough, or buggy, or designed with a flaw because I was too inexperienced to know I needed something...

That said, I also think the STL is too often suggested. Oddly it's usually suggested by non-experts, simply because that seems to be the thing to say. "Only n00bs write their own linked lists" seems to be the tone more often than not when the suggestion is made.

Still. Learning the STL from the start is a "good thing"(tm). It allows beginners to focus their time on learning, rather than infrastructure debugging or data structure design. It gets beginners thinking in more of a proper computer science mode rather than the usual procedural mode everyone is used to. It gets beginners better help, because experts don't have to read through [possibly buggy]linked list code to get to the meat of things.

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.

char * c = strcat(a, b);// Oops, that didn't make a new "string" in c, it caused c to point at a, and// added the b stuff to the end of a. Even if the beginner knew "how to use"// strcat, he still has to remember which order to put the parameters in -// dest-first isn't necessarily obvious.// Oops, who knows if there was enough memory allocated for that concatenation?// And who's going to clean that memory up anyway? Who even knows whether a and// b point at local buffers or at heap allocations?// Oh, and what kind of weird magical incantation is "strcat" anyway? And what// if I want a \0 in the middle of my string data? Oh, and let's not// forget possible performance issues due to not having a length-counted string.std::string c = a + b;// Readable, intuitive and does exactly what you would expect it to on both// a high level ("c is now the string representing the concatenation of a and// b, which are unchanged") and a low level (memory is allocated as needed, and// will be automatically cleaned up when the strings go out of scope; allows// storage of \0; maintains a length count).


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.

This topic is closed to new replies.

Advertisement