I just checked out a page at random.
Why are you referring to main as a "so-called" function? While not necessarily the wrong usage of that phrase, it tends to convey an ambiguous negative impression that might be confusing to some readers.Originally Posted by From-Your-Link
This paragraph sounds wrong. Someone new to programming might take that to mean: "When you see a semi-colon, that means the value of the expression before it is discarded".Originally Posted by From-Your-Link
You should be more clear about the fact that the value of the expression is discarded in that example because it is not being stored anywhere (which you get into a bit later), not because of the semi-colon.
Fair enough. Most tutorials and books exclusively teach the use of the [] operator, but why, when offered an option that guarantees safety, would you ignore it, and refuse to teach it? Refusing to acknowledge something that is objectively and demonstrably better, for an overwhelming majority of cases shows nothing but a stubborn nature on your part.
What can this strange device be?
When I touch it, it gives forth a sound
It's got wires that vibrate and give music
What can this thing be that I found?
erm..., i disagree with that one... saying they are both ways of containing data is close enough i'll grant that. And as for being terrible for beginners, I think they are a fundamental concept that aids understanding of the higher level types. Using them dynamically is harder sure, but the static allocation and access is so graspable before feature-rich containers come into a beginners picture.
Thought for the day:FLTK: "The most fun you can have with your clothes on.""Are you sure your sanity chip is fully screwed in sir?" (Kryten)
Stroustrup:
"If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"
That depends on the individual. Some don't care or grasp basic underlying concepts that are close to the hardware. Nor should they have to. An array should fulfill its function while exposing a rich, useful interface. That's std::vector and std::array in a nutshell. C arrays are dangerous and inherently low level.
massive no. not good ideain the chapter on for loops, you used a double for the loop index.
Thought for the day:FLTK: "The most fun you can have with your clothes on.""Are you sure your sanity chip is fully screwed in sir?" (Kryten)
Stroustrup:
"If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"
Perhaps "extending" the vector and string classes to provide rudimentary bounds checking as done by Stroustrup in Programming Principles and practices using C++?I'm open for suggestion. Suggest me a better way for beginners to avoid silently introducing an error into their program without using at(). I'm listening.
Jim
No one is ever going to do that. If everyone tried to provide helper functions for functions such as strcpy, et all, then much of the evil in the world wouldn't be here. Programmers are just too lazy to do that.
Besides, how is this different from using at(), which does exactly this anyway?
Because you wouldn't need use at() to have an exception thrown when using the array notation.Besides, how is this different from using at(),
And I'm not talking about programmers, I'm talking about our Tutorial Writer supplying a header file to be used with his tutorial.
Jim
I really dislike the tutorial. For someone who wants to explain things so much better and change the way things are taught, you sure are going down the well-trodden path. I'm not really sure what is so different; you are just taking a lot, lot longer to explain things.
Why aren't we programming anything cool? You have all these beautiful pictures of fractals and stuff. Teach around a nifty project like drawing a fractal - just as a suggestion - because one of the things that make programming worth it is doing something gratifying.
I hate to be so down on it but do you really want people to learn something useful or not? I doubt we'll get people who can do better than this at the current rate you're going:
10 PRINT "THIS IS MY COMPUTER, HEAR ME ROAR"
20 GOTO 10
There are plenty of places doing EXACTLY this in simpler languages than C++, and people are against that, too. Why are you different?
Its cool that you took this task on, to create the tutorial, and you hold your corner well, must have took a lot of dedication. but I feel it may have been done without any peer review as you wrote? And now a lot of holes appear when presented completely.
Thought for the day:FLTK: "The most fun you can have with your clothes on.""Are you sure your sanity chip is fully screwed in sir?" (Kryten)
Stroustrup:
"If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"
Wait, using at() is an ugly syntax? Seriously? I think it's very intuitive."Ugly syntax" is subjective, but the number of characters isn't. Two characters for [], 5 characters for .at().
Trying to write code using as few characters as possible is a bad way of coding. Use as many characters as is required to make code readable by another human being. The word "at" is very intuitive for humans (or at least for me). It makes sense that I'd try to find the value of a vector at position 5 or 10 or whatever I choose to type in.
The fact that it throws an exception is even better.
It appears that there are some very rude and stubborn people on this forum, so I have decided to have a conversation only with people who are polite. Also, I will be responding only to well-meaning comments and questions, and I also do not want to be dragged into a discussion with close-minded people.
Matticus: If you rise above the C++ perspective and think about programming languages in general, then ‘main’ is, generally speaking, not really a function, because it is not pure. It can be called a procedure or subroutine. This is mentioned in the tutorial only to instill some interest into the reader. The procedures will not be mentioned until the tutorial talks about graphics, in a much later chapter.
About discarding the value of the expression, I think that if you continue reading the tutorial there can be no such doubt as you are suggesting.
Elkvis: .at() is slightly better than operator [] with debugging checks, but the price to pay is huge. Consider:
- it’s three more characters, which does make a difference to a beginner
- It is different from the way other common programming languages do it
- It is different from the way that C++ programs and other tutorials usually do it. The beginner who was instructed to use .at() will not know about the operator[]. Then, in fact, you have to teach both ways and explain the difference. And then, in order not to confuse the beginner, you will have to choose again to use mostly one or the other. And then you went nowhere.
It is out of the question.
rogster001: Native arrays? This is a high-level tutorial. Low level stuff should not be in a tutorial for beginners. There was already a discussion before about using the word ‘array’ for vectors, and the conclusion was that vectors satisfy the requirements of array abstract data type.
whiteflags: I compared the pace of progression of my tutorial to other books and tutorials. Word-for-word, I am about 20% faster to arrays, functions, sorting. In general this tutorial is faster. This is at the expense of removing all the unnecessary details that burden other tutorials and books.
We are not programming anything cool because so far the tutorial has progressed only to arrays, which would approximately be at the page 80.
Elkvis: about .at() again, it does make sense to use it in a tutorial for people who already had some exposure to programming. Since at least 50% of the other C++ tutorials actually go too fast, and they are appropriate for such an audience, it would be ok for them to use .at(). But those tutorials are not for total beginners, in spite of what they claim.