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

  1. #46
    Registered User
    Join Date
    Jul 2015
    Posts
    37
    Or to clarify that: you would like me to change the entire philosophy of my tutorial, only to cover the C++language better, which is not a focus of the tutorial. I think you are unrealistic.

  2. #47
    Registered User
    Join Date
    Jul 2015
    Posts
    37
    Do first 20 programs a beginner makes need to adhere to all the best practices?

    Edit: Of course it is correct C++. All the prorgams will compile and run according to standard C++.

  3. #48
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by Kevin C View Post
    Or to clarify that: you would like me to change the entire philosophy of my tutorial, only to cover the C++language better, which is not a focus of the tutorial. I think you are unrealistic.
    No, I don't expect you to change your tutorial to focus simply on C++. I expect you to use best C++ practices where you cover the C++ bits. That's all.

    Quote Originally Posted by Kevin C View Post
    Do first 20 programs a beginner makes need to adhere to all the best practices?
    As much as possible, yes. They are BEGINNERS. They don't know better. You certainly don't want to send someone out there who writes bad C++ code. People pick up whatever they see on the net, you know. So do it right from the beginning. Use the best practices where appropriate.
    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.

  4. #49
    Registered User
    Join Date
    Jul 2015
    Posts
    37
    So, please, will you be so kind to highlight the piece of code from my tutorial that you deem not to be good enough for a beginner.

  5. #50
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    I already mentioned the use of at() instead of the index operator for out of bounds access.
    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.

  6. #51
    Registered User
    Join Date
    Jul 2015
    Posts
    37
    Ok, that covers many examples. But I think that using operator [] instead of .at() in tutorials and books is quite common. Perhaps you could point to me to some other reputable tutorials or books that employ the .at() operator so early and often to be in accordance with your suggestion.

    Edit: If that is such an indispensable best practice, I expact that most other tutorials and books are employing it,too.

  7. #52
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by Kevin C View Post
    But I think that using operator [] instead of .at() in tutorials and books is quite common.
    It is unfortunately pretty common since books focus mostly on the language and not things like debugging.
    Unfortunately, there are so many poorly written books out there too that I wouldn't have the slightest idea where to find a good book that uses best practices.
    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.

  8. #53
    Registered User
    Join Date
    Jul 2015
    Posts
    37
    You cant find even one? So, all the other books and tutorials are wrong, and you are right?

  9. #54
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Quote Originally Posted by Kevin C View Post
    You cant find even one? So, all the other books and tutorials are wrong, and you are right?
    Most tutorials and books gloss over best practices, in the interest of simplicity and/or expedience. Yes, the [] operator works. Using .at() is almost always better.
    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?

  10. #55
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    Quote Originally Posted by Kevin C View Post
    You cant find even one? So, all the other books and tutorials are wrong, and you are right?
    Well, that's being kind of literal about it.

    Code:
    std::vector::at()
    is a useful tool because it gives you a specific out of bounds exception (std::vector::at - cppreference.com)

    I would suggest coding in some way like this :
    Code:
    #define debug
    
    std::vector<int> x(1024, -1);
    
    #ifdef debug
    // code using at() method
    #else
    // code using [] instead
    #endif
    I think at() is slightly slower than just using [] but the safety and error response is worth it in applications you're prototyping or debugging.

  11. #56
    Registered User
    Join Date
    Jul 2015
    Posts
    37
    Ok, Elysia and others, let me say this:

    Sometimes it happens that we, people, have some idea, and it is a good idea and we like it. And then we get kind of stuck into that idea, and we are unable to percieve that in some other specific situation our idea is not that good, due to various specific circumstances.

    I know that using checked array access is better for beginners. But in C++, there are various circumstances that make that idea hard to employ. We have to be practical. I have made all attempts to mitigate the impact of not using a C++ standard way to do checked vector access. The readers will be instructed to use Visual Studio in Debug mode. Those using Code::Blocks with gcc will be employing _GLIBCXX_DEBUG. I think that more than does it, it is good enough, it practically as good as the real thing. Remember, this is a tutorial for beginners.

  12. #57
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    I know that using checked array access is better for beginners. But in C++, there are various circumstances that make that idea hard to employ.
    Like what? Using
    Code:
    std::vector::at(size_type pos)
    is incredibly simple O_o

  13. #58
    Registered User
    Join Date
    Mar 2015
    Posts
    184
    I was thinking that there are no really good C++ tutorials for total beginners, so I decided to create one.
    Perhaps you could point to me to some other reputable tutorials or books that employ the .at() operator so early and often to be in accordance with your suggestion.
    wut?

  14. #59
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    Like what? Using is incredibly simple
    O_o

    Simple? Yes, but typing the three extra characters can cause eye strain, carpal tunnel, and athlete's foot.

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

  15. #60
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by Kevin C View Post
    Sometimes it happens that we, people, have some idea, and it is a good idea and we like it. And then we get kind of stuck into that idea, and we are unable to percieve that in some other specific situation our idea is not that good, due to various specific circumstances.
    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.

    Quote Originally Posted by Kevin C View Post
    I know that using checked array access is better for beginners. But in C++, there are various circumstances that make that idea hard to employ. We have to be practical. I have made all attempts to mitigate the impact of not using a C++ standard way to do checked vector access. The readers will be instructed to use Visual Studio in Debug mode. Those using Code::Blocks with gcc will be employing _GLIBCXX_DEBUG. I think that more than does it, it is good enough, it practically as good as the real thing. Remember, this is a tutorial for beginners.
    How the heck is this more practical? You say you're trying to avoid specifically talking about C++, and then you tie yourself down to some specific IDEs and compilers and mess around with defines. Yeah, that's very C++ neutral.
    So let me ask you this: are you ever going to change your mind on this? I need to know if I can start ignoring giving you advice since you don't seem to be willing to listen anyway, despite several members here telling you using at() is simpler.

    There's no point talking to a wall, obviously.
    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