Thread: Java and C++ are alike ?

  1. #1
    flashing vampire black's Avatar
    Join Date
    May 2002
    Posts
    563

    Java and C++ are alike ?

    i know something about C++ but nearly nothing of Java, some friends told it is easy to understand and they are alike, most interesting is they said in Java you need not to face pointer directly, which is cool, but I think C++ has many advantages over Java, any opinions ?
    Never end on learning~

  2. #2
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,490
    If you know nothing of Java, how can you say that C++ has many advantages over it?

  3. #3
    CS Author and Instructor
    Join Date
    Sep 2002
    Posts
    511
    Well this is an open question you will receive many opinions from.

    here are a few.

    1. All have direct ancestor of C.

    2. Java has no multiple inheritance (uses interface)

    3. Java has no pointers (references)- can use pointers in C# but is considered unsafe

    3. Java is platform independent. Unlike C/C++.

    4. Java and C# are object oriented (C++ is technically hybrid)

    I have taught both C++ and Java. I personally perfer Java and now C# over C++. My college and I still teach C as a structured non OOP language.

    Just my thoughts...
    Mr. C: Author and Instructor

  4. #4
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,490
    C++ is technically hybrid
    AFAIK, the term 'object oriented' means that a language implements polymorphism. 'Object based' describes a language which deals with objects and isn't polymorphic. So C++ is totally object oriented. At least, that's my understanding.

  5. #5
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    C++ is technically multi-paradigm. It isn't object oriented because you can write as large (or as small) a program you want without touching objects (at least nothing beyond a struct to hold some data). On the other side, you can write almost completely object-oriented code.

    As for which has advantages over the other... as always, this depends on your application of it.

    Try writing a high-performance matrix library in Java or an interactive web program in C++.
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  6. #6
    flashing vampire black's Avatar
    Join Date
    May 2002
    Posts
    563
    Originally posted by Mister C
    Well this is an open question you will receive many opinions from.

    here are a few.

    1. All have direct ancestor of C.

    2. Java has no multiple inheritance (uses interface)

    3. Java has no pointers (references)- can use pointers in C# but is considered unsafe

    3. Java is platform independent. Unlike C/C++.

    4. Java and C# are object oriented (C++ is technically hybrid)

    I have taught both C++ and Java. I personally perfer Java and now C# over C++. My college and I still teach C as a structured non OOP language.

    Just my thoughts...
    from your opinion Java seems definitely beyond C++, i cant see something be advantages over Java (well, if you say pointers, but some go for it and others resists it)
    Never end on learning~

  7. #7
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >from your opinion Java seems definitely beyond C++, i cant see something be advantages over Java
    This is a dangerous assumption if you don't have extensive experience with both languages. From my experience, Java is a diluted, "safe" C++. If you take C++, remove everything but the OO paradigm, remove everything you consider too complicated or too unsafe, add keywords up the wazoo to avoid the C/C++ "static" confusion, force arbitrary size decisions on the language, and throw a huge and useful collection of libraries into the mix, you pretty much have Java.

    >AFAIK, the term 'object oriented' means that a language implements polymorphism.
    There are four key concepts: Abstraction, Polymorphism, Inheritance, and Encapsulation.

    >but I think C++ has many advantages over Java, any opinions ?
    It depends on what you intend to use either language for. For many tasks C++ is too much language for the simple job you want done, so you choose a language more specialized (or slower, but simpler and more productive).
    My best code is written with the delete key.

  8. #8
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    >>> 3. Java is platform independent. Unlike C/C++.

    Well, compiled binaries are not platform independent, but pure ANSI C/C++ code will work on any platform with a compliant compiler (which is most you'll deal with probably). Same way Java has to have a bytecode interpreter for its target platform.
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  9. #9
    CS Author and Instructor
    Join Date
    Sep 2002
    Posts
    511
    OK, I knew I would

    "platform independent": -an example here is that primatives in Java have the same size regardless of the compiler/platform.

    "C++ is hybrid" : Well it is not totally OOP- this is known. Java and C# you have to use a class just to write a basic program. C++ you can write a program without using a class.

    Prelude is right in stating the four hallmarks in OOP.

    C++ does has some advantages :

    1. I/O is much easier.
    2. Formatting is easier.

    those are a few.
    Mr. C: Author and Instructor

  10. #10
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    >>> "platform independent": -an example here is that primatives in Java have the same size regardless of the compiler/platform.

    Okay, I see what your getting at. Java code will behave the same anywhere, C++ code might not, depending on how data is stored.

    C++ has a few other strengths: generic programming through templates, and speed (while maintaining some semblance of OOPness) again, largely due to templates and lower-level memory access.

    A lot of things you can do in C++ though, you can also do in Java. Which is 'better' depends on which you are more familiar with, and what the problem requires. There are some things for which C++ is simply overkill, or are difficult to accomplish in C++, but not in Java.
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  11. #11
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    Yeah, I've heard rumors that templates might be added to Java. Not sure of the validity of the rumors though.

  12. #12
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,380
    > but I think C++ has many advantages over Java, any opinions

    Both have advantages over eachother, both have different fields of application. What may be an advantage of C++ in one field of application, may be a disadvantage in a different field of application.

  13. #13
    Registered User codegirl's Avatar
    Join Date
    Jun 2003
    Posts
    76
    If there's one thing that I learned from my Programming Languages class, it's that there is no "best" language -- it all depends on the application you're writing. If there was a "best" language for all types of applications, don't you think there wouldn't be very many other languages to choose from?
    My programs don't have bugs, they just develop random features.

  14. #14
    GuiltySpark343
    Guest

    Back to Basics

    Java is no more portable than any other language. In fact, it's not even executable. No, it's a text file that has to be passed to a kernel that has already been compiled for the specific processor the Java is going to be "run" on, which in turn executes the java instructions in .obj.

    Just another layer.

    Get over it.

  15. #15
    Unregd
    Guest

    Re: Back to Basics

    Originally posted by GuiltySpark343
    Java is no more portable than any other language. In fact, it's not even executable. No, it's a text file that has to be passed to a kernel that has already been compiled for the specific processor the Java is going to be "run" on, which in turn executes the java instructions in .obj.

    Just another layer.

    Get over it.
    That's the point. Joe Average doesn't know how to compile a relatively portable C++ application, but he'll have no problem going to www.dancing-baby-and-other-wastes-of-time.org to run a Java applet. It's such a good idea, in fact, that Microsoft took Sun's idea and made the .NET platform and C#.

    And I wouldn't say Java is less portable than Visual Basic 6.0 or some obscure language. There are Java virtual machines for many, many platforms.

Popular pages Recent additions subscribe to a feed