Thread: Transition from Java to c++..

  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    21

    Transition from Java to c++..

    Guys please help me out with this

    I know the basics of C language.Now i want to learn Java..But i want to ask that after learning Java is it difficult to learn C++.

  2. #2
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by ankitsinghal_89 View Post
    Guys please help me out with this

    I know the basics of C language.Now i want to learn Java..But i want to ask that after learning Java is it difficult to learn C++.
    You're asking if Java somehow pollutes/corrodes your mind in such a way that learning C++ becomes more difficult?

    No comment. Although I suppose you could excise the infected brain matter with an appropriate surgical procedure
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    I think if you already know C, you will learn Java from a different perspective than a complete newbie - I think the difference will help you when you return to C++. I am of the opinion that C and Java are two totally different paradigms, and focussing on one too much can harm your skills in the other. However, C++ has changed a lot since I first started learning it - and it is now a lot more like other OO languages. I think you'll be fine.

  4. #4
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Just remember:
    Java ---> void main()
    C++ ---> int main()
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  5. #5
    Registered User
    Join Date
    May 2009
    Posts
    37
    i believe, instead of Java polluting your mind, it should be C++ polluting you mind, in the sense that C++ is more powerful (in some sense), and you might get off-tracked with OOP. So learning Java first is actually a good idea.

  6. #6
    The larch
    Join Date
    May 2006
    Posts
    3,573
    The main obstacle for me learning another language is that I pretty much find my way around in one language, but I'll be rather clueless in another language for quite some time which means I won't be able to write similar programs (beyond doing C in any language) efficiently in the new language. This lowers the motivation a bit.

    Right now it is C++ holding me a bit back from exploring Python and C#, but C++ was my second language and I "got going" with it at a second attempt too (but at first I tried to use the tutorial that comes with DevCpp, so no wonder ).

    Basic syntax of another C-like language (at the level of "programming C in it") comes quite quickly, though. A HiLo game is a matter of minutes of learning
    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).

  7. #7
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Java is a one-paradigm language. It supports object-oriented programming, and will be in your way if you want to do any other paradigm (procedural, generic, functional). This means that if you do Java exclusively for a long time, you will become accustomed to thinking about every problem in the Java way.

    C++ is a multi-paradigm language. It will happily support procedural, object-oriented and generic programming, and some functional programming too, although it isn't very good at that. When designing solutions in C++, you're supposed to think about the problem from multiple viewpoints and choose the most effective way of solving it.

    There's no problem with learning Java before C++, as long as you keep the flexibility of thinking that makes C++ so interesting to use.

    When you do learn C++, there will be new concepts to learn and integrate into your way of thinking. Generic programming is something supported in very few languages (AFAIK, these are Ada, C++, D, and possibly some functional languages). C++ has a very different resource management philosophy than most other languages. Don't let Java make you narrow-minded, and you'll be just fine with whatever other language you choose to learn afterwards.
    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

  8. #8
    and the hat of copycat stevesmithx's Avatar
    Join Date
    Sep 2007
    Posts
    587
    Quote Originally Posted by CornedBee View Post
    Generic programming is something supported in very few languages (AFAIK, these are Ada, C++, D, and possibly some functional languages).
    IIRC, Java supports generics as of jdk 1.5.
    Not everything that can be counted counts, and not everything that counts can be counted
    - Albert Einstein.


    No programming language is perfect. There is not even a single best language; there are only languages well suited or perhaps poorly suited for particular purposes.
    - Herbert Mayer

  9. #9
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    > IIRC, Java supports generics as of jdk 1.5.
    Yes and they're mostly broken. Especially when arrays come into play. Other than a few other "WTFs", Java is sort of nice.

    Perhaps one reason I never have bothered with C++ is because I seem to have all the bases covered, with C, Perl and Java (maybe some ML if really required ).
    Last edited by zacs7; 05-09-2009 at 09:04 AM.

  10. #10
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Generics in Java support type-safe programming with containers. They don't support generic programming.
    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

  11. #11
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by CornedBee View Post
    Generics in Java support type-safe programming with containers. They don't support generic programming.
    And all that nice type info that you added to the "generic" code is stripped away by the compiler when you actually compile it, so then you no longer have a container of Foo<String> and Foo<int>, they both become Foo.
    Any static data in those classes is then shared between both your Foo<String> and Foo<int> instead of having separate static data for each instance type the way you would have in C++.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  12. #12
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Based on my interviews with candidates who are usually only familiar with Java I would agree with Corned Bee's statement that Java object oriented code is just that - purely Java object oriented code.

    When asked about many of the basic OO concepts that apply to any language I always get the how I would do it in Java answer. This tells me that they are focusing on one implementation of the concept rather than the concept itself. It is my opinion that Java only teaches you the Java way to do this or that and does not necessarily teach you the concept behind it.

    C++ on the other hand brings much more to the table and if you are simply used to 'how you would do it in Java' you will have a very tough time with C++. However, if you read the gang of four design patterns book and others like it and apply the concepts to C++ rather then the impl of the concept then you will probably do quite well with C++.

    C++ offers so many approaches that if you think in terms of the impl of the concept you will get lost very quickly. C++ also does not give any hints as to which is the correct approach for your problem and also does not force you into any certain design. Because of this it is more difficult to design since there are so many approaches available but it also makes it extremely flexible.
    C++ will let you mix and match designs and approaches even if it is not the best idea in the world, but it will still let you do it.

    If you are going to learn Java that is fine but make sure you understand fully what concepts the language simplifies and/or hides from you before transitioning to C++. I'm sure some professors are telling students that if you know Java then you know C++, and thus the reason why people put it on their resume even though they cannot write one line of C++ code on a whiteboard. Just because you know Java does not mean you know C++.

    Perhaps one reason I never have bothered with C++ is because I seem to have all the bases covered, with C, Perl and Java (maybe some ML if really required ).
    I whole-heartedly disagree with this statement.
    Last edited by VirtualAce; 05-09-2009 at 11:00 AM.

  13. #13
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    > I whole-heartedly disagree with this statement.
    Sure but for personal projects, I see no need for it :-)

  14. #14
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Quote Originally Posted by zacs7 View Post
    Perhaps one reason I never have bothered with C++ is because I seem to have all the bases covered, with C, Perl and Java (maybe some ML if really required ).
    I wasn't aware you could use all of them in the same source file.
    (It can be done with Perl and C, of course )
    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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Mats, the java answers
    By Jaqui in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 04-22-2008, 02:12 AM
  2. C#, Java, C++
    By incognito in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 10-05-2004, 02:06 PM
  3. The Java language is being expanded
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 26
    Last Post: 06-11-2004, 09:07 PM
  4. Java woes
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 07-06-2003, 12:37 AM
  5. How to use Java with C++
    By Arrow Mk 84 in forum C++ Programming
    Replies: 2
    Last Post: 02-27-2003, 04:12 PM