Thread: Whether C++ is a good starting language?

  1. #1
    Registered User
    Join Date
    Jun 2012
    Location
    Morden, UK
    Posts
    128

    Whether C++ is a good starting language?

    Hi everyone.

    I've been on the board for a little while now while I go through the basics of c++. Unfortunately I'm not really good enough to be able to help anyone else right now.

    I am wondering whether I would be better to learn a language with a simpler syntax for the beginning period of programming while I get my head around the actual logic rather than getting bogged down with the syntax of c++.

    I don't want an 'easy' route, more a logical one i.e. if I was to start with python, I would no doubt get further quicker, but would that be transferable to c++ seeing as the syntax is rather different.

    That is one thought in my mind. The other is telling me to stick with c++ only, because it will give me a very solid grounding and enable further skills such as attention to detail because it is so particular about syntax.

    Would one route have any advantages over the other? I'm kind of at that early stage practicing command line coding and thinking where exactly is this going? I don't have a particular program to make in mind, however, some kind of aim would probably be useful!

    I guess I'm trying to say sometimes I find the motivation dwindling a bit, but perhaps this is due to me not having any specific aims. I also know I don't have a a choice, I must learn programming in order to forge some sort of career as it is always the programming bit holding me back.

    I'm as far as functions/pointers at the moment after practicing loops for quite an extended period of time.

    I really enjoy programming and I get a huge sense of satisfaction when my small programs work and would love to be able to help out others here on the board as that in itself would be good practice.

    Has anyone got any advice for someone who clearly needs a bit of guidance?

    Thanks.

    Sam.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by samwillc
    I don't want an 'easy' route, more a logical one i.e. if I was to start with python, I would no doubt get further quicker, but would that be transferable to c++ seeing as the syntax is rather different.
    The general skills related to problem solving through programming will be transferable. Knowledge of certain programming paradigms will also be transferable. Even the syntax, although different, have some similiarities, though typically this is both a boon and a bane whenever you learn a programming language since you may automatically attempt to use similiar looking constructs in the new language as if they were the same as the language you already know, even if they differ.

    Quote Originally Posted by samwillc
    That is one thought in my mind. The other is telling me to stick with c++ only, because it will give me a very solid grounding and enable further skills such as attention to detail because it is so particular about syntax.
    Learning to program with other programming languages can also give you "a very solid grounding and enable further skills such as attention to detail because it is so particular about syntax". I don't see C++ as special in this regard.

    Quote Originally Posted by samwillc
    Has anyone got any advice for someone who clearly needs a bit of guidance?
    Since you are already well on your way with C++, stick with C++.
    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. #3
    Registered User
    Join Date
    Jun 2012
    Location
    Morden, UK
    Posts
    128
    Hi laserlight.

    That's helpful and gives me a few things to think about.

    When I first learned to play the guitar, it was very obvious when I was getting better. I could play more complex things, and I started to enjoy it more. Rather than just playing scales for hours on end I could make songs and play increasingly awesome solos! Well, what else would you want to do eh? What's rhythm guitar all about?!

    Anyway, maybe I can apply the same logic to this. For example, if I try some practice quiz programs, I will start finding out where I have improved/needs work. I feel this could be my problem right now as it feels very stagnant cracking open xcode, writing some nested loops and watching (in decreasing amazement each time) when an output appears. Or maybe it's my own fault for sticking at the same topic for too long without moving forward. This stems from a bit of paranoia that I will forget what I've learned!

    Sam.

  4. #4
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    The logical route is to keep up the work in two parts: reading suitable information, and keep practicing what you have learned, by attempting to solve a range of problems. When you take up some new problems, you'll need to dig into the books again.....

    Sometimes, when learning something new and complex with the guitar, you need to relax a bit and work through the scales in order to strengthen your fingers before proceeding. Similarly, when trying to do something more complex, you'll sometimes need to limber up the mind by working with some basic things, and refreshing other stuff you have learned before.

    The parallel for me was a martial art (my sister learned musical instruments, not I). When working towards a higher dan (higher black belt degree) ranking, I would divide my time between advanced material (the techniques and forms required for the dan grade), beginner techniques (basic strikes and blocks), and everything in between. I also spent time as an instructor, teaching people at all grades from beginner to my own dan grade. Teaching something to someone else - particularly someone who thinks differently than you do - is a useful technique for learning.

    Don't make the mistake of believing the basics are something to be gotten past and then ignored. I remember someone failing a dan grading when the instructor asked him to go through some forms that every beginner learns in the first three months - he knew the material, but did techniques more sloppily than was expected at his level. The same applies to C++.
    Last edited by grumpy; 01-17-2013 at 04:32 PM.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  5. #5
    Registered User
    Join Date
    Sep 2008
    Posts
    200
    My point of view is this: A programming language is a tool. Like any tool, you'll learn to use it however you use it. While at the start you'll need to practice the basics again and again, you really start learning it when you really start using it. You'll get used to (and good at) using the features you actually use in real life, and the rest doesn't really matter too much. For example, the majority of C programmers have no use for bit fields in structures, and so will be out of practice using them and possibly even have forgotten the syntax. This doesn't really matter, since this is because they never need to use them.

    The upshot of this is that you should try and actually do as much stuff as you can in your language. And when you do stuff, do it in the way you think is best, not the way that uses some new feature you've just learned about.

    As for your specific question about possibly learning a simpler language, I would advise you to. This isn't advice that everyone would agree with, just mine. I use both C and C++ quite extensively in my work, and C++ is an absolute behemoth of a language. And not just compared to C - I know Python, Java and Lisp all fairly well, and C++ easily dwarfs them by miles. I would say you should learn how to use C well first - this will let you learn things like how to organise and design programs while not getting bogged down in the extensive syntax and subtle semantics of such a huge language. Then when you want to learn C++ you can take the new features it gives you and put them to use where they can really help you in your next programs, as opposed to learning loads of abstract features that you can't clearly envision a use for (as I did in my early days).

    As for having started down the C++ route already, the stage you're at makes it sound like you won't have "wasted" a lot of time if you switch to C now.
    Programming and other random guff: cat /dev/thoughts > blogspot.com (previously prognix.blogspot.com)

    ~~~

    "The largest-scale pattern in the history of Unix is this: when and where Unix has adhered most closely to open-source practices, it has prospered. Attempts to proprietarize it have invariably resulted in stagnation and decline."

    Eric Raymond, The Art of Unix Programming

  6. #6
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Quote Originally Posted by JohnGraham View Post
    C++ is an absolute behemoth of a language
    those of us who use it every day would consider it feature-rich, and consider that a good thing. there is no requirement to use any particular feature if you don't want to, and you don't pay any overhead penalty for features you don't use.

    As for having started down the C++ route already, the stage you're at makes it sound like you won't have "wasted" a lot of time if you switch to C now.
    as for starting with C and moving on to C++ later, I, and many others on this forum will strongly disagree. C++ is an excellent language to start with, because (if you have halfway-decent instruction materials) it immediately exposes you to the high-level concepts, without the need to learn about the low-level stuff like char pointers and their associated functions. since most beginner-level C++ tutorials start out teaching the use of std::string, the intuitive use of operators for string manipulation comes naturally. instead of trying to remember what the return value of strcmp represents, or remembering to allocate space to use strcpy or strcat, you can simply use ==, = and +, like any other variable in C++.

    my position is this: don't "waste your time" on C, as a stepping stone to C++.

  7. #7
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    C++ is an excellent language to start with, because (if you have halfway-decent instruction materials) it immediately exposes you to the high-level concepts, without the need to learn about the low-level stuff like char pointers and their associated functions.
    I suppose it depends on where someone wants to focus their energy. Some people, for instance, want to code for embedded devices - in that instance, the low level concepts of 'C' might be more of a benefit, as they'd be working much closer to the hardware level.

    I'm not disagreeing with you in any way, just offering my two cents.

    instead of trying to remember what the return value of strcmp represents, or remembering to allocate space to use strcpy or strcat, you can simply use ==, = and +, like any other variable in C++.
    There is a creative way to copy strings with the assignment operator in 'C', though it's more of a "party trick" and not something I'd ever actually use in practice.

  8. #8
    Registered User
    Join Date
    Sep 2008
    Posts
    200
    Quote Originally Posted by Elkvis View Post
    those of us who use it every day would consider it feature-rich, and consider that a good thing.
    I appreciate that you're entitled to your opinion, but the above is an opinion dressed up as a fact, which it is not - please present opinions as opinions. I use C++ for approximately 50% of my workload (though it has been 100% in the past), and while I wouldn't disagree that the term "feature rich" certainly applies, I think "behemoth" or "gargantuan" more closely fits how I think of the language, especially when you're new to both the language and general programming concepts and program design.
    Programming and other random guff: cat /dev/thoughts > blogspot.com (previously prognix.blogspot.com)

    ~~~

    "The largest-scale pattern in the history of Unix is this: when and where Unix has adhered most closely to open-source practices, it has prospered. Attempts to proprietarize it have invariably resulted in stagnation and decline."

    Eric Raymond, The Art of Unix Programming

  9. #9
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Quote Originally Posted by Matticus View Post
    I suppose it depends on where someone wants to focus their energy. Some people, for instance, want to code for embedded devices - in that instance, the low level concepts of 'C' might be more of a benefit, as they'd be working much closer to the hardware level.
    you're absolutely right, but I was coming at it from more of a general learning-to-program perspective. if you have no predetermined direction, C++ makes a better first language than C.

    There is a creative way to copy strings with the assignment operator in 'C', though it's more of a "party trick" and not something I'd ever actually use in practice.
    maybe off topic, but care to share? I'm intrigued by this.

  10. #10
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Quote Originally Posted by JohnGraham View Post
    the above is an opinion dressed up as a fact, which it is not
    really? I think that using the word "consider" in that context implies an opinion. as an example, I consider myself to be a good programmer, but some others may not. it's an implicit statement of opinion.

  11. #11
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    maybe off topic, but care to share? I'm intrigued by this.
    My pleasure. Simply wrap the character array in a struct.

    Code:
    #include <stdio.h>
    
    #define MAX_LEN 40
    
    struct MyString
    {
        char mystring[MAX_LEN];
    };
    
    int main(void)
    {
        struct MyString stringA = {"This is a test."};
        struct MyString stringB;
    
        stringB = stringA;
    
        printf("%s\n",stringB.mystring);
    
        return 0;
    }
    It's definitely not perfect (can't assign string literals, etc), but interesting nonetheless. I was strangely delighted when I learned this little trick (from a book).

  12. #12
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by JohnGraham
    I would say you should learn how to use C well first - this will let you learn things like how to organise and design programs while not getting bogged down in the extensive syntax and subtle semantics of such a huge language. Then when you want to learn C++ you can take the new features it gives you and put them to use where they can really help you in your next programs, as opposed to learning loads of abstract features that you can't clearly envision a use for (as I did in my early days).
    On the other hand, with suitable guidance*, you could learn how to use the facilities provided by the C++ standard library to quickly get up to speed in solving problems with programming, and thus acquire more of this transferable skill. Like JohnGraham, I often say that a programming language is a tool, but I guess you could picture it as more of a toolbox: C++ offers a wide array of tools, but not all the tools are good or suitable for the occasion.

    * The suitable guidance that I suggest comes in the form of Accelerated C++ by Koenig and Moo. Although the book is a bit dated, it is still good, and the approach used in that book has some of what Stroustrup recommends in his paper on Learning Standard C++ as a New Language, i.e., an approach that:
    • proceeds from the concrete to the abstract,
    • presents language features in the context of the programming and design techniques that they exist to support,
    • presents code relying on relatively high-level libraries before going into the lower-level details (necessary to build those libraries),
    • avoids techniques that do not scale to real-world applications,
    • presents common and useful techniques and features before details, and
    • focus on concepts and techniques (rather than language features).
    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

  13. #13
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Quote Originally Posted by Matticus View Post
    It's definitely not perfect (can't assign string literals, etc), but interesting nonetheless.
    interesting as an example indeed, but like you say, nearly useless for real-world code.

  14. #14
    Registered User
    Join Date
    Sep 2008
    Posts
    200
    Quote Originally Posted by Elkvis
    those of us who use it every day would consider it feature-rich, and consider that a good thing.
    Quote Originally Posted by Elkvis View Post
    I think that using the word "consider" in that context implies an opinion.
    It does imply an opinion, but here you're making a factual assertion about the opinions of others, which is not the same as expressing your own opinion. If I say "I consider myself a good programmer", that's a statement of my opinion. If I say "Linus Torvalds considers me to be a good programmer", that's a statement of fact about an opinion of Mr. Torvalds' that he has presumably conveyed to me. In your case, you were stating (in a factual manner) that some group of people have such-and-such an opinion. If you'd said that you consider it a good thing, then that would be stating your opinion.
    Programming and other random guff: cat /dev/thoughts > blogspot.com (previously prognix.blogspot.com)

    ~~~

    "The largest-scale pattern in the history of Unix is this: when and where Unix has adhered most closely to open-source practices, it has prospered. Attempts to proprietarize it have invariably resulted in stagnation and decline."

    Eric Raymond, The Art of Unix Programming

  15. #15
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Quote Originally Posted by JohnGraham View Post
    It does imply an opinion, but here you're making a factual assertion about the opinions of others, which is not the same as expressing your own opinion. If I say "I consider myself a good programmer", that's a statement of my opinion. If I say "Linus Torvalds considers me to be a good programmer", that's a statement of fact about an opinion of Mr. Torvalds' that he has presumably conveyed to me. In your case, you were stating (in a factual manner) that some group of people have such-and-such an opinion. If you'd said that you consider it a good thing, then that would be stating your opinion.
    six of one, a half dozen of the other. let's get back on topic.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to develop good logic in C language
    By rocky in forum C Programming
    Replies: 3
    Last Post: 02-19-2006, 08:52 AM
  2. Java as a Main Language in College Won't Do Good
    By alphaoide in forum A Brief History of Cprogramming.com
    Replies: 23
    Last Post: 01-01-2006, 10:02 AM
  3. Good books on the language?
    By homeyg in forum C++ Programming
    Replies: 1
    Last Post: 12-03-2004, 06:43 PM
  4. Good colleges for language study
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 10-16-2004, 08:30 PM
  5. Good site to learn about Prog. language concept?
    By Extrovert in forum Tech Board
    Replies: 5
    Last Post: 03-13-2003, 02:46 AM