CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 34

Thread: Java to C++

  1. #16
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Java to C++

    So to sum it all up:
    Quote Originally Posted by potatoCode
    learn C++ as if you knew nothing about it.
    Where "it" means Java.

    Regards,

    Paul McKenzie

  2. #17
    Join Date
    May 2009
    Posts
    2,413

    Re: Java to C++

    Quote Originally Posted by sgiri1981 View Post
    Dear All,
    I m new to C++ and am transitioning from Java. I m comfortable with the principles of OOP, which I learnt along with Java.
    You're at square one. Java means nothing in the C++ world. Java and C++ are VERY different languages.

    Start learning C++ from the beginning. I recommend the new book by Stroustrup (the founder of C++). It's called Programming, Principles and Practices Using C++.

  3. #18
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Java to C++

    Quote Originally Posted by nuzzle View Post
    You're at square one. Java means nothing in the C++ world. Java and C++ are VERY different languages.
    Exactly. Even though many of the posts here are helpful in stating the differences in the two languages, I would believe that trying to figure out the differences would be very confusing to a Java programmer learning C++.

    So the safest thing to do is to hide all of the Java books, pretend Java doesn't exist, and learn C++ from scratch.
    Start learning C++ from the beginning. I recommend the new book by Stroustrup (the founder of C++). It's called Programming, Principles and Practices Using C++.
    Another book is "Accelerated C++" by Koenig & Moo.

    Regards,

    Paul McKenzie

  4. #19
    Join Date
    May 2009
    Posts
    2,413

    Re: Java to C++

    Quote Originally Posted by Paul McKenzie View Post
    Even though many of the posts here are helpful in stating the differences in the two languages,
    They're not helpfull. They suggest there are minor differences between C++ and Java/C#. There isn't. The differences are major.

  5. #20
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Java to C++

    Quote Originally Posted by nuzzle View Post
    They're not helpfull.
    Well, those are the differences, whether they are helpful or not is a matter of opinion.

    I don't disagree with you that any Java or C# programmer going to C++ should just forget about those languages when learning C++. That's been proven by the many threads started on CodeGuru by Java programmers who have totally butchered C++ programs with Java-ized code.

    Regards,

    Paul McKenzie

  6. #21
    Join Date
    May 2009
    Posts
    2,413

    Re: Java to C++

    Quote Originally Posted by Paul McKenzie View Post
    Well, those are the differences, whether they are helpful or not is a matter of opinion.
    Well, point at a helpful difference that has been pointed out in this thread?

  7. #22
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: Java to C++

    Quote Originally Posted by nuzzle
    Well, point at a helpful difference that has been pointed out in this thread?
    Aye, I went straight to suggesting Accelerated C++ because I felt that it was futile to try and answer the more technical questions. It would be better for sgiri1981 to just learn C++ and then compare for himself/herself in retrospect.
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  8. #23
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Java to C++

    Quote Originally Posted by nuzzle View Post
    Well, point at a helpful difference
    "Helpful" is subjective. Maybe the OP has now seen so many differences, they've been convinced into *not* assuming that Java and C++ are similar (hopefully the OP sees that it's a loser trying to leverage what they've learned in Java in learning C++).

    I've responded many times on threads over the years like these concerning Java programmers learning C++. I've gotten into many disagreements from Java programmers saying what they're doing is OK. Again, you have no argument with me when it comes to Java programmers learning C++.

    Regards,

    Paul McKenzie

  9. #24
    Join Date
    May 2009
    Posts
    2,413

    Re: Java to C++

    Quote Originally Posted by Paul McKenzie View Post
    "Helpful" is subjective.
    It's like with my kangoroos. They aren't very helpful.

  10. #25
    Join Date
    Nov 2006
    Location
    Essen, Germany
    Posts
    1,344

    Re: Java to C++

    Quote Originally Posted by nuzzle View Post
    It's like with my kangoroos. They aren't very helpful.
    At least they´re tasty
    - Guido

  11. #26
    Join Date
    Apr 2007
    Location
    Mars NASA Station
    Posts
    1,436

    Re: Java to C++

    You can switch from any languages to any languages provided you understand the concept.
    Thanks for your help.

  12. #27
    Join Date
    Jul 2002
    Location
    Portsmouth. United Kingdom
    Posts
    2,727

    Re: Java to C++

    Quote Originally Posted by Paul McKenzie View Post
    I don't disagree with you that any Java or C# programmer going to C++ should just forget about those languages when learning C++.
    Do long term C++ coders have the same sort of problems when trying to learn Java/C#. I imagine that forgetting (almost) all things are references would likely trip up the unwary.
    i.e.
    This snippet will do different things in C++ and Java/C#
    Code:
    a.value = 0;
    b = a;
    b.value = 1; // Has 'a' changed? Depends on the language.
    Last edited by JohnW@Wessex; May 19th, 2009 at 02:55 AM.
    "It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
    Richard P. Feynman

  13. #28
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Java to C++

    Quote Originally Posted by JohnW@Wessex View Post
    Do long term C++ coders have the same sort of problems when trying to learn Java/C#. I imagine that forgetting (almost) all things are references would likely trip up the unwary.
    The problem that I see with C++ programmers going to Java are these:

    1) Not getting used to what "=" does in Java (which is your snippet)

    2) Not using the ready-made libraries by Sun and other companies, and instead code their own routines. Most of the time, the reason for this is that the C++ programmer is not aware of these libraries (or particular library) that exists to do the job (not really because the C++ programmer believes they're superior programmers and who must "code it themselves").

    3) Getting used to the difference between a byte and a character.

    4) Not only the language is different, but the programming paradigm is different (for example, a typical Java app throws exceptions if you make the slightest wrong move, while C++ only throws exceptions when there are those rare exceptional conditions).

    A C++ programmer can readily maintain an existing Java application -- however (and IMO) it takes much more for a C++ programmer to actually design and start coding a non-trivial Java app from scratch. The same vice-versa, however an existing C++ application being maintained by a Java programmer scares me more than the other way around.

    Regards,

    Paul McKenzie

  14. #29
    Join Date
    Oct 2000
    Location
    London, England
    Posts
    4,773

    Re: Java to C++

    When I coded in Java I commonly made the mistake of forgetting to initialise members, eg collections, so I would for example have a vector as a class member and try using it forgetting that it was null by default.

    It was also difficult to grasp in some ways the lack of ownership and the lack of const, so if I passed a vector from a class to a function in another class that function could do what it wanted with it, and also if it stored a copy, neither class actually "owned" it.

    A noticeable issue was that a Java project with a bad class path would run continuously, just throwing ClassNotFound exceptions and logging them whereas a similarly bad C++ program (i.e. bad LD_LIBRARY_PATH or whatever) would probably have terminated, probably immediately on start-up, which would mean it would be easier to fix. Particularly given that you might have the class path correct in dev and wrong in production (they never quite match up exactly). Of course this may have been a less-than-perfect setup. Probably a good setup would ensure all the required .jar files are there as soon as your Java server starts up and terminate instantly if they are not, allowing you to fix the issue.

  15. #30
    Join Date
    May 2009
    Posts
    28

    Re: Java to C++

    Hi All,
    Good to see so many fruitful posts while I was away, tied up in yet another language: SAS.

    Quote Originally Posted by Paul McKenzie View Post
    ....
    ....

    The same vice-versa, however an existing C++ application being maintained by a Java programmer scares me more than the other way around.

    Regards,

    Paul McKenzie
    I m precisely in this situation!!

Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured