Thread: Check word

  1. #16
    Registered User cstryx's Avatar
    Join Date
    Jan 2013
    Location
    Canada
    Posts
    123
    Quote Originally Posted by Elysia View Post
    It is not smart. Many people have problems dealing with high complexity from the start. To take an example, if you're going to teach someone how a car works, are you going to teach them exactly how the engine works first or are you going to teach them what components there are and how they connect? Furthermore, the teaching time is limited. It is better spent teaching people how to use building blocks to piece a program together than wasting time teaching people exactly how a computer works. That can be delegated to a computer architecture course.
    If C++ didn't exist, are you saying that people would not be capable of learning C in that case because they have to deal with null-terminators? IMO C is actually an easier language than C++ because there is more to the C++ language over C, even though C doesn't have a lot of the features that C++ has by default, and in which case typically means that you have to write your own implementation rather than using some generic implementation that already exists for something.

    You've got to start somewhere is all I'm saying. But to start off with std::string, then learning about the allocators and template stuff involved, along with polymorphism, and iterators behind the mystery of the std::string typedef, to me, is not much easier than just learning how null-terminated strings work.

    Quote Originally Posted by laserlight View Post
    That is certainly true: abstractions leak, so if you know what is behind the abstractions, you are in a better position to make decisions in the face of such leakage. However, if actually read the article, you would see that the approach "presents code relying on relatively high-level libraries before going into the lower-level details (necessary to build those libraries)" and "presents common and useful techniques and features before details". That is, the details will eventually be explored, but where applicable the use of relatively high-level libraries will be presented first.
    I can see your point, and I also agree with it, as well as my own sadly... For that reason, I can see this is a very subjective matter and that there's no real way to dictate the way someone should learn about strings because everybody has a different way of learning, and there are many other factors that decide how well someone will learn a concept one way vs another, including previous programming history, and others.
    Last edited by cstryx; 08-29-2015 at 01:44 PM.

  2. #17
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by cstryx
    IMO C is actually an easier language than C++ because there is more to the C++ language over C, even though C doesn't have a lot of the features that C++ has by default, and in which case typically means that you have to write your own implementation rather than using some generic implementation that already exists for something.
    Have you read the article that I linked? Stroustrup gives examples of plausible C and C++ beginner programs for comparison. Yes, C++ is a bigger language, so in terms of language mastery C is an easier language than C++, but here we're looking at beginnings, not what is advanced.

    Quote Originally Posted by cstryx
    You've got to start somewhere is all I'm saying. But to start off with std::string, then learning about the allocators and template stuff involved, along with polymorphism, and iterators behind the mystery of the std::string typedef, to me, is not much easier than just learning how null-terminated strings work.
    No, that is a poor approach: allocators and the template machinery behind std::string would be details that should come later.
    Last edited by laserlight; 08-29-2015 at 01:46 PM.
    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 cstryx's Avatar
    Join Date
    Jan 2013
    Location
    Canada
    Posts
    123
    Quote Originally Posted by laserlight View Post
    No, that is a poor approach: allocators and the template machinery behind std::string would be details that should come later.
    Exactly, but null terminated strings vs the usage of std::string -- which should come first? This is what I had in mind when I brought up subjectivity. And where should dynamic allocation come in? When and how should you learn how the allocators do this?

    I think if someone is determined enough and believe they are ready for learning something more complex, they can and maybe should go for it. There's a chance that they may give up and be frustrated, but there's no saying if you live in fear and stay away from that stuff forever. For programming, I highly believe mental barriers and determination as well as motivation to learn are like the training wheels on a bike.

    Cheers!

  4. #19
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by cstryx View Post
    If C++ didn't exist, are you saying that people would not be capable of learning C in that case because they have to deal with null-terminators?
    No, of course not. You're going to have to deal with it if you're going to learn C. But if you're learning a language that has a string class, then why bother with null-terminators?

    IMO C is actually an easier language than C++ because there is more to the C++ language over C, even though C doesn't have a lot of the features that C++ has by default, and in which case typically means that you have to write your own implementation rather than using some generic implementation that already exists for something.
    If we're talking about learning the entire language, sure. But C++ is easier to learn in the sense that you have less to code to put together a program than C.

    You've got to start somewhere is all I'm saying. But to start off with std::string, then learning about the allocators and template stuff involved, along with polymorphism, and iterators behind the mystery of the std::string typedef, to me, is not much easier than just learning how null-terminated strings work.
    Better put off those topics to an advanced course. Chances are you won't have to care much about allocators at all.

    Quote Originally Posted by cstryx View Post
    I think if someone is determined enough and believe they are ready for learning something more complex, they can and maybe should go for it. There's a chance that they may give up and be frustrated, but there's no saying if you live in fear and stay away from that stuff forever. For programming, I highly believe mental barriers and determination as well as motivation to learn are like the training wheels on a bike.
    There's no denying that, but the discussion was about whether learning the magic behind string before learning about string was a good teaching method.
    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.

  5. #20
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by cstryx
    Exactly, but null terminated strings vs the usage of std::string -- which should come first? This is what I had in mind when I brought up subjectivity. And where should dynamic allocation come in? When and how should you learn how the allocators do this?
    Well, there will certainly be some subjectivity as to exactly which subset of C++ should be taught first, as Stroustrup explained in that article. However, I think your specific scenarios are fairly easy to address:

    The usage of std::string should be taught before null terminated strings, with the exception of string literals. As pointed out in the article, the reason is that this allows beginners to solve problems involving strings without going into details that can be introduced later, e.g., dynamic memory allocation to expand a string.

    Dynamic allocation should be introduced after containers, classes and pointers are taught as this would be a point where the student has a grasp of how to use containers and also has the tools to implement basic RAII.

    Going into allocators in depth is probably beyond the scope of an introductory course, though after learning dynamic memory allocation, RAII and having the experience of implementing a dynamic array container, perhaps the student could be introduced to the usage of the standard allocator.
    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

  6. #21
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    Oh God, designing a STL-compliant allocator is so gory. It's more gory than the Human Centipede 2.

  7. #22
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738
    Quote Originally Posted by MutantJohn View Post
    Oh God, designing a STL-compliant allocator is so gory. It's more gory than the Human Centipede 2.
    Wohohohow... I think you didn't intend to, but you know you just destroyed many curiosity-driven people, right? I mean, omg...

    What's hilarious and seriously frightening though, is that although I haven't done any serious STL business like that, I have a feeling you're not exaggerating...
    Devoted my life to programming...

  8. #23
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    MutantJohn is exaggerating. Pre-C++11 allocators were indeed gory, but the new minimal allocators aren't that bad.
    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.

  9. #24
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    Quote Originally Posted by GReaper View Post
    Wohohohow... I think you didn't intend to, but you know you just destroyed many curiosity-driven people, right? I mean, omg...

    What's hilarious and seriously frightening though, is that although I haven't done any serious STL business like that, I have a feeling you're not exaggerating...
    Elysia is probably right. Getting a minimal allocator working isn't that bad but of course, minimal is minimal. Writing custom allocators is something I've been really wanting to do but sorely lack the motivation to do so.

    You know what, I'm gonna do it. To google!!!

    Edit : Oh yeah, that movie totally made me kind of sick to my stomach the first time I saw it but now that I look back on it, I see that it was done to just do exactly that. You gotta love movies like that lol.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 01-04-2015, 04:07 AM
  2. Replies: 3
    Last Post: 03-22-2014, 10:46 PM
  3. Replies: 2
    Last Post: 09-23-2013, 08:10 PM
  4. Replies: 28
    Last Post: 10-23-2011, 07:17 PM
  5. check if user input matches a word
    By fakebloo in forum C++ Programming
    Replies: 1
    Last Post: 12-05-2004, 07:12 PM

Tags for this Thread