C++ vs Java

This is a discussion on C++ vs Java within the C++ Programming forums, part of the General Programming Boards category; Why C++ is faster than Java? How java can be made as fast as C++?...

  1. #1
    Registered User Moni's Avatar
    Join Date
    Oct 2002
    Location
    Dhaka, Bangladesh.
    Posts
    104

    C++ vs Java

    Why C++ is faster than Java?
    How java can be made as fast as C++?
    We all are the components of a huge program...... the programmer is always debugging us with His debugger.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,691
    Java is an interpreted language. In other words, Java doesn't compile into machine code. It is compiled into a platform independent set of byte codes, that are executed by the Java virtual machine.
    There are Java compilers that can compile Java into machine code (thus losing it's platform independence). These compilers still have to compile in a garbage collector - which in some instances, can still make Java slower than C++.

  3. #3
    Registered User
    Join Date
    Jan 2003
    Posts
    648
    Java with the help of a VM with a JIT compiler can reach speeds of up to 15% slower than C++, which is really good considering all its language features like GC and full OOP.

  4. #4
    Registered User Moni's Avatar
    Join Date
    Oct 2002
    Location
    Dhaka, Bangladesh.
    Posts
    104
    But what they are trying to make it as fast as C++ ???

  5. #5
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    >But what they are trying to make it as fast as C++ ???

    Most people want a language that has very fast execution...
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  6. #6
    Registered User zahid's Avatar
    Join Date
    Aug 2001
    Posts
    532
    1.Performance Evaluation: Java vs C++
    2.Comparative Performance Analysis of Client-Server Applications developed in Java and C++

    3.An empirical comparison of C, C++, Java, Perl, Python

    I guess above resouces will help you to resolve ... You will find the third one as the best for analysis. One more thing, I guess this thread should be in GD.

    4.Optimizing Java for Speed


    Welcome to cboard !!! Happy to see you from Bangladesh, rare to find Bangladeshies interested in C/C++ .
    Last edited by zahid; 03-17-2003 at 07:13 AM.
    [ Never code before desk work ]
    -------------------------------------:-->
    A man who fears Nothing is the man who Loves Nothing
    If you Love Nothing, what joy is there in your life.
    =------------------------------------------------------= - I may be wrong.

  7. #7
    Registered User Moni's Avatar
    Join Date
    Oct 2002
    Location
    Dhaka, Bangladesh.
    Posts
    104
    Salam Zahid Bhai!
    Actually I am C/C++ programmer and know little Java! I am a newcomer to java and I am finding it slower than the C/C++ that's why I first thought "Is java going to be faster or not!"

    But Many many thanks for your such good links!

    If I go to Dhaka I will meet you can you give me your address
    Last edited by Moni; 03-19-2003 at 01:36 PM.
    We all are the components of a huge program...... the programmer is always debugging us with His debugger.

  8. #8
    Bios Raider biosninja's Avatar
    Join Date
    Jul 2002
    Location
    South Africa
    Posts
    765
    _
    Attached Images Attached Images  
    The knack of flying is learning to throw yourself at the ground and miss.

  9. #9
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    bios: i have no clue what your thing a ma bob was for.

    and full OOP.
    Actually Java doesn't support full OOP, it doesn't support multi level inheritance, and that's all I know about Java.


    i.e you can't do:

    class Waste {
    }

    class Poop : public Waste {
    }

    clas Diarrhea : public Poop{
    }

  10. #10
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,691
    Multiple inheritence is about as good a practice as using goto's - you should only use it when it really, really makes sense. And even then it can be done other ways.

    Notice also that the "goto" keyword has since been removed from Java.

    gg

  11. #11
    Bios Raider biosninja's Avatar
    Join Date
    Jul 2002
    Location
    South Africa
    Posts
    765
    bios: i have no clue what your thing a ma bob was for
    The stupidity of this thread. Has been done before. This is a C/C++ board not java...making this thread pointless!

    Java is a multi platform language which makes it slower. And if I'm correct... it doesn't have pointers (correct me if i'm wrong). So...whats the use of Java? other than writing applets and other web stuff.

    Multiple inheritence is about as good a practice as using goto's - you should only use it when it really, really makes sense. And even then it can be done other ways
    Multiple inheritence is quite usefull whem used correctly and in the right places
    The knack of flying is learning to throw yourself at the ground and miss.

  12. #12
    ! |-| /-\ +3 1337 Yawgmoth's Avatar
    Join Date
    Dec 2002
    Posts
    187
    Originally posted by biosninja



    Multiple inheritence is quite usefull whem used correctly and in the right places
    And so are gotos!

    Seriously though, I think C++ is better than JAVA cuz it has multiple inheritance, it's faster, and has gotos.


    Java has its place on the web (like clones of pong and space invaders), but for 90% of other stuff, C++ is better.
    L33t sp3@k sux0rz (uZ it t@k3s 10 m1|\|ut3s 2 tr@nzl@te 1 \/\/0rd & th3n j00 h@\/3 2 g3t p@$t d@ m1zpelli|\|gz, @tr0(i0u$ gr@mm@r @|\|d 1n(0/\/\pr3#3|\|$1bl3 $l@|\|g. 1t p\/\/33nz j00!!

    Speling is my faverit sujekt

    I am a signature virus. Add me to your signature so that I may multiply.

  13. #13
    Bios Raider biosninja's Avatar
    Join Date
    Jul 2002
    Location
    South Africa
    Posts
    765
    And so are gotos
    gotos should only be used when there is absolutely NO way out
    The knack of flying is learning to throw yourself at the ground and miss.

  14. #14
    booyakasha
    Join Date
    Nov 2002
    Posts
    208

    about the gotos

    Java does have a limited form of gotos
    (but not using the keyword "goto"

    here is some Java code

    Code:
    outerLoop: while(true){
        innerLoop: for(int i = 0 ; i  < MAX ; i++){
             foo += 45;
             test: if( foo % 88 == 3 ){
                    break outerLoop;
             } else if( q == r ){
                    if( s == w ) break test;
             } else {
                    continue innerLoop;
             }
        }
    }
    just a made up example, but it does show that Java allows for a large amount of gotos functionality.

  15. #15
    Registered User zahid's Avatar
    Join Date
    Aug 2001
    Posts
    532
    Originally posted by Moni
    If I go to Dhaka I will meet you can you give me your address
    You are always welcome.

    I sent you a pm, I guess you have already got it.
    Last edited by zahid; 03-22-2003 at 11:07 PM.
    [ Never code before desk work ]
    -------------------------------------:-->
    A man who fears Nothing is the man who Loves Nothing
    If you Love Nothing, what joy is there in your life.
    =------------------------------------------------------= - I may be wrong.

Page 1 of 2 12 LastLast
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, 03: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, 11: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, 10:07 PM
  4. Java woes
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 07-06-2003, 01: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, 06:12 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21