What's wrong with C++ as a first language?

This is a discussion on What's wrong with C++ as a first language? within the C++ Programming forums, part of the General Programming Boards category; I've read a lot of debate, both here and elsewhere about the problems with C++ in general (I still like ...

  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    12

    Question What's wrong with C++ as a first language?

    I've read a lot of debate, both here and elsewhere about the problems with C++ in general (I still like it, even though I'll be moving on to other languages when I've gotten more competent). However much some people dislike the language being used at all, there seems to be even more opposition to the idea of it being a newbie's first programming language.

    Well, I'm a newbie and C++ is the first language I've decided to try. So far it's been a lot of fun for me, and while I haven't gotten into the nitty gritty of real programming like creating classes, understanding inheritance and the like, I'm enjoying the learning curve immensely.

    I've heard that it's too low level (better to hide the inner workings from people who don 't know what they're doing). I've heard that it's too demanding in terms of precise syntax (why punish programmers for missing a single semi-colon?). I've heard it takes too long to produce truly impressive results (it's just too generalist). I've heard these and a dozen other warnings; at the risk of sounding thick-headed, most of them seem to boil down to
    "C++ is a pain in the neck, and if you've never programmed before it'll put you off for good."

    I'm the kill of bull-headed masochist who'll spend weeks boring into a problem until I beat it, if for no reason but the sheer spite of it. Finicky syntax and blood-boiling bugs will irritate me, but not enough to quit programming altogether. If frustration headaches, delayed gratification and general information overload are all I have to worry about, I'm sticking with C++ as my introduction to the world of programming.(Then maybe Python or LISP)

    The people here have a lot of experience with the language, and while the results might be a little biased (I'm guessing most of you enjoy using C++ to some degree), I'd like to know if the experts could give me any other reasons to start with another language aside from the fact I might pull my hair out. Am I going to develop any bad coding habits? Will it hurt my understanding of programs in general? I'll switch to one of the more popular first languages if this is going to make me a bad programmer somehow, or hurt my ability to understand other languages, but if it's just about the difficulty curve, well... :3

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    I would actually argue that the best language to learn to program in is C. It has a simple syntax, is relatively easy to learn, and is very powerful.
    bit∙hub [bit-huhb] n. A source and destination for information.

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    I've heard these and a dozen other warnings; at the risk of sounding thick-headed, most of them seem to boil down to
    "C++ is a pain in the neck, and if you've never programmed before it'll put you off for good."
    Yep, that's pretty much it. So if you don't mind that, you don't need to worry.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #4
    The larch
    Join Date
    May 2006
    Posts
    3,573
    I think this should be moved to General Programming.

    Personally I didn't learn C++ as the first language (second, if not to count an aborted attempt to learn C++ from the tutorial that comes with DevCpp - which IIRC turns out to be a bad C tutorial in the first place.)

    I think one of the greatest reasons is that you want to learn to think like a programmer (describe algorithms in terms of if's and for's and then perhaps some classes and like). The problems with C++ is that for really basic things you'll need to know a lot of technicalities that have nothing to do with training structured thinking. Add to that, that many mistakes lead to undefined behaviour - you might not even be aware that something is wrong, and if you come painfully aware of that, you might not be able to identify what went wrong, as undefined behaviour can make arbitrary piece of code crash or fail.

    I've heard that it's too demanding in terms of precise syntax (why punish programmers for missing a single semi-colon?).
    Not too sure about that: which language is not demanding in precise syntax (e.g Python punishes you for a missing space)?

    I've heard it takes too long to produce truly impressive results (it's just too generalist).
    Your first GUI tutorial that comes with C# lets you make your own browser ... (I suspect it's just an IE widget, though, and the loading time of the first page was enormous.)

    but if it's just about the difficulty curve, well...
    That's entirely up to you.

    Once you know one or two languages, picking up others will be a lot faster, though.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  5. #5
    Registered User meganewbie's Avatar
    Join Date
    Apr 2009
    Location
    USA, CA
    Posts
    10
    I used a dialect of BASIC as my first language (put the stones down please)

    It was a modern BASIC though and OOP so it did teach me the very basics of classes and such.....BUT I have always wanted to learn C++

    Im what you call a "hobbiest programmer" and so Im not the most advanced programmer but Im enjoying learnig C++

    I probably should have tried C++ alot sooner but I listened to people and was scared away from trying....now I regret not trying C++ sooner

  6. #6
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,554
    The only "faults" of C++ as I see it are:
    - Too much undefined stuff. If something is undefined, then don't allow it or warn if it's used. Compilers do not. It's a pain.
    - C++ has a lot of power and flexibility and with power comes responsibility. There is a lot and I mean a LOT of bad practices that you should avoid. It takes years to learn them all.
    - No easy GUI programming. There is no standard way of writing GUI code. You have to rely on 3rd party libraries. Of course, if you get to know them, and if you find a good one, then GUI programming isn't difficult at all. It's just that finding such a library might be difficult.
    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.

  7. #7
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    Quote Originally Posted by bithub View Post
    I would actually argue that the best language to learn to program in is C. It has a simple syntax, is relatively easy to learn, and is very powerful.
    I agree, learning C is very easy, then learn the C++ extensions. Although I must say that you should learn to write C that is C++ compatible from the beginning (i.e. strong typecasting). So learn C by coding in a C++ environment, that way you don't learn a lot of bad habits that latter need to be unlearned (like I did).

    Quote Originally Posted by meganewbie View Post
    It was a modern BASIC though and OOP so it did teach me the very basics of classes and such.....BUT I have always wanted to learn C++
    OOP BASIC? Must be some abomination of nature like VB, which isnt BASIC at all.
    Last edited by abachler; 09-19-2009 at 07:41 AM.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  8. #8
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    (are you saying C++ is like spidey?)

    All these discussions are theoretically. I would like to hear from professionall programmers what is the marketing value of each language. What do companies ask for today?

  9. #9
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    Quote Originally Posted by abachler View Post
    I agree, learning C is very easy, then learn the C++ extensions. Although I must say that you should learn to write C that is C++ compatible from the beginning (i.e. strong typecasting). So learn C by coding in a C++ environment, that way you don't learn a lot of bad habits that latter need to be unlearned (like I did).
    Totally agreed. I would say start from C++ without its OOP features. Then you are at the point that you could use C++ to learn OOP and use C for more low-level machine stuff

  10. #10
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,554
    I would say learn C++ right away. If you are not going to use C, then don't learn it. C is an old, difficult language that is not up to today's standards. Why bother learning something such when you are not going to use it?
    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.

  11. #11
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    Quote Originally Posted by Elysia View Post
    I would say learn C++ right away. If you are not going to use C, then don't learn it. C is an old, difficult language that is not up to today's standards. Why bother learning something such when you are not going to use it?
    C is an integral part of C++, you cant use C++ without using some C.

    if is C
    switch is C
    struct is C
    while is C
    int main() is C
    any function call that isnt into a member function of some class is C

    The member functions themselves are C, although they contain non-C code if they reference class objects.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  12. #12
    The larch
    Join Date
    May 2006
    Posts
    3,573
    int main() is C
    Isn't it int main(void)?

    any function call that isnt into a member function of some class is C
    What about overloaded functions?
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  13. #13
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    Quote Originally Posted by anon View Post
    Isn't it int main(void)?
    int main() is int main(void) same thing in both C and C++


    What about overloaded functions?
    Well, its hard to overload a function without the base version of it being C

    There are limits on function overloading in C, namely you have to have a different number of arguments, so it isn't full bore C++ style overloading.

    Most modern compilers will implement full function overloading anyway though even though it isn't technically part of the C standard.
    Last edited by abachler; 09-19-2009 at 09:43 AM.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  14. #14
    The larch
    Join Date
    May 2006
    Posts
    3,573
    In what sense are they C? In the same sense as all C++ is just machine code?
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  15. #15
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    Quote Originally Posted by anon View Post
    In what sense are they C? In the same sense as all C++ is just machine code?
    In the sense that C++ isnt a language, it is a language extension of C. Much as I love it and use it. But to say don't learn C learn C++ isn't really helpful, as you need to know C to use C++. And in real world application development most employers will get frustrated if you try writing all your code in C++, as not only will development time increase and performance suffer, but the code that is written in a purist style will be difficult to maintain spaghetti code. Maybe YOU can write purist code that isn't spaghetti, but 99.9% of purists cannot. I don't know if it's because most purists are java-heads who learned C/C++ as a second language and try to write C/C++ like they wrote java, or if its just what schools are teaching these days. As a professional software engineer, with my roots in EE (i.e. hardware), I can tell you that if its what the schools are teaching, they are doing their students a great dis-service.

    BTW, the schools I have looked at do in fact teach purist design and teach java exclusively, or prior to C/C++, which is bass ackwards. You should start out with low level languages first, then teach higher level languages, not the other way around.
    Last edited by abachler; 09-19-2009 at 10:17 AM.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

Page 1 of 3 123 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 15
    Last Post: 08-09-2009, 11:20 AM
  2. The value of learning a new programming language
    By h3ro in forum General Discussions
    Replies: 21
    Last Post: 06-13-2009, 01:48 AM
  3. ASM to C language
    By TAZIN in forum C Programming
    Replies: 22
    Last Post: 06-03-2009, 06:29 AM
  4. God
    By datainjector in forum A Brief History of Cprogramming.com
    Replies: 746
    Last Post: 12-22-2002, 11:01 AM
  5. bubble sort in assembly language!!!!!!
    By lorenzohhh in forum C++ Programming
    Replies: 1
    Last Post: 04-15-2002, 08:30 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21