Hey there Sign in to join this conversationNew here? Join for free

New to computer programming? C++

Announcements Posted on
TSR Movie Madness is down to only 8 films! Help decide on the final 4 now! 15-07-2014
    • 3 followers
    Offline

    ReputationRep:
    Many people around me are Java and C++ coders, and all of them have said Java is a lot harder. I have attempted to learn both of them in the paste, I got quite far with Java by learning from pre-coded stuff (someone elses work), then I learnt how it all worked and would edit things in to it.

    C++ on the otherhand, I never even wrote more than a few lines of code. :/
    • 13 followers
    Offline

    ReputationRep:
    (Original post by Tootles)
    The neg's because you said C++ is a bitch. It isn't. C's a bit of a bitch, but it's still fun. C++, however, is a simple enough language to be your first.
    Did you neg this post as well?

    (Original post by Psyk)
    You don't really have to worry about OO stuff with C++, it's not forced on you. You can code C++ in a procedural way like C if you want. But perhaps it would be less confusing to use C instead.
    If someone disagrees with what I said, I'd appreciate an explanation why. Maybe they will convince me I'm wrong. Perhaps I have overlooked something. Or mabe they just meant to hit the pos rep button instead
    • 23 followers
    Offline

    ReputationRep:
    (Original post by Psyk)
    Did you neg this post as well?



    If someone disagrees with what I said, I'd appreciate an explanation why. Maybe they will convince me I'm wrong. Perhaps I have overlooked something. Or mabe they just meant to hit the pos rep button instead
    What I meant was that C++ allows you to do really simple stuff in a simple way, and you can progress to more advanced stuff without needing to learn a new language, upto OOP to API code and event-driven, especially if you're using Visual C++, which makes it quite easy to write full windowed OOP, event-driven programs.
    • 13 followers
    Offline

    ReputationRep:
    (Original post by Tootles)
    What I meant was that C++ allows you to do really simple stuff in a simple way, and you can progress to more advanced stuff without needing to learn a new language, upto OOP to API code and event-driven, especially if you're using Visual C++, which makes it quite easy to write full windowed OOP, event-driven programs.
    So I guess it wasn't you that negged me, we seem to be in agreement

    My point was kind of similar. The fact that C++ has object oriented features, it doesn't mean you have to use it. You can learn standard procedural programming with C++ before progressing onto OOP.
    • 1 follower
    Offline

    ReputationRep:
    (Original post by Hanvyj)
    I said it was a bitch because you have to deal with memory management. Which you do, and - as someone who learned Java first I find hard - hence why C++ is really a better language to start with. Memory leaks are one of the hardest things to track down.

    Your example has no memory management and shows some code so basic its pretty much going to be simple in any language.




    I guess I must apologise profusely for having such an incorrect opinion.
    For simple programs you do not have to bother with memory management at all any more than you have to with BASIC or most other languages. It is only when you are allocating dynamic storage that you have to consider this; this is more advanced programming,
    • 1 follower
    Offline

    ReputationRep:
    (Original post by DYKWIA)
    I would in general agree, C++ isn't the best language for a beginner. While it's possible to learn to program in anything - after all you want to learn to program, and any language can do that, why would you when there are far better options out there? Would you learn to fly a plane in a 747, or would you learn in a Cessna? The very fact that the vast majority of introductory programming courses teach a very high level language, such as Python, Ruby, Java etc. should be an indicator that there are good reasons to start off with a simpler language.

    Is it really a good idea to expose someone to garbage collection or hash tables before they have even encountered loops, conditionals, sequences, mutability, aliases - the building blocks of programming? Once you have learned these fundamentals, then perhaps move onto another language - it's not like once you learn one language you are stuck in that language for life! It's always a good thing to have a range of languages at your disposal, and learning an easier one to begin with isn't a waste. Heck, do you know how many businesses use Python as their primary language? Answer - a lot.
    No, it not a good idea to expose people to garbage collection or hash tables before they have encountered loops, conditionals etc - that would be stupid. You don't need to do this in C++ either, so why make out that you do? Have you ever seen any books on C++ that take this approach. I certainly haven't. Most of the ones that I have read give a basic overview and then deal with the more basic concepts first.
    • 1 follower
    Offline

    ReputationRep:
    (Original post by Tootles)
    The neg's because you said C++ is a bitch. It isn't. C's a bit of a bitch, but it's still fun. C++, however, is a simple enough language to be your first. How hard is

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main(void) {
      int i;
      for(i = 1; i <= 100; i++) {
        cout << i^i;
      }
      return 0;
    }
    to understand?
    Quite straighforward but I would not have included the ^ operator in my first example programs.
    • 0 followers
    Offline

    ReputationRep:
    (Original post by tonyhawken)
    For simple programs you do not have to bother with memory management at all any more than you have to with BASIC or most other languages. It is only when you are allocating dynamic storage that you have to consider this; this is more advanced programming,
    Beyond simple "Hello World" level programs, odds are that you'll need to do it in some form or another.
    Memory allocation is not something that you can just file away as an "advanced" topic.
    • 13 followers
    Offline

    ReputationRep:
    (Original post by tonyhawken)
    For simple programs you do not have to bother with memory management at all any more than you have to with BASIC or most other languages. It is only when you are allocating dynamic storage that you have to consider this; this is more advanced programming,
    But the point is in C++ you could only write quite trivial programs without doing any allocations. I wouldn't say that's "advanced", it's required to do much useful with the language. There are ways to avoid doing dynamic allocations, but in some ways that's an even more advanced topic as it can be less intuitive.

    Anyway, memory allocation at it's most basic isn't very complicated. The only knowledge you need is the difference between the stack and the heap, and that if you allocate on the heap you need to free it.
    • 0 followers
    Offline

    ReputationRep:
    I Recommend you start with C# for those Reasons
    1-Because it's a Clone so if you wanted to shift to Java it would be easy and they are pretty much the same
    2-Beacause it Do look like Visual Basic Way so it's Extremely Easy
    3-Because She is a "C" Family Member So it Has a lot in common with c and C++
    4-it's Good for Writing A.I (not that Great) and OS Kernel


    But if you insist to use C++ I recommend C++ For Dummies Which is Here Link : Here
    and Book to Complete the Journey Here

    Enjoy!!
    • 1 follower
    Offline

    ReputationRep:
    (Original post by JGR)
    Beyond simple "Hello World" level programs, odds are that you'll need to do it in some form or another.
    Memory allocation is not something that you can just file away as an "advanced" topic.
    Oh yes it is, and it is typically how most text book writers see it. You do not even have to consider memory management unless you are using dynamic storage - ie creating data structures with linked lists etc. This is usually covered in the second year of a computer science course and for that reason will not be covered by someone who is starting to program for the first time and quite possibly is not studying Computer Science at University.
    • 1 follower
    Offline

    ReputationRep:
    (Original post by Revo)
    I Recommend you start with C# for those Reasons
    1-Because it's a Clone so if you wanted to shift to Java it would be easy and they are pretty much the same
    2-Beacause it Do look like Visual Basic Way so it's Extremely Easy
    3-Because She is a "C" Family Member So it Has a lot in common with c and C++
    4-it's Good for Writing A.I (not that Great) and OS Kernel


    But if you insist to use C++ I recommend C++ For Dummies Which is Here Link : Here
    and Book to Complete the Journey Here

    Enjoy!!
    I would not recommend the C++ for dummies book as it is crap. There are many good books on C++ for all levels of ability, so why use the dummies book.

    Also, why would you want to use a programming language that has certain features that resemble another language. It reminds me of the current advert for the Volkswagen Golf.
    • 1 follower
    Offline

    ReputationRep:
    (Original post by Psyk)
    But the point is in C++ you could only write quite trivial programs without doing any allocations. I wouldn't say that's "advanced", it's required to do much useful with the language. There are ways to avoid doing dynamic allocations, but in some ways that's an even more advanced topic as it can be less intuitive.

    Anyway, memory allocation at it's most basic isn't very complicated. The only knowledge you need is the difference between the stack and the heap, and that if you allocate on the heap you need to free it.
    This also is not true. You can write quite sophisticated programs without having to bother with memory allocation. And, even if you do, this is not a big problem - it is a relatively easy matter to implement. You are making it sound that having to do this is ever so difficult and so should be avoided at all costs.

    Admittedly you don't have to bother with this in Java as it is done for you. But then there are features in Java that make the language more difficult to learn - for instance the extremely verbose case-sensitive classes names and methods which are very easy to get wrong.
    • 13 followers
    Offline

    ReputationRep:
    (Original post by tonyhawken)
    This also is not true. You can write quite sophisticated programs without having to bother with memory allocation. And, even if you do, this is not a big problem - it is a relatively easy matter to implement. You are making it sound that having to do this is ever so difficult and so should be avoided at all costs.
    Got any examples of fairly large programs with no dynamic allocations? I suppose it's possible if you use the stl a lot since that often deals with the allocations behind the scenes (don't know much about the stl to be honest, I rarely use it at work). But I agree that basic dynamic allocation is not complicated, in fact I quite explicitly said that in my post. Which is why I disagree that dynamic allocations are "advanced".
    • 1 follower
    Offline

    ReputationRep:
    (Original post by Psyk)
    Got any examples of fairly large programs with no dynamic allocations? I suppose it's possible if you use the stl a lot since that often deals with the allocations behind the scenes (don't know much about the stl to be honest, I rarely use it at work). But I agree that basic dynamic allocation is not complicated, in fact I quite explicitly said that in my post. Which is why I disagree that dynamic allocations are "advanced".
    I think you have lost track of what are the intentions of the original sender is. This person is someone who has never programmed before, and so is unlikely to be writing very large programs, using dynamic structures or using the STL. I should imagine to start with that they are quite content to write simple short programs that work properly. It is these types of program that you will probably deride and call noddy programs. There is nothing wrong with this. Later on when more experienced and various skills have been mastered they can progress to larger more sophisticated programs.

    Although C++ is a very rich language and there are parts of it that are complicated, the language is accessible for someone starting to program.
    • 7 followers
    Offline

    ReputationRep:
    Asian dad: Programming in C++? Should be programming in A++
    • 13 followers
    Offline

    ReputationRep:
    (Original post by tonyhawken)
    I think you have lost track of what are the intentions of the original sender is. This person is someone who has never programmed before, and so is unlikely to be writing very large programs, using dynamic structures or using the STL. I should imagine to start with that they are quite content to write simple short programs that work properly. It is these types of program that you will probably deride and call noddy programs. There is nothing wrong with this. Later on when more experienced and various skills have been mastered they can progress to larger more sophisticated programs.

    Although C++ is a very rich language and there are parts of it that are complicated, the language is accessible for someone starting to program.
    I don't disagree with that. But I don't think it would take that long before they will want to do something involving dynamic allocations. As I said, I don't consider it an advanced topic so I don't see why someone who is still a beginner can't learn the basics of it. It won't be the first thing they do of course, but I'd say it's still in the beginner stage.
    • 1 follower
    Offline

    ReputationRep:
    The string class from the stl would save him a lot of trouble. Vector would be very useful too and he wouldnt have to worry about dynamic allocation.

    C strings are not beginner friendly at all IMO.
    • 1 follower
    Offline

    ReputationRep:
    (Original post by INTit)
    The string class from the stl would save him a lot of trouble. Vector would be very useful too and he wouldnt have to worry about dynamic allocation.

    C strings are not beginner friendly at all IMO.
    The string class is part of the standard library and always has been. So, you can use strings without having to make use of the STL. And yes, there is absolutely no reason at all to use C strings.
    • 13 followers
    Offline

    ReputationRep:
    (Original post by tonyhawken)
    The string class is part of the standard library and always has been. So, you can use strings without having to make use of the STL. And yes, there is absolutely no reason at all to use C strings.
    You should clarify, no reason to use C strings as a beginner. Although even that depends on what you're interested in learning. If you're interested in low level stuff it might make sense to take a "bottom up" approach to programming where you learn the low level stuff first (for example how things are represented in memory) and then move onto more high level concepts. But I think that's probably not the best way for most people to learn.

Reply

Submit reply

Register

Thanks for posting! You just need to create an account in order to submit the post
  1. this can't be left blank
    that username has been taken, please choose another Forgotten your password?

    this is what you'll be called on TSR

  2. this can't be left blank
    this email is already registered. Forgotten your password?

    never shared and never spammed

  3. this can't be left blank

    6 characters or longer with both numbers and letters is safer

  4. this can't be left empty
    your full birthday is required
  1. By joining you agree to our Ts and Cs, privacy policy and site rules

  2. Slide the button to the right to create your account

    Slide to join now Processing…

Updated: September 18, 2012
New on TSR

Student crowdfunds degree

Graduate raises £26,000 online for Masters course

Article updates
Useful resources
Reputation gems:
You get these gems as you gain rep from other members for making good contributions and giving helpful advice.