Slashdot Mirror


Learning C++ for Java Programmers?

The Real Joe Faith asks: "The O'Reilly book 'Java in a Nutshell' used to include a really handy introduction to Java specifically aimed at C++ programmers. It meant an experienced programmer could re-use their knowledge and get up to speed quickly. But what about going the other way? I know a fair amount of Java but, for my sins, have always avoided C++. Now I need to learn it. Fast. Not just the syntax, but also about the various standard libraries out there. Now that Java is the standard language on most computer science courses I guess there will be a few people in the same boat. Can anyone recommend a good book (or any other information source)?" For those Java programmers among us who have gone this route, what books did you use to assist you in the transition to C++? How well did these books work for you?

99 comments

  1. My advice, take it or leave it... by rixstep · · Score: 1, Informative

    My advice, take it or leave it...

    Switch jobs fast. You do not want to get into C++. It's a freaking mess. Remember Alan Kay, father of OO? Here's a quote:

    I invented the term 'object-oriented' and I can tell you I did not have C++ in mind.
    -- Alan Kay


    1. Re:My advice, take it or leave it... by Kick+the+Donkey · · Score: 0, Interesting

      The whole idea of object oriented programming is a mess. Trying to follow someone else's oo-code is like trying to get through a maze, but only looking at the floor. Sooner or later, you'll find on the way out, but you'll still have no idea what the maze looks like.

      --
      /. is a bunch of nerds at a million typewriters. It's not a political conspiracy determined to undermine your beliefs.
    2. Re:My advice, take it or leave it... by Profane+MuthaFucka · · Score: 3, Insightful

      That's probably because C++ isn't object-oriented. It's object capable, and probably better programmed in a generic style.

      Anyway, if you want to learn C++ fast, I suggest getting a couple good books, a lot of coffee, and a compiler. It'll take a short year or so, but it's completely worth it.

      This is not a flame - I'm a C++ fan. It's my favorite language. But if you think you can learn it well in less than a year, you're kidding yourself.

      --
      Fascism trolls keeping me up every night. When I starts a preachin', he HITS ME WITH HIS REICH!
    3. Re:My advice, take it or leave it... by the+eric+conspiracy · · Score: 2, Informative

      I did not have C++ in mind

      LOL. You know he won the Turning Prize for SmallTalk.

    4. Re:My advice, take it or leave it... by Anonymous Coward · · Score: 1, Funny

      LOL. You know he won the Turning Prize for SmallTalk.

      Really? In what direction was it turning?

    5. Re:My advice, take it or leave it... by OmniVector · · Score: 1

      i'm not sure if this is supposed to be a joke or what. smalltalk is a well done OOP language. objective-c is what c++ SHOULD have been. (which for those who don't know is a smalltalk/c derivative).

      --
      - tristan
    6. Re:My advice, take it or leave it... by OmniVector · · Score: 1, Insightful

      oop is a good solution. by no means the best, but good. the thing is certain problems are inherintly procedural, some are functional, others are oop, a few are logical, and even aspect oriented. the point is easy programming methodology has a use and as such should be applied where that use is best. if you told all AI programmers to stop coding and lisp and redo it all in C, they'd laugh at you.

      computer science 101: pick the right tool for the job.

      --
      - tristan
    7. Re:My advice, take it or leave it... by Anonymous Coward · · Score: 0

      It should not take a year. Read The C++ Programming Languge by Stroustrupp, one of the books on the standard library like Josuttis, the books by Meyers and Sutter, Josuttis and Vandevoorde's templates book, and then Alexandrescu's modern C++ book. All of these may take you a year to get though, but after reading the first two you will know more than probably 95% of C++ programmers, and that should only take you a month or so. At this point you should be able to be quite productive on the job. My experience is that it will take around 3 months to get someone to the point where they can read and write modern C++ well. This is for reasonable intelligent and hard working people coming from a Java, or other language, background.

    8. Re:My advice, take it or leave it... by Anonymous Coward · · Score: 0

      I'm not sure if this is supposed to be a joke or what. If you read the D&E it should be clear to you that objective-c does not meet the requirements under which C++ was designed.

    9. Re:My advice, take it or leave it... by OmniVector · · Score: 1

      what is the D&E, and since when were there "specs" for which c++ was designed.

      --
      - tristan
    10. Re:My advice, take it or leave it... by Profane+MuthaFucka · · Score: 1

      It should not take a year.

      You're right. It should take 10 years. Because 10 years is the time it takes to go from picking something up, to being really really good at it.

      -Start golfing today, in 10 years you might be good.
      -Pick up a guitar today, in 10 years you might be good.
      -Start C++ today, in 10 years you might have mastered all of it.

      --
      Fascism trolls keeping me up every night. When I starts a preachin', he HITS ME WITH HIS REICH!
    11. Re:My advice, take it or leave it... by Anonymous Coward · · Score: 0

      what is the D&E

      "The Design and Evolution of C++" (Stroustrup).

    12. Re:My advice, take it or leave it... by Anonymous Coward · · Score: 1, Insightful

      objective-c is definitely NOT what C++ should've been. Smalltalk isn't what it shouldn't have been either, as arkane, and provincial as most other languages born of the 70's. C++ is reviled by java zealots and "alternative" object-ish languages alike because of your fundamental idiosyncratic failure to grasp even the most fundamental concept of power.

      "With great power, comes greater responsibility".

      Didn't ANY of you ever read Spider-Man ?

      Part of why the current crop of developers has so much "faith" in java is because academia itself didn't see "fit" to teach principals of object-oriented programming in a language that they themselves didn't quite "get". Don't believe me, just ask how many CompSci majors are truly exposed to 'C', much less C++, by the time they're in their senior year in college.

    13. Re:My advice, take it or leave it... by mrlpz · · Score: 1

      ^^^^^^^ I entered that...just so folks who like to bicker know who disagreed with them.

    14. Re:My advice, take it or leave it... by meatball_mulligan · · Score: 1

      I totally agree. Too often people get so wrapped up in what's cool about their language of choice that they refuse to see that no single language or programming model is always the right choice.

      For building large, web based apps with multiple back-end legacy and database systems, thousands of simultaneous users, and dozens shared components, J2EE has been a godsend. It has gotten rid of a hundred headaches with development, maintenance and administration. But that doesn't mean that there's not a place for Perl or PHP for simple CGIs or quick web apps that aren't huge enterprise wide systems. I've also become quite smitten recently with Objective C (and the Cocoa or GnuStep libs) for my personal pet projects -- usually small stand-alone GUI apps. The point, just as OmniVector said, is pick the right tool for the job.

      m.m.

      btw: I know this is bucking /. tradition, but how 'bout getting back to the original question. It appears that someone has already decided that C++ is the best tool for this job. (Yeah yeah, I know, but cut the guy some slack okay? It wasn't his decision.) Can anybody recommend a good book for an experienced Java programmer who wants to leverage that knowledge in an attempt to learn C++?

  2. STL is important by magefile · · Score: 4, Informative

    This is probably the best tutorial I've come across for the Standard Template Library.

    Good luck!

    1. Re:STL is important by Profane+MuthaFucka · · Score: 4, Insightful

      STL is MORE than important. Learning all about the STL is an activity that should occupy the time period from 1 to 1.5 years after a person starts learning C++.

      --
      Fascism trolls keeping me up every night. When I starts a preachin', he HITS ME WITH HIS REICH!
    2. Re:STL is important by escher · · Score: 1

      The STL didn't even exist when I started with C++. Still, it was better than what the CS dept. I was attending at the time used: ADA.

      I still have nightmares.

    3. Re:STL is important by Anonymous Coward · · Score: 0

      1 to 1.5 years is probably way too late. For instance, std::string should be in lesson 1. I admit that writing your own templated functors etc. to extend the STL should wait.

    4. Re:STL is important by Profane+MuthaFucka · · Score: 1

      I'm assuming that the beginner doesn't already know C. If they do, then you're right that it's too late.

      My thought was to make the beginner do everything without STL at first, to learn, and to increase their desire for something like the STL to make their lives easier.

      --
      Fascism trolls keeping me up every night. When I starts a preachin', he HITS ME WITH HIS REICH!
  3. Re:Forget it by Anonymous Coward · · Score: 0

    I salute your your insightful/funny/offtopic/flamebait/troll FP. Oneliner that does it all.

    Bravo, Sir!

  4. no API by baylorhawk · · Score: 3, Informative

    Well, I can't recommend a book, since I learned C++ first, but I have a warning...there is no definitive API. I imagine that would be a stumbling block for Java-to-C++ converts.
    However, might I recommend this for the STL?
    I think that in searching for a book, you should probably look for one that highlights the differences between the languages. That helped me when I was learning Java, and it's probably the quickest way you can pick it up. Have a look at Amazon and just search under books for "java c++". The first few entries are aimed at this. I can't vouch for these books, but hey, that's what I found.

    1. Re:no API by Anonymous Coward · · Score: 0

      I think the SGI docs are out of date. I am pretty sure they were written by Matt Austern. You would be better off getting the book he wrote based on the notes _Generic Programming and the STL_. The other good book is Nico Josuttis's _The C++ Standard Library_. _Effective STL_ by Meyers is also good.

  5. I Need C++ for Cobol Programmers by Anonymous Coward · · Score: 0, Funny

    I made a bundle coming out of retirement back in '99 but since then me and the Mrs. have been tooling across the US of A on Route 66 but what with the price of gas so high now and the RV only getting 3.4 miles to the gallon the pocketbook is kinda thin lateley. Plus I need my third bypass operation and one of those titanium hip joints would be just dandy! So maybe I ought to be updating my resume again, put out a shingle and see if anybody needs an old fart with skills in a dying computer language. Will program for viagra!

  6. C++ is better for... by phoenix.bam! · · Score: 1, Offtopic

    I like C++ a lot more for learning theory. Data structures and algorithms and what not. I'm working on a project now with Java though and I love it for actual development. Easy to read API plus everything is already done, no lower level networking or serial interfacing.
    I learned C++ first and I found it easy to learn. Then I learned java, and i find it similar. The only difference that might be hard to grasp is the difference pointers and references have between the two. Just look up a website listing the differences and you'll be set for C++

  7. book we use for 15-113 by viperstyx · · Score: 4, Informative

    heres a book that was suggested by my professor here at CMU for our intro to C class: "C for Java Programmers" by Thomasz Muldner" ISBN: 0-201-70279-7 not exactly c++ but may be you can find something like it. in anycase, should help others.

    1. Re:book we use for 15-113 by Anonymous Coward · · Score: 0

      I'd say that ("C for Java Programmers") is a poor choice for learning C++ or even C. The C code examples are usually the kind of C that is produced by programmers who want to show off their huge talents and serious better-than-you programming style, and who produce bug-ridden, undebuggable, unmaintainable and unreadable crap.

  8. Do us all a favor by Henry+V+.009 · · Score: 4, Insightful

    Please don't code anything in C++ after learning it "fast." It's not that kind of language.

    1. Re:Do us all a favor by baylorhawk · · Score: 4, Informative

      The parent post has a point. C++ is a difficult language to pick up quickly. My college has 3 C++ courses that are prereqs to just about all the other cs courses, and I still didn't learn it well until my senior year when I had to use it again.
      Learning C++ for any practical use will take time and practice to learn all of the nuances, especially the copy constructors, operator overloading, and all of that junk.

    2. Re:Do us all a favor by 1iar_parad0x · · Score: 2, Insightful

      Do us all a favor and cut the sarcasm! I'd be more sarcastic, but I'm trying not to sound like a troll.

      If the guy has been writing code for a while, he can make the switch. I'm guessing he's working in C++ shop, thus there will be some senior coders around to help him out.

      --
      What do you mean my sig is repetitive? What do you mean my sig is repetitive? What do you mean....
  9. Ask Slashdot: where Google Morons ask questions by Anonymous Coward · · Score: 0

    Geez, how hard was it to type in "Java for C++ Programmers"?

    http://www.awprofessional.com/bookstore/product. as p?isbn=0201612461&redir=1

    1. Re:Ask Slashdot: where Google Morons ask questions by TheWanderingHermit · · Score: 1

      It was probably as easy as typing in "C++ for Java" (since he's looking to learn C++, NOT Java), but taking time to think it through would have taken too much time, wouldn't it?

      But, if he had typed in "C++ for Java", as I did, here's a useful link.

    2. Re:Ask Slashdot: where Google Morons ask questions by Webmonger · · Score: 2, Informative

      Not actually that useful. They don't mention smart pointers in the memory management section. They claim C++ has no string type. Not good.

    3. Re:Ask Slashdot: where Google Morons ask questions by InterventionOne · · Score: 2, Informative

      The link in the above post (see parent) seems to be broken for me. I don't know if this happens to be the same book as the one above...

      This is the book that my Survey of Programming Languages professor suggested for those of us who came in knowing Java but not C++.

      It's nice in that it compares and contrasts many features of both languages (including quite a bit on the STL and writing templates in C++), but I found myself wishing it would have gone into more detail several times - my one gripe is that it doesn't do much more than scratch the surface in several instances.

      (apparently, there's at least a couple of "C++ for Java Programmers" books on amazon alone...)

      A couple of reference sites I've used in the past:

      C/C++ Reference

      C++ Library Reference

      (Personally, I still shy away from C++ whenever I can...I certainly haven't gotten a comfortably firm grip on it yet.)

    4. Re:Ask Slashdot: where Google Morons ask questions by TheWanderingHermit · · Score: 1

      But, to someone who knows Java and knows almost nothing about C++ (like me), it's a good start. True, it doesn't tell you EVERYTHING, but it's a start.

      On the other hand, as many point out, it really takes at least a year or more to learn C++. Isn't that true with any complex language?

    5. Re:Ask Slashdot: where Google Morons ask questions by boneshintai · · Score: 1

      Not actually that useful. They don't mention smart pointers in the memory management section. They claim C++ has no string type. Not good.

      But, to someone who knows Java and knows almost nothing about C++ (like me), it's a good start. True, it doesn't tell you EVERYTHING, but it's a start.

      No. If the grandparent is right (I didn't check, of course) then it's not a good start. It teaches you things about the language that are actively wrong (that it has no string type) and doesn't teach you things that may make life a lot easier if you're coming from Java (self-managing pointers).

    6. Re:Ask Slashdot: where Google Morons ask questions by boneshintai · · Score: 3, Informative

      Ok, now having actually read the link, here is a list of things that are either actively wrong or totally unhelpful:

      • No mention of std::vector in the discussion of arrays
      • Deprecated pre-standard headers such as
        #include <pair.h>
        instead of
        #include <pair>
      • Introduces C-style IO (printf et al) before stream IO, even though Java provides workable streams and C-style IO is completely nonestensible in ways a Java programmer may be accustomed to
      • To declare a constant in C++, you use #define (not final) as in:

        #define MAX_SIZE 10

        No. Please use const instances. They're typechecked but the compiler is free to translate them into inline constants similar to what the preprocessor produces:

        const int MAX_SIZE = 10;
      • Macros (#define min(x,y) (((x)
      • void main (...) is totally wrong. Main is not permitted to be void in C++. Some compilers will allow it, but it is not a feature of the langugae.
      • C-style typedef struct {...} typename; is unnecessary in C++; structs essentially are handled as classes that default to public and as such the struct name is a type.
      • Unions.
      • "In C++, all parameters are passed by value." Unless they're passed by reference, anyways.
      • You do not need to use std::malloc to allocate a structure or a builtin type. The 'new' operator works just fine.

      Christ. This is from 1998. No wonder it's got so many issues.

    7. Re:Ask Slashdot: where Google Morons ask questions by TheWanderingHermit · · Score: 0

      Okay, you're right. I'm wrong. Obviously you know every little detail and have much more time on your hands on a Friday night than I do so you can spend your evening disecting this.

    8. Re:Ask Slashdot: where Google Morons ask questions by Gilk180 · · Score: 1

      I agree with you on most point: to expand.

      #define should NEVER be used for anything except to protect headers from being included multiple times or to separate non-portable code. As mentioned, const variables and inline functions provide the exact same functionality and performance(on a good compiler), but also have type checking. If you don't want type checking, use an inline template.

      Unions are the most useless feature of C++. I find void pointers easier to deal with in the rare circumstance that something like this is needed.

      >"In C++, all parameters are passed by value." Unless they're passed by reference, anyways.

      If you want to get technical about it, a pass by reference is equivalent to passing a pointer(reference) by value. Think about the syntax of the declaration.

      >You do not need to use std::malloc to allocate a structure or a builtin type. The 'new' operator works just fine.

      Even better, you should NEVER use malloc to allocate a structure or a builtin type in C++ unless you know exactly what you are doing. The structure may have a constructor that won't be called using malloc. Just a language lawyer note, but std::malloc should not be a resolvable name. std:: is for C++ libraries. malloc is a C function and will be in the root namespace, so fully qualified it is ::malloc.

    9. Re:Ask Slashdot: where Google Morons ask questions by boneshintai · · Score: 1

      "In C++, all parameters are passed by value." Unless they're passed by reference, anyways.

      If you want to get technical about it, a pass by reference is equivalent to passing a pointer(reference) by value. Think about the syntax of the declaration.

      Consider:

      /// A trivial swap implementation
      inline void Swap (int &a, int &b) { a ^= b^= a ^= b; }

      While internally to the compiler a and b may be (and often are) pointers, that fact is hidden from the programmer and is in no way guaranteed. However, a and b are guaranteed to refer to valid, changeable ints. Furthermore, the call swap (foo, bar); will actually swap the contents of foo and bar in the calling function.

    10. Re:Ask Slashdot: where Google Morons ask questions by Anonymous Coward · · Score: 0

      It's more like he's right and your wrong. He actually knows what he is talking about and you are giving incorrect and bad advice on a topic which your largely ignorant of. The points he discussed are not "every little detail" of the language. They are basic points anyone knowledgeable in the language should know.

    11. Re:Ask Slashdot: where Google Morons ask questions by Anonymous Coward · · Score: 0

      If you want to get technical about it, a pass by reference is equivalent to passing a pointer(reference) by value. Think about the syntax of the declaration.

      That is an implementation detail. It is irrelevant to the question of whether C++ supports call-by-reference or not. A key point is that looking at a piece of code f(x, y) we can't tell (just from syntax) whether x and y are passed by reference or by value.

    12. Re:Ask Slashdot: where Google Morons ask questions by ManoMarks · · Score: 1
      I'm so tired of this kind of post. So many people on /. think it is the height of brilliance to tell everyone else why they are stupid. And to post it as an AC too.

      The original poster may or may not have done some of this research themselves, but many people would much rather get advice from experienced users than rely on a resource they find on the web which may or may not be accurate.

      Also, you can't tell the worth of a, say, book without reading. It's helpful if someone else says "I've read this book and it is good" because that gives them a sense that at least one othe poster found it to be a good resource.

      I personally have wasted lots of time trying to get something out of a web resource, only to realize that it's not worthwhile, or there's a better resource somewhere else, often by having someone say to me, or post somewhere "Hey, have you tried this?"

      --

      That's gotta fit into your schema somewhere

  10. Trollish? True! by Webmonger · · Score: 4, Funny

    C++ is an excellent language, but it gives you enough rope to hang yourself, your immediate family, and maybe a few pets. Learn it fast, and you'll learn it wrong.

  11. Lying during job interviews by DaoudaW · · Score: 0, Flamebait

    Man, you don't need to learn C++, you need to learn to be more truthful during job interviews. End of sermon.

    Now about c++. Boot linux, bring up kdevelop, create a console project and start writing.

    What's that? You need to program windows apps! OMG!! You are a big liar!

  12. One word: Don't. by jonadab · · Score: 0, Troll

    Seriously. Java isn't the best and most modern language in existence, but C++
    is substantially worse in an assortment of ways. The *only* thing it has going
    for it over Java is performance, which is mattering less and less as fewer and
    fewer people are trying to function on the 486SX systems with 1MB of RAM that
    were prevalent when Java got its reputation for slowness.

    If you want to diversify from Java and learn more languages, that's good, but
    C++ isn't a good choice anymore. People are moving *away* from C++, for good
    reasons. Learn Perl or Python or Ruby or Scheme, something that actually
    provides some facilities Java doesn't.

    --
    Cut that out, or I will ship you to Norilsk in a box.
  13. Use a Typical C++ Programming Book by ElliotLee · · Score: 1

    What I did was simply buy and read a C++ programming book, the same way many C++ programmers learned C++. The only difference is that with my knowledge of Java, I was able to skip (or quickly review) the parts of C++ that are similar to Java (and there are quite a few). The rest I learned like any other person. Knowing Java just helps you to pick up the same stuff faster.

  14. C++ THEN Java by miyako · · Score: 1

    I started learning C++ about 7 years ago (I say started because it seems like no matter how long one has been programming C++ there are always new things to learn), and I started with Java about a year and a half ago.
    One thing that seems apparent to me is that it is much more inherently difficult to go from a higher level language like Java to a lower level language like C++, because starting with Java the programmer becoms accustomed to not having to think about things which become major problems in a C++ program.
    As others have mentioned, the lack of a standardiezed API for C++ beyond the STL can make things seem like a major PITA going from Java to C++, just think about what it would be like trying to go from Swing to the Microsoft API or GTK+ (though Qt is REALLY nice, if you are a java programming learning C++ and want to learn a GUI API start with this first).

    --
    Famous Last Words: "hmm...wikipedia says it's edible"
    1. Re:C++ THEN Java by Nicolay77 · · Score: 2, Informative

      I learned Java first, and then C++ with wxWindows (now wxWigdets).

      The change was so welcome that now I use C++ with wxWin almost exclusively, even if somethimes I have to use Java (because someone pays me to use it).

      It has not only GUI classes but several data structures and system functions that make very easy to leverage the operating system API without actually going down and using it. Try to make a nice screensaver in Java.

      There is something I miss from Java, because I have to implement similar things in C++ and is serialization. That's where the difference between C++ and Java lies to me. ODBC is also better in Java, but there are ODBC libraries for C++.

      I find almost everything else better in C++. But remember, do not use features of the language that you do not fully understand. Just because C++ has templates, it doesn't mean you have to use them just to feel like you're using C++. The same with multiple inheritance, in fact, never use it.

      And compared to Java, good C++ is fast as hell. The right tool for the right job, bla, bla, bla, etc...

      --
      We are Turing O-Machines. The Oracle is out there.
  15. My Opinion by The+Slashdolt · · Score: 3, Insightful

    My learning went from assembly ==> C ==> C++ ==> Java, and my advice to you is to not go from Java to C++. If you remember venn diagrams, imagine one circle as Java, Then draw circle next to it without intersection and call that one C. Now draw a circle that intersects Java and C, but also has its own distinct characteristics, and that circle would be C++. There is no way to learn C++ without learning C. If I were you, I'd learn C. Then once you learn C, your OO knowledge will make you question some things. Then C++ will make sense to bridge that gap. Learning C++, or C for that matter, is not going to be fast. And anyone who does learn it fast will be in trouble unless they're really talented. One thing is for sure, once you learn C/C++ you will REALLY appreciate Java. Good Luck.

    --
    mp3's are only for those with bad memories
    1. Re:My Opinion by E_elven · · Score: 2, Insightful

      There is absolutely no reason to learn C before going to C++. In fact, it will probably be harmful. All the C you will need will be provided by C++.

      --
      Marxist evolution is just N generations away!
    2. Re:My Opinion by The+Slashdolt · · Score: 1

      Let me get this straight. It's your opinion that learning things such as pointers, references, pass-by-value, method pointers, macro's, STL, virtual, pure virtual, operator overloading, destructors, no-GC, etc, etc is perfectly fine to learn all in one shot without any prior knowledge. Remeber, that Java has no analogous to A LOT of these things. I would hate to have to see the code of some experienced Java coder having to see all of these things at once. But apparently you have different opinion.

      --
      mp3's are only for those with bad memories
    3. Re:My Opinion by Anonymous Coward · · Score: 0

      Well, if we want to be precise...

      C is a small circle, 80% enclosed by the Java circle. C++ is a huge circle that covers 100% of C, and 95% of Java. Plus a huge tract of space that neither covers.

      You can spend years learning C++ and still not master it. You probably won't be productive for the first 3 or 4 months.

      On the other hand, you can do some shockingly powerful things with the language if you spend the time to learn it well.

    4. Re:My Opinion by psykocrime · · Score: 1

      It's your opinion that learning things such as pointers, references, pass-by-value, method pointers, macro's, STL, virtual, pure virtual, operator overloading, destructors, no-GC, etc, etc is perfectly fine to learn all in one shot without any prior knowledge

      What does any of that have to do with learning C before C++? C++ includes pretty much everything that's in C, but renders some of those things obsolete because it has better features. All one does by learning C first is learn the bad / old way of doing things.

      Learning C++ in isolation is roughly equivelant to learning Java in the first place. I for one don't see any point in spending the time to learn the C specific stuff first, then spend time unlearning that to learn to do things "the C++ way."

      I would hate to have to see the code of some experienced Java coder having to see all of these things at once.

      Nobody says you have to use everything that's in C++. It's perfectly OK to spend many happy hours coding in C++ without ever using operator overloading or templates or function pointers. But they're there if you need / want them.

      --
      // TODO: Insert Cool Sig
  16. You don't need a Java to C++ book by LoveMe2Times · · Score: 4, Insightful

    Just be confident knowing that most of your basic skills will transfer, and get a normal C++ book. Personally, I recommend Stroustroup's book, and Dietel and Dietel is an oft used text. Most of those "Learn C++ in 24 Hours!" types of books are a waste of trees. Like others have said, it's crucial that you get something that covers STL (both the ones I mentioned will). It's C++'s version of a class library. You'll find it a little thin after working in Java, and that's where platform specific stuff enters the picture. You'll find most of your time is learning a new widget set (presuming you need GUI programming), or socket APIs (if you need 'em), or platform specific threading/synchronization etc.

    Overall, coming from Java, you won't expect or know how to use fancy language features. That's Ok. Write C++ like you would Java (mmm, careful about that memory leak though). This assumes you're doing app development where you can afford to make every function virtual, every object a reference, and have accessor functions for every member variable. If that's not what you're up to and you need write tight C++, well, forget Java while you learn C++. Make sure you get your memory models straight--stack vs heap, by value and by reference, pointers vs reference, iterators vs pointers, reference counted, and on and on. You have to get the now classic "Effective C++" books by Scott Meyers. That's the best way to avoid classic stupid C++ mistakes. You'll find it a bit heavy going at first, but until it makes sense to you, you're probably writing bad C++. Good luck.

    1. Re:You don't need a Java to C++ book by hummassa · · Score: 2, Informative

      Bruce Eckel's Thinking in C++ will help, also...

      --
      It's better to be the foot on the boot than the face on the pavement. ~~ tkx Kadin2048
  17. You'll Miss the API by pitfiend · · Score: 2, Informative
    First off, you're going to miss the Java API. I just spent the last semester in your predicament. I have a strong Java background, but I was forced to TA an intro to C++ class. I found that our text "C++ Effective Object Oriented Software Construction" by Kayshav Dattatri was a very good intro to C++ if you've got a Java background. He tends to make comparisions to Eiffel or Smalltalk, but Java comes into the picture often (and its pretty close to Smalltalk in a number of ways).

    Also check out www.cppreference.com. I have found it to be significantly more useful than the STL reference at SGI.

    To paraprhase Mark Twain, the rumors of the performance of C++ have been greatly exagerated. The advantage you get from cross platform compatibility and a fantastic API far outweigh a minor performance hit.

    1. Re:You'll Miss the API by E_elven · · Score: 2, Informative

      C++ is cross-platform. You just have to compile it separately for each target.

      Anyway, a few posters seemed to mention the Java API -or the SE part in J2SE, which to me seemed to be an alright compilation when I toyed around with Java. One should remember that C++ has all the libraries Java does, usually more and in various forms for one to pick and choose from. Google is one's friend for library-hunting aside from the nigh-obligatory boost.org libraries.

      --
      Marxist evolution is just N generations away!
  18. zerg by Lord+Omlette · · Score: 3, Informative

    My favorite book is Accelerated C++ by Koenig n Moo. It's C++ taught as a language w/ a library. It's not taught as C w/ classes tacked on as an afterthought. Check it out.

    You will spend the rest of your life learning C++, anyone who says they "know" the language is either lying or deluding yourself. After you're done w/ Accelerated C++, pick up Modern C++ Design by Alexandrescu. Also get a subscription to C/C++ Users Journal.

    --
    [o]_O
  19. Re:One word: Don't. by OmniVector · · Score: 1

    i agree with you. really, i do. the job market can be less forgiving than that though. plus there's a whole 10 and more years worth of perfectly working c++ code that has to be maintained and companies can't just afford to throw it away.

    now if you're in the position of starting a project/company yourself, obviously avoiding c++ is a good thing from the start.

    --
    - tristan
  20. Sympathy by Animats · · Score: 1
    You have my sympathy.

    After ten years of C++ programming, I'm underwhelmed with C++. It's broken, and Strostrup is in denial about its flaws. If C++ wasn't broken, we wouldn't have needed Java or C# or Objective-C, which, after all, look a lot like C++.

    The basic problem with C++ is that, alone amongst major programming languages, it has hiding without safety, which is a terrible combination. C has neither hiding nor safety. Java, Perl, Python, Ada, and LISP have hiding with safety. This has nothing to do with efficiency. There are some basic bad design decisions in C++. Some of them come from C, and some of them come from early C++. The end result is a mess.

    The best the C++ community has been able to do is to impose religious dogma, in the form of "patterns", on C++ usage. This sort of works, but not very well. Witness Microsoft's endless buffer overflow problems. Switching to C++ has not helped at all.

    It's not getting any better, either. The C++ language development community is dominated by people who like to do really l33t things with templates.

    I wish there were something decent and mainstream to program in. (And don't go on about Eiffel or Sather or Z or Haskell; those are going nowhere.)

    1. Re:Sympathy by rjh · · Score: 1
      Witness Microsoft's endless buffer overflow problems. Switching to C++ has not helped at all.
      Microsoft never used MFC for their own development of code. It's all C. Nor was C++ ever really a priority at Microsoft until Visual Studio .NET; the Visual C++ 6.0 standard library was considered a sick and cruel joke, almost gratuitously incompatible with the real C++ standard library.
      The C++ language development community is dominated by people who like to do really l33t things with templates.
      You obviously haven't seen some of the things they're doing with templates. I never would've thought I could get better-than-FORTRAN performance out of an object-oriented language, but that's what Blitz is giving me.
      I wish there were something decent and mainstream to program in.
      Python and Ada95 are both excellent, general-purpose languages with wide industry support.
    2. Re:Sympathy by HeghmoH · · Score: 1

      If C++ wasn't broken, we wouldn't have needed Java or C# or Objective-C, which, after all, look a lot like C++.

      A lot of people don't seem to realize this, but ObjC was created around the same time as C++. It wasn't made as a response to C++, but rather they were both responses to the idea of gluing OO onto C. Just a minor nitpick to a very good post.

      --
      Mod down posts with a "Free Mac Mini/iPod" sig, they're spam!
    3. Re:Sympathy by Anonymous Coward · · Score: 0
      It's broken, and Strostrup is in denial about its flaws.
      ...
      The C++ language development community is dominated by people who like to do really l33t things with templates.
      Lobbing insults at people has never helped your cause, and is not likely to do so now. In fact, it undermines it. You had a reccomendation for C++0x to include a so-called "strict" mode. What ever happened to that? Do you have an implentation? I seem to remember a number of those people "who like to do really l33t things with templates" were actually interested in your proposal. You don't seem to have done much with it though.
    4. Re:Sympathy by Anonymous Coward · · Score: 0

      I never would've thought I could get better-than-FORTRAN performance out of an object-oriented language, but that's what Blitz is giving me.

      But can it beat FORTRAN with a macro preprocessor and some "l33t" macros? That is the question. Otherwise you are just noting that a faster algorithm is faster than a slower one, which is an unimpressive tautology, and then claiming that a direct comparison with the same algorithm implemented in both languages would be "impossible" because the macro package you used for C++ is not available for fortran. Every comparison I have seen showing this "faster than FORTRAN" performance either exploits a particular failing of the FORTRAN compiler being used, or effectively is using a different algorithm and hence not a direct comparison between language features.

  21. C++ for Java Programmers, by Razzy · · Score: 2, Informative

    by Timothy Budd, may be what you're looking for. My uni taught intro cs in Java but in our OO development class, C++ was the language of choice. They threw this book our way to ease the transition. It didn't hurt, although Stroustrup's book, Meyers' Effective C++ and STL, and Lippman and Lajoie's C++ Primer are more useful in the long run. Also pick up a nice STL reference like Josuttis.

  22. Same boat by jennifer_l · · Score: 0

    The OP is quite right - I'm in exactly the same boat and no, I don't need to learn C++ because I lied in an interview, or need to develop some software quickly, but rather because I am interviewing for an academic course that teaches C++ and one of the requirements is that you be able to learn C++ quickly, so the "pre-test" as it were is for me to try and learn it in the week I had between being notified I needed to learn it, and the interview itself. Meh. They suggest Deitel & Deitel; it's looking good for me so far. "C++ for Java Programmers" looks okayish, but not as thorough; I'm going for the learning-as-if-a-newbie approach and mapping concepts on to what I already know (thank gods for all those compiler theory lectures eh?).

  23. some source suggestions by 1iar_parad0x · · Score: 1

    Use one of the first two books for syntax, and use the rest to further your knowledge quickly.

    For syntax:
    C++ in a Nutshell
    by Ray Lischner

    OR

    Sams Teach Yourself C++ in 10 Minutes
    by Jesse Liberty, Mark Cashman

    For examples:
    The C/C++ Users Journal (from the publishers of Dr. Dobbs)
    http://www.cuj.com/

    Effective C++ Cd: 85 Specific Ways to Improve Your Programs and Designs
    By Scott Meyers

    Frankly, there are a ton of similar books out there...

    At some undisclosed site (Amazon.com) their data miners|web agent|sentient AI suggests:

    C++ Gotchas: Avoiding Common Problems in Coding and Design
    by Stephen C. Dewhurst

    Other advice:
    Try to find some good sample code. Take a cleanly written open-source utility or something from MSDN and try to extend a feature in the software. That's how I learn.
    (yes, haha, I send cleanly written and OSS|MSDN in the same sentence...)

    --
    What do you mean my sig is repetitive? What do you mean my sig is repetitive? What do you mean....
  24. The three needs of Java2C++ programmers by SilentJ_PDX · · Score: 4, Informative

    I was in the same boat a year ago. I think (good) Java developers needs are unique when approaching C++ because we already know about 80% of the syntax and concepts, but we need a quick way to get into the STL, tips on how NOT to hang yourself (far too easy in C++), and some sense of how C++ programmers organize code.

    For getting into the STL, I chose Accelerated C++ by Koenig and Moo. It is very basic at the beginning. However, it's not a 700-page behemoth (a Good Thing), it approaches C++ as OOP from the outset, and it starts using the STL from chapter 1. I'm sure you'll need a full STL reference after this book, but it serves as a decent starter. (I also have "The C++ Programming language" by Stroustrup and it's a bit too close to a language definition... good reference, bad primer)

    For the tips, Scott Myers books can't be beat. Enough people have heaped praise on them that I won't bother with it here.

    That leaves the last part of my education: "how do C++ programmers organize code". Unfortunately, the C++ world doesn't seem nearly as unified as the Java world. I started out doing things very Java-like, but decided that probably wasn't going to work if I eventually start coding with other people. Accelerated C++ has some tips. The C++ Programming Language also has a lengthy discussion on how to organize your code. Being the completely anal guy I am, I wanted to get it right the first time. Unfortunately, that's not possible. My style is still changing frequently as I see elements I like. I'm sure it will calm down if I ever get a job in a C++ shop.

    1. Re:The three needs of Java2C++ programmers by Javagator · · Score: 1

      I want to second the Meyers and the "Accelerated C++" recommendations. As for "how do C++ programmers organize code", I would recommend another book by Koenig and Moo, "Ruminations on C++". Chapter 24, "An Object Lesson in Library-Interface Design" has the best example of how to organize a C++ program that I have seen. Even if you don't get the book, read this one chapter.

  25. Re:One word: Don't. by seanbry · · Score: 2, Insightful

    I am sorry, I am a bit confused by your argument. Move away from C++ to what exactly. The only other languages you mentioned where Perl, Python, Ruby, or Scheme. I have yet to use Ruby or Scheme, but I did look up some things on them.

    Most of those languages are scripting lanugages and aren't really what you'd program a major application in. I know I user perl for sys admin tasks and quick hacks to just 'get things done'

    If you're going to beat up on C++ tell them to move away give a decent language to move to. And you never explained what Java had that C++ doesn't.

    Please tell me why I want to move away from a language such a C++ or even its predecessor C. Those languages are solid, and fast. You can do most anything with them. And the cleanliness of the program is left to the programmer, so if you develope bad practices you'll write bad code. If done propertly I see nothing wrong with using C++.

  26. Things to consider when coming to C++ from Java by linuxhansl · · Score: 4, Insightful
    I started out with C++ a loonngg time ago. For all of my current projects I suggest Java (although I actually don't code that much anymore), unless I need to do system programming.

    Here's (on the top of head) what comes to mind when I think ab out moving from Java to C++:
    1. Learn the STL (as has been suggested here before). It's a great way to understand the philosophy behind C++.
    2. Look into templates (which you need to understand the STL anyway). You can write very generic code if you can employ "type-variables".
    3. Consider using stack variables even for non-primitive types.
      In C++ you can place objects on the stack with no need to allocate an object on the heap.
    4. Think about an ownership model from the beginning. C++ does not have a Garbage Collector, so you have to make sure that from the beginning you always know who owns which objects when and who is responsible to allocating/deleting it. (That also relates to using stack variables if you can).
    5. For the reasons above, don't forget about destructors.
    6. Learn about when C++ performs automatic conversions, when copy-constructors and default-constructors are called, etc. These conversion are sometime unexpected.
    7. Learn about pass by reference vs. pass by value. In Java Objects are always passed by reference, primitive types by value. In C++ you have much more control. Specifically objects are passed by value by default leading to sometimes unnecessary copies.
    8. Learn about const. Const "Constants", const parameters, const methods. That can make your code safer.
    9. Think about "virtual". In Java every object is automatically polymorphic. In C++ you have to declare method as virtual to use late-binding (which is used to achieve polymorphism).
    10. Look at the different forms of class derivations. In Java there's only one form (equivalent to the C++ public form). In C++ you have public, private, protected derivation (no, that's not the scope identifier for members). C++ also supports multiple inheritence, in that case in addition you have to think about virtual derivation.
    11. There's no "finally" in C++. Typically you code guaranteed actions at the end of a method call in a destructor of a stack-allocated object.
    12. Take a look at threading. C++ does not included any standardized thread library. There are abstraction libraries out there that wrap the Windows API and PThreads into one nice library.
    1. Re:Things to consider when coming to C++ from Java by cxvx · · Score: 1
      Learn about pass by reference vs. pass by value. In Java Objects are always passed by reference, primitive types by value. In C++ you have much more control. Specifically objects are passed by value by default leading to sometimes unnecessary copies.

      You are incorrect about Java.
      In Java, everything is passed by value. You never pass objects by reference, you pass references to objects by value.

      --
      If only I could come up with a good sig ...
    2. Re:Things to consider when coming to C++ from Java by mrjohnson · · Score: 1

      Before you say somebody is wrong, it's always a good idea to ask google first. :-)

      http://www.javaworld.com/javaworld/javaqa/2000-0 5/ 03-qa-0526-pass.html

    3. Re:Things to consider when coming to C++ from Java by Anonymous Coward · · Score: 0

      And before you say that somebody is wrong for saying that somebody is wrong, you ought to actually read the page that you link to:

      However, Java doesn't pass method arguments by reference; it passes them by value.

    4. Re:Things to consider when coming to C++ from Java by Anonymous Coward · · Score: 0

      Exactly. It is just that Java always refers to objects indirectly (by reference) so the references are evaluated and passed by value.

      Pass by reference in the C++ way is an abomination, invented mostly to fix other problems in C++.

    5. Re:Things to consider when coming to C++ from Java by ralatalo · · Score: 1

      Re: Re: Learn about pass by reference vs. pass by value. In Java Objects are always passed by reference, primitive types by value. In C++ you have much more control. Specifically objects are passed by value by default leading to sometimes unnecessary copies.

      Re: You are incorrect about Java.
      In Java, everything is passed by value. You never pass objects by reference, you pass references to objects by value.

      You are incorrect, well, not really as you just said the same thing as the original poster did but in a less clear way.

      Java has two types of variables, primatives and reference variables. So you can either pass a primative or you can pass a reference. If you pass a primative, you are passing it's value. If you are passing a reference, well, you are passing the reference to an object (or null). Yes, you are passing a reference and yes you are passing the value of the reference, really you are just passing a pointer to the object but they lie to you about Java not having pointers so they have to call it something else.

      C++ does gives you so much more choices

    6. Re:Things to consider when coming to C++ from Java by cxvx · · Score: 1
      You are incorrect, well, not really as you just said the same thing as the original poster did but in a less clear way.

      I'm not incorrect. The OP said

      In Java Objects are always passed by reference, primitive types by value.
      while I said
      In Java, everything is passed by value. You never pass objects by reference, you pass references to objects by value.

      That's not the same and there's quite a semantic difference between those two.

      The way I told it is correct. And even you yourself say:

      Yes, you are passing a reference and yes you are passing the value of the reference,
      Now, you're only rehashing what I said, while at the same time saying I'm wrong. You might want to think this over again some time.
      --
      If only I could come up with a good sig ...
    7. Re:Things to consider when coming to C++ from Java by ralatalo · · Score: 1

      There is only a difference between passing a reference to an object and passing the value of the reference to an object when there is a way to access an object without using a reference which there isn't in Java. So, in Java there is NO difference.

      In C++ where you can access an object directly, though a pointer, or by a reference there is a difference.

      Therefore, you are incorrect to state that the original poster was incorrect, thougth as you say... you just rehashed the view of the original.

      You might want to think again, what's the difference beween giving someone your P.O. Box number and giving them a copy of your P.O. Box number.

      I think it's truely misleading to say that Java passes objects by value, and you try to cloud the water by saying that Java passes everything by value and therefore Java is passing the value of a reference rather than passing a reference.

      Even in, C/C++ functions arguments are really all pass by value. You just pass the value of the pointer or the value of the reference when you write it as pass by reference. You aren't really passing a reference or a pointer. The system copies the values onto the call stack and passes control, so everything is pass by value if you want to go to the details. But why do you want to make things so confusing?

    8. Re:Things to consider when coming to C++ from Java by mrjohnson · · Score: 1

      I believe the author meant to refer to primitive types....

      The object *reference* is passed by value, but it's still only a reference.

      Later, he says:
      "Java copies and passes the reference by value, not the object."

      But, you're right -- I could have read the article more closely. I would have linked one of the other hits. :-)

  27. Accel C++ by thebroken · · Score: 3, Insightful

    The book my Koeing and Barbara Moo, Accelerated C++, is an excellent starting point in my oppinion. If you have previous programming experience, i suggest you pick this up, rather than a 500 page primer. It goes through a lot of stuff and a suprising rate. It also teaches you some basic algo's and uses STL right from the start, not the sort of backward teaching some other books use. It's very good, and i suggest you pick it up. You might also try Bruce Ekels Thinking In C++, they can be found for free (both volumes) on his site. Simply google the title and it will take you there.

  28. after c++ learn c# by tanadeau · · Score: 1

    After learning c++, I would recommend learning c#. I t has many of the nice features of Java, like complete OO, strong typing, automatic polymorphism, etc,, and many of the powerful features of c++ like operator overloading and the use of pointers in unsafe code blocks (only used when speed is very important).

  29. Why hasn't anyone recommended Thinking in C++? by techstar25 · · Score: 2, Informative

    You can't go wrong with Eckel's Thinking In C++. You can download it for free. Or buy it. It seems to have been designed for C programmers moving to C++, but for free it makes a great reference (picked up a hardcopy of an old edition on half.com for $3, just because I like hardcopies, although I keep the current softcopy nearby).

  30. free book online by StandardDeviant · · Score: 1

    (disclaimer: one of my livejournal interests is "informed dislike of c++". ;))

    Bruce Eckel has written some fairly good (IMHO) books on c++ and Java. You can download them for free from here. The thing I like best about his approach is that it tries to teach you more than just the syntax, also (as the titles suggest) how to think in that language. The only con to his writting style is that his examples are sometimes a little contrived...

    As other posters have said, do try to learn the STL as soon as possible. It makes C++ far less painful and more like Java. Of course, you could be stuck in a situation where your compiler is really old (bad templates support) and/or the environment doesn't have the STL, so as nice as std::vector is, you should probably learn how to use arrays too. ;) One of the biggest flaws in C++ to me is that it is almost like three languages in one, any one of which can be used to build a solution, but the best way isn't always obvious. [Well, and manual garbage collection sucks!]

    Good luck!

  31. Thinking in C++ by Anonymous Coward · · Score: 0

    I can' believe nobody has mentioned this book yet! It gives you a great insight into the language and why it works like it does.

    You can download it from http://bruceeckel.com/. If you want you can try Thinking in Java first, as you already know the language, it will give you an insight of the kind of book they are.

  32. Re:One word: Don't. by mrlpz · · Score: 1

    Exactly my point ! The point is most propellerheads today have this Jihadish leaning towards Java. What ? You expect the framework to save your a$$e$ or something ? Good , if that were the case, then you could compile a java jvm with itself and call it well and good. Do most of you even realize that most JVM's are written a language that starts with the third letter of the English language ?

    Get in touch with reality, just because you CAN do something, doesn't mean you should, or weren't the rest of your liberals listening to yourselves when you squawked that Bush shouldn't go into Iraq for this or that reason....same THING with Java. Just because SWING/SWT exist, doesn't mean they're anywhere near where other visual frameworks are in terms of richness. Exactly where do you think the concepts for templates and generic programming came from ? Cobol ? Fortran ? Smalltalk ?

    Please....if you're going to berate C++, then stop use KDE, GNOME, or just about any replacement desktop ( for linux or otherwise ). Write yourself a replacement shell in Java....let's see how far we get with that. ( curious reminder of where earlier projects to produce a Java Client PC system are today ).

  33. Re:One word: Don't. by jonadab · · Score: 1

    > Move away from C++ to what exactly.

    To VHLLs, of course. I thought I was clear on that point.

    > The only other languages you mentioned where[sic] Perl, Python, Ruby, or

    > Scheme. I have yet to use Ruby or Scheme, but I did look up some things

    > on them.

    Try learning one of them.

    > Most of those languages are scripting lanugages and aren't really what

    > you'd program a major application in. I know I user perl for sys admin

    > tasks and quick hacks to just 'get things done'

    A good language is flexible enough to be used for "quick hacks" as you

    put it or for full-blown applications. In fact, often a quick hack to

    get something done ends up turning *into* a full-scale application over

    the long haul. All four of the languages I listed are rapidly gaining

    recognition as excellent choices for large-scale application development,

    due largely to the excellent ratio of results to programmer time. (C and

    C++ get a slighly better ratio of results to CPU time, but CPU time is

    cheaper than programmer time and these days is almost never the bottleneck

    for most categories of applications.)

    > Those languages are solid, and fast. You can do most anything with them.

    Congratulations, you've discovered Turing equivalence. Of course you *can*

    do almost anything with them. The more useful questions are, how long does

    it take you to write and debug the code, and how easy is it for someone else

    to read and understand it? On the first question, C and C++ get abysmal

    scores compared to e.g. Perl; the second question, as you point out, relates

    a lot more to programming style and is largely independent of language. A

    good programmer can write good code in pretty much any language he has taken

    the trouble to learn, with certain obvious exceptions which deliberately defy

    good programming practice. (For example, befunge is deliberately designed so

    that data and code are not separate; this violates one of the basic principles

    of maintainable code, so it's very hard to write good code in that language.

    Similarly, unlambda is designed so that even simple problems cannot be solved

    in conventional ways, but only by mind-bending paradigm gymnastics. SPL is

    designed to be so absurdly verbose that no problem of any significant scope

    can be solved in a section of short enough to read in one sitting. Nobody

    writes good code in these languages, but it doesn't matter; that wasn't

    their purpose.)

    --
    Cut that out, or I will ship you to Norilsk in a box.
  34. Re:One word: Don't. by seanbry · · Score: 1

    You seem to be noting exceptions to practical programming languages. It's like using BrainFuck to do everything you need. It is indeed a turning complete language, but you wouldn't use it unless you just wanted to have some fun.

    In reponse to writing code, and debugging it. Well if written well and I try to keep good practices, I usually don't have a problem debugging C. As programs get larger eventually CPU consumption becomes a problem. And using Perl or another scripting language just looses practicality. And C / C++ offers better memory managment that other languages just don't have.

    In either case , you have to make sacrificies. CPU consumption time versus program needs.

    I guess we can agree to disagree on the proper use of languages. I just can't see myself ever using perl for a industry application. I love perl just because of the flow and ease of use. It's powerful and flexible, but somethings must be written in other languages. I wouldn't write an OpenGL game in Java though it can be done, it'd be slow. I stick to what I know is fast C / C++.

    As far as readablity it all depends on the progamer. I can write clean perl and clean C. Both easy on the eyes. Yet I find the flexiabilty of perl to have its down fall. You can quickly write 'ugly' perl because of its flexability. C forces a bit more stricter syntax than perl , but then again its still quite easy for me to write 'ugly' C.

    When it boils down to it, all is left in the hands of the programmer, how clean or dirty he keeps his/her hands is up to him/her.

  35. I've done exactly that ... by arhar · · Score: 1

    .. and I second the recommendation for Timothy Budd's "C++ for Java Programmers" (ISBN 0201612462) ... great book!

    Also, this tutorial is full of useful information. However, you have to ignore the occasional bitter remarks about Java from the author, such as these gems:

    Unlike Java, C++ is a fast, powerful, and flexible programming language.

    Java was built as a simple-to-learn subset of C++ for set-top boxes and drooling AOL users. Now, it's time to play in the big leagues.

  36. What I used.... by spinkham · · Score: 1

    For me, Essential C++ was a good jumpstart book, and then
    The C++ Programming Language is of course the gold standard if you need to go deeper.
    I have also heard good things about Accelerated C++, but haven't looked at it myself.

    --
    Blessed are the pessimists, for they have made backups.
  37. Re:One word: Don't. by Anonymous Coward · · Score: 0
    You seem to be noting exceptions to practical programming languages. It's like using BrainFuck to do everything you need. It is indeed a turning complete language, but you wouldn't use it unless you just wanted to have some fun.
    The previous poster was not advcating using Branfuck or Unlambda for general programming tasks. They were stating that you could do so. The point was that just because you can do most anything with a language, doesn't mean you should.
    As programs get larger eventually CPU consumption becomes a problem.
    ML, OCaml, Haskell, Lisp etc, are all compiled languages, with runtime speeds comparable to compiled C/C++.
    And C / C++ offers better memory managment that other languages just don't have.

    C/C++ memory management is unnecessarily low level. How exactly is it superior to that found in a modern garbage collected language? As an application programmer, why should I have to keep track of every bit of memory when I dont have to? Why would I even want to.
    In either case , you have to make sacrificies. CPU consumption time versus program needs.
    Not really. The above compiled languages are comparable to C++ for resultant executable speed. You dont need to make as much of a sacrifice as you seem to think.
    I stick to what I know is fast C / C++.
    Without even investigating the alternatives? There was a time when people knew the earth was flat. Just because you think your C/C++ code is fast does not mean it is. And don't forget development speed.

    There are some tasks which C/C++ is suited. For most development tasks, there are better alternatives IMHO.
    As far as readablity it all depends on the progamer. I can write clean perl and clean C. Both easy on the eyes.
    You may be able to keep you hands clean, but what about the other guys on the project? If you were using a language with a more uniform syntax, safer semantics or even just fewer special cases to be learnt, then it would be easier for everyone to keep their hands clean.
    Yet I find the flexiabilty of perl to have its down fall. You can quickly write 'ugly' perl because of its flexability. C forces a bit more stricter syntax than perl , but then again its still quite easy for me to write 'ugly' C.
    If strictness of the language is a major concern for you, then you would be using a language which has much stricter semantics than C/C++.

    Just my 2c
  38. Thoughts from a java convert by m4k3r · · Score: 1

    My uni basically only taught Java as a programming language, which proved (not very) useful for my first real development job in c++.

    Things I wished I'd realised sooner:
    1) Learn how to use (or write, if you're brave) STL iterators with containers.
    2) Learn the difference between the stack and the heap.
    3) Use memory leak checkers (eg. valgrind), as you WILL get memory management incorrect.
    4) Realise that destructors in c++ are actually useful, in that you know (more or less) when they'll be run.

    I've read some code written by people claiming to know c++ with a java background. Every single object was created with the new object, including those used only in the current scope. yeeech.

  39. Re:One word: Don't. by mrlpz · · Score: 1

    Where to start...you poor misguided anonymous coward. I know...almost at the beginning.

    "ML, OCaml, Haskell, Lisp etc, are all compiled languages, with runtime speeds comparable to compiled C/C++."

    If you read from the introduction to Haskell itself, even THERE it clearly states that in cases where "In applications where performance is required at any cost" ( direct quote ) C( and by inference C++ ) is the better choice, and since I've yet to see a Lisp compiler generate code anywhere NEAR what a C/C++ parser itself can generate, I'd say that applies there as well.
    I will, however, concede that with things like GreenCard, it may be possible to create a mixed language system that could both provide some HLL "ease" of use along with little or no compromises in speed.

    If you can write perl code, and the other guys on your team can't, respectfully suggest to them that they wash their hands before they code.

  40. Re:One word: Don't. by RianDouglas · · Score: 1
    (I'm the previous AC)
    "Premature optimisation is the root of all evil"
    C.A.R. Hoare.
    "Programming in C++ is premature optimization."
    From comp.lang.python
    Wouldn't you be better off choosing a language which is more expressive, flexible, and lets you produce a solution sooner? You can always change algorithms, or call out to lower level code if you need better performance.

    These benchmarks compare many languages. OCaml and Lisp do quite nicely vs C/C++.

    It comes down to using the best tool for the job. It's just unfortunate that most people only have one or two tools in their toolbox, and force problems/solutions to fit the tool.

    As for your last point, I'd prefer not to write Perl code :-)
  41. Re:One word: Don't. by mrlpz · · Score: 1

    As is the case with most college students I come across as interns.

    Whomever in the python newsgroup got the impression that C++ was premature optimization obviously show little mature of character, much less of programming, or application much less algorithmic design. It's not meant as a personal affront to them, but in general. In college you have it droned into you that things be generalized as this, or that, when in reality, you'll hardly ever truly run across generalizations when developing solutions for business or practical matter. Generalizations are the strata that academia wrap themselves in so that they can have some semblance of mysticism without ever having to deal with "specifics". I loved the statement, "the solution is trivial at this point". Ever ask an anesthesiologist if the solution to how much anesthesia he applies is ever trivial ? Doubtful.

    Why ? Because specificity IS the solution. All these modern pseudo-code script languages allow you to speak in generality to the solution of a problem, and use the argument that we can "throw more CPU or memory at it"...it is after all "cheaper" these days. I've not seen ONE client who's casually ( much less that dismissively ) agree that "Sure, we can buy another rack of servers each with a couple of gigs of ram, and a few 250Gb hard drives...why not, it's "cheaper" these days. Yeah, right !
    Just to make the programmers life easier and let him design a program in one of those languages that doesn't require much specificity. Of course it says NO SMALL THING, that all the companies listed on the Haskell main site are companies with the revenue to push something like Haskell. But in MOST cases, that is not the case. And it will continue to not be the case, as long as there are bean counters watching IT budgets. And if anything in life is as sure as death and taxes, it'll be that accountants and comptrollers will ALWAYS have the last laugh.

    Doubt me ? You don't have to look far into the past for proof, just look at DOT bust. So when in doubt, don't generalize, much less program in it.

    As for perl, programming in perl is like going for a root canal in the days before NOX. You know it's going to be painful.

  42. Re:One word: Don't. by Tukla · · Score: 1

    Wow. Brainfuck looks almost as scary as Whitespace. And I used to think APL was hard to follow.

  43. Re:One word: Don't. by Tukla · · Score: 1
    As for your last point, I'd prefer not to write Perl code

    Writing Perl is easy. Reading Perl, that's hard. (/Scotty)

  44. Re:One word: Don't. by RianDouglas · · Score: 1
    The main reason management types give for using C/C++ is due to perceived availability of personel, not performance. Pretty much the same reason as is given for VB. Most people I know can also write english - doesn't mean you'd get them to write a book.
    All these modern pseudo-code script languages allow you to speak in generality to the solution of a problem, and use the argument that we can "throw more CPU or memory at it"...it is after all "cheaper" these days.
    You are talking as if C/C++ are the last word in programming langauges. Why not use assembly if performance is so important? You do know that Lisp is older than all languages in use, other than Fortran? And that OCaml often out performs C++? Its also generaly acknowledged that programmer time is more expensive than server time. Save yourself some of the team's time. You could the buy the equipment with some of the savings, and pocket the rest. I'm sure clients would hate that.
    I've not seen ONE client who's casually ( much less that dismissively ) agree that "Sure, we can buy another rack of servers each with a couple of gigs of ram, and a few 250Gb hard drives...why not, it's "cheaper" these days. Yeah, right !
    If you have factor in the robustness, flexibility and maintainability of the resultant system, the client may prefer to buy the extra rack of equipment, than be delivered a faster (perhaps), rigid, inflexible and brittle solution, late in C/C++. You also need to factor in maintenance costs.
    And if anything in life is as sure as death and taxes, it'll be that accountants and comptrollers will ALWAYS have the last laugh.
    I didn't think accountants had a sense of humour.
    As for perl, programming in perl is like going for a root canal in the days before NOX. You know it's going to be painful.
    I agree entirely.