Thread: New C++ tutorial for beginners - opinions wanted!

  1. #16
    Registered User
    Join Date
    Jul 2015
    Posts
    37
    Who says that I'm going to disregard the advice? I'm just explaining another perspective on issues, which might clarify some decisions and structure of the tutorial. That way I expect to get more informed feedback.

    Besides, there is absolutely no need for the feedback to be only a one-way process.

  2. #17
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    26,720
    A solution would be to write "array data structure", linking to DADS as in this statement.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #18
    Registered User
    Join Date
    Jul 2015
    Posts
    37
    Well, the C++ vector is both an array data structure and an array data type, but in the context of what the tutorial is explaining, and what I was thinking, the tutorial is actually talking about the data type.

    So I was thinking of adding an explanation to clarify the issue, but I am quite certain that the right thing for this tutorial is to talk about arrays and how to use them. This tutorial is about programming first, and about C++ second.

    And thanks for the comment!
    Last edited by Kevin C; 07-08-2015 at 08:55 AM.

  4. #19
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    26,720
    Quote Originally Posted by Kevin C
    Well, the C++ vector is both an array data structure and an array data type, but in the context of what the tutorial is explaining, and what I was thinking, the tutorial is actually talking about the data type.
    Err... no. A std::vector can be said to be an array (or "dynamic array") in the sense of an array data structure from computer science, hence my link to DADS. But it cannot be said to be of an array data type, for the type of a std::vector is definitely not that of a C++ array. Perhaps you are thinking of "data type" in the sense of "abstract data type", but then we would say that an array (as in a computer science sense), not a std::vector, is an abstract data type.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #20
    Registered User
    Join Date
    Jul 2015
    Posts
    37
    Yes, I was thinking about the array abstract data type. But I didn't quite understand the second part of your last sentence.
    Edit: oh, I got it.

  6. #21
    Registered User
    Join Date
    Jul 2015
    Posts
    37
    Well, yes, array is an abstract data type. I mean: that is one of the meanings of the word array. Well, we could also abstract the vector, but that would be uncommon terminology. But I think that we went into a digression.

    Edit: ah, I have eluded the word "abstract". Well, of course - I wasn't thinking of C/C++ arrays.
    Last edited by Kevin C; 07-08-2015 at 09:35 AM.

  7. #22
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    26,720
    Quote Originally Posted by Kevin C
    But I didn't quite understand the second part of your last sentence.
    Ah. As in a std::vector refers to a C++ standard library container, so calling it an abstract data type would be strange since its interface incorporates implementation concerns even though the standard does not mandate a particular implementation, whereas as the article that I linked to stated: "Ignoring size an array may be seen as an abstract data type with the operations new(), set(i, v, A), and get(i, A), where i is a numeric index, v is a value, and A is an array."
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  8. #23
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    26,720
    Okay, moving on, I noticed that in chapter 2 and then in the chapter on for loops, you used a double for the loop index. This is usually a bad idea due to floating point inaccuracy. I understand that you want to introduce types later, but perhaps it would be a good idea to introduce int before double?

    Likewise, I noticed that you only introduced counting from 0 in the chapter on arrays. I guess that you were trying to avoid information overload by introducing counting from 0 at the same time as for loops, but given the prevalence of such a convention in various programming languages (and even in some areas of computer science), I think that it would be wiser to introduce it earlier so as to develop the habit of counting from 0 even when sequence containers are not in use.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  9. #24
    Registered User
    Join Date
    Jul 2015
    Posts
    37
    Well, thank you for the thorough look at the tutorial!

    Using type double for the index is a bad idea, for many reasons, but it will work correctly even in the for loop. This 'practice' is abruptly discontinued when arrays are introduced (the arrays are in chapter 10, and the int type is in chapter 9). To quote from Printing out Arrays | Learn Programming with C++ :

    "In the given example, the loop variable i is of type int. Indices of arrays have to be integers, so whenever a variable is used as an index, it should be of an integral type. Considering that loop variables typically count the ordinal number of a loop iteration, which is always an integer, it is also customary to make loop variables to be of type int. This convention will be followed in all of our future programs, as well.

    When writing loops that iterate through elements of an array, it is crucial to pay attention to boundary conditions, that is, to correctly specify the range of indices. Since array indices begin with the number 0, the starting and final value of the loop variable i have been appropriately changed. The starting value is now 0, and the final value is 6. Notice that we have used the operator '<' instead of the operator '<='. Therefore, the variable i will range from 0 to 6, not from 0 to 7. Again, this is an idiomatic manner of writing for loops in the programming language C++."

    I think that the readers will acquire the mentioned habit, and besides, it's much easier to type in 'int' then type in the word 'double'.

    Yes, I'm trying to avoid the information overload. Well, it's all a compromise. I was of the opinion that the habit of counting from 0 is not that hard to acquire. The chapter 10 and all later chapters will follow the common convention.

    Perhaps the real reason is that earlier, there is no need to start counting from 0, and when the arrays are introduced, then there is finally a need, so it's easier to explain why.

  10. #25
    Registered User
    Join Date
    Jul 2015
    Posts
    37
    Perhaps I should have mentioned earlier that this tutorial is quite unconventional and quite different from all other tutorials I have seen. Simply put, there is an entirely new and different philosophy behind it. Of course, IMO, this is a better way to explain programming, and that is, perhaps, why I wrote the turorial. And I am quite certain, and I'm sure that many of you are aware of the fact that there is something quite wrong with conventional way of explaining programing, as there are so many people having serious problems with the conventional approach.

    Of course, this new approach has some other issues, and some people here might have already pointed them out. But the question is: are those issues more or less problematic than the ones in the common approach? IMO, the issues with this new approach are fairly minor in comparison.

    So, perhaps it would be good when reading the tutorial, to try not to insist on the way you learned prorgamming. Try to read the tutorial with the eyes of a true programming beginner, and try to spot the issues from that perspective.
    Last edited by Kevin C; 07-08-2015 at 11:54 AM.

  11. #26
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    26,720
    Quote Originally Posted by Kevin C
    Perhaps I should have mentioned earlier that this tutorial is quite unconventional and quite different from all other tutorials I have seen. Simply put, there is an entirely new and different philosophy behind it. Of course, IMO, this is a better way to explain programming, and that is, perhaps, why I wrote the turorial. And I am quite certain, and I'm sure that many of you are aware of the fact that there is something quite wrong with conventional way of explaining programing, as there are so many people having serious problems with the conventional approach.

    Of course, this new approach has some other issues, and some people here might have already pointed them out. But the question is: are those issues more or less problematic than the ones in the common approach? IMO, the issues with this new approach are fairly minor.
    You might want to elucidate this "unconventional" approach that you have in mind as I can detect no significant novelty in the learning material. For example, Stroustrup once wrote an essay on Learning Standard C++ as a New Language (PDF). Your teaching goals may be different, but writing out this "different philosophy" could help you (and us) understand more clearly what you are trying to do.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  12. #27
    Registered User
    Join Date
    Dec 2013
    Posts
    241
    So maybe "C++ tutorial" is not the appropriate name. I'd suggest "Programing concepts by C++ examples"

  13. #28
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,094
    Perhaps I should have mentioned earlier that this tutorial is quite unconventional and quite different from all other tutorials I have seen. Simply put, there is an entirely new and different philosophy behind it. Of course, IMO, this is a better way to explain programming, and that is, perhaps, why I wrote the turorial. And I am quite certain, and I'm sure that many of you are aware of the fact that there is something quite wrong with conventional way of explaining programing, as there are so many people having serious problems with the conventional approach.

    Of course, this approach has some other issues, and some people here might have already pointed them out. But the question is: are those issues more or less problematic than the ones in the common approach. IMO, the issues with this new approach are fairly minor.

    So, perhaps it would be good when reading the tutorial, to try not to insist on the way you learned prorgamming. Try to read the tutorial with the eyes of a true programming beginner, and try to spot the issues from that perspective.
    o_O

    Translation: "You professional programmers with decades of experience should ignore the technical faults in my pet project because snowflake."

    Repeating on Matticus, what is the point of asking for feedback if you are just going to disregard recommendations?

    *shrug*

    Perhaps, it would be good, when writing tutorials, to heed the guidance of experts. Try to write the tutorial with the aim of making more people into experts, and try to prevent instilling bad habits and impart poor information.

    Soma
    “Salem Was Wrong!” -- Pedant Necromancer
    “Four isn't random!” -- Gibbering Mouther

  14. #29
    Registered User
    Join Date
    Jul 2015
    Posts
    37
    About the name, it's "Learn Programming with C++", but if that is not clear enough, I'm thinking of changing it into "Learn Programming - with C++" (with the dash). What do you think about this?

    About the concepts, I'll have to write them down first, that is not easy to explain.

    I don't need translations, I write in the English language.
    Last edited by Kevin C; 07-08-2015 at 12:23 PM.

  15. #30
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by C++ Tutorial
    Now, try to execute this program just to see what the computer will make of it. An error dialogue will appear, and some text containing the words like "vector subscript out of range" may be displayed. Click the Abort button to terminate the execution of the program.
    You are assuming the Visual Studio IDE and compiler. This is NOT always the case. If people are using gcc and just compiling the usual way way (e.g. g++ source.cpp -o out.exe), then they will get NO error whatsoever! Beware!
    I really like to use vector's at function for debugging purposes. It will guarantee that you will always get an error if you do out-of-bounds accesses, whatever compiler you may be using. This is much better than in some cases such errors silently work when they shouldn't (it is undefined behavior after all).
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Researching C++ - Your Opinions Wanted Here!
    By McCrockett in forum C++ Programming
    Replies: 2
    Last Post: 11-08-2012, 09:38 AM
  2. Storing position/velocity of agents -- opinions wanted
    By Ocifer in forum C++ Programming
    Replies: 11
    Last Post: 02-03-2012, 04:06 PM
  3. Expert opinions wanted!
    By MK27 in forum Linux Programming
    Replies: 8
    Last Post: 11-01-2011, 10:14 AM
  4. Beginners Contest #2 For those who wanted more!!
    By ILoveVectors in forum Contests Board
    Replies: 16
    Last Post: 08-12-2005, 12:03 AM
  5. Opinions Wanted
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 03-04-2002, 09:56 AM

Tags for this Thread