Thread: C++ vs. Java

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    104

    C++ vs. Java

    Hey, I read in the Thinking in C++ book that C++ is essentially the same as Java. Is this so?

  2. #2
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    Well, Java and C++ are very similar, but certain differences are too big for them to be called the same, one being how files are created, applets vs executables. They both have classes, but they use them in different ways. Third, Java can do what C++ can, but, it takes certain commonly used bits of code and wraps them into functions. For instance I believe there's one that is the equivilant to combining getch(); and return 0; (just a rough example, not exactly that same) Java is also more portable to the internet, for servers as well as web pages themselves can be generated by java, C++ can generate any kind of text (ie: web page code) you want it to, but you can't use it for web page interactivity like you can Java, so it's really what you're going to do with it that matters which language to choose, i recommend learning and using both, never hurts on a resume .
    PHP and XML
    Let's talk about SAX

  3. #3
    Banned borko_b's Avatar
    Join Date
    Jun 2002
    Location
    Well... I live in Bulgaria :)
    Posts
    100
    actually C++ and Java are quite different... (even in syntaxis)

    Java doesn't have global functions or variables they must be all wrapped in a class

    Java is interpreted language and C++ is compiled language
    (there is no such thing as Virtual C++ machine)

    Java doesn't have pointers , C++ has

    the concept of virtual methods in C++ is slightly different than Java's

    Java has its implementation of methods inside class declaration only
    C++ has outside and inside

    and Java sux , C++ does not! )

  4. #4
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    Borko, isn't everything in Java, besides primitive types, a reference/pointer? The only difference is that you don't have to dereference them. (Don't worry, I'm probably wrong. )

  5. #5
    Banned borko_b's Avatar
    Join Date
    Jun 2002
    Location
    Well... I live in Bulgaria :)
    Posts
    100
    >>Borko, isn't everything in Java, besides primitive types, a
    >>reference/pointer? The only difference is that you don't have to
    >>dereference them. (Don't worry, I'm probably wrong. )

    Java has no primitives
    even int is wrapped in a class
    it also does not actually has 'arrays'
    it has only 'vectors' of classes
    for instance
    in Java :

    int array[20];
    is not an array it is vector ...
    and it can grow beyond 20...

    >>...reference/pointer...
    Yes every object is passed in refference manner to the methods
    but still there are no pointers in Java...

    There is a major difference between 'reference' and 'pointer'

    they both access memory indirectly BUT references cannot be incremented, they allways 'reference' to a single object during their lifetime hence cannot be used for arrays like pointers can...

  6. #6
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    Java does have primitives. int, float, double, byte are primitives. The uppercase versions are the wrapper classes.

    I am paraphrasing Eckel. I can post the table if you would like.

  7. #7
    geek SilentStrike's Avatar
    Join Date
    Aug 2001
    Location
    NJ
    Posts
    1,141
    Saying they are similiar is true. However, they are by no means the same... I am suprised you got that impression from reading Eckel, his Thinking In Java book was very good.
    Prove you can code in C++ or C# at TopCoder, referrer rrenaud
    Read my livejournal

  8. #8
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    I did understand what he meant. It is just that I am very bad at explaining myself. I put things in my own mental terms and don't really use appropriate wording.

  9. #9
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Its funny how people get upset about what you just said It took me an afternoon to learn C++ because I knew both Cand JAVA very well. This would be speaking only in terms of programming though. Other than that they work very differently as far as how the interface with the OS. If anything, JAVA molded itself from C++ not the other way around.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C#, Java, C++
    By incognito in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 10-05-2004, 02:06 PM
  2. First Java Class at college
    By GanglyLamb in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 09-29-2004, 10:38 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. C or Java as a first language
    By CorJava in forum A Brief History of Cprogramming.com
    Replies: 34
    Last Post: 10-23-2002, 05:12 PM