Will Java ever be as efficient as C or C++?

This is a discussion on Will Java ever be as efficient as C or C++? within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Now, I know it's not *as* fast as C++, but how did they efficienize their parser so much? Java VMs ...

  1. #16
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    Now, I know it's not *as* fast as C++, but how did they efficienize their parser so much?
    Java VMs have a JIT compiler which converts java bytecode to machine code. The machine code for frequently used parts of the application are saved so that it doesn't have to be re-interpreted. So if you have a java program in which 95% of the CPU usage is done in a small loop, that loop wont be re-interpreted each iteration. In that case, the java program will run just as fast as its C/C++ equivalent.

    Write any program with a half decent looking UI in Java. It can't be done.
    Completely false. Run the program Azureus, and tell me how its UI is worse than a UI written in any other language.

  2. #17
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,220
    Quote Originally Posted by stovellp
    Write any program with a half decent looking UI in Java. It can't be done.
    The UI on Azureus looks pretty ........ing sweet in my humble opinion.

  3. #18
    ---
    Join Date
    May 2004
    Posts
    1,379
    I use Azureus and yes the UI is pretty sweet but lucky for me I have the RAM to spare because she is a bit of a hog.

  4. #19
    Bob Dole for '08 B0bDole's Avatar
    Join Date
    Sep 2004
    Posts
    618
    Azureus on linux doesnt hog anything, ???? hmmmm
    Hmm

  5. #20
    Banned nickname_changed's Avatar
    Join Date
    Feb 2003
    Location
    Australia
    Posts
    986
    You mean this Azureus? http://azureus.sourceforge.net/screenshots_v2.php

    Hmmm.... the icons are nice, from the KDE Crystal theme, it certainly looks good for an open source project. The actual widgets themselves don't look anything special though, certainly nothing like Office 2003 (and yes you can make Office 2003 looking applications pretty easily in other languages).

  6. #21
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    So making a half decent UI means it has to look like Office 2003?

    There is absolutely nothing wrong with Azureus's UI.

  7. #22
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    Quote Originally Posted by Brian
    The UI on Azureus looks pretty ........ing sweet in my humble opinion.
    A fine example of SWT hard at work

  8. #23
    Jez
    Jez is offline
    The C-er
    Join Date
    Mar 2004
    Posts
    192
    > Now, I know it's not *as* fast as C++, but how did they efficienize their parser so much?

    It may be that the Java compiler looks at your code, sees it does nothing at all a million times, and so does nothing. I know some compilers can eliminate null expressions like that.

    I would suggest try looping say 1000 000 000 times, see if it still takes no time...

    Or conversely change the code so the compiler must calculate something to return a result.

    I'm guessing, of course, because I haven't seen your code. (It wouldn't help much if I did, since I don't know Java. ( I did try learning it once, but really had trouble getting to grips with it.))

  9. #24
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,220
    If you want to argue the weaknesses of Java you should be focusing on real-time performance not GUIs.

  10. #25
    Bob Dole for '08 B0bDole's Avatar
    Join Date
    Sep 2004
    Posts
    618
    I like guis in java personally, at least from a programming POV
    Hmm

  11. #26
    Registered User
    Join Date
    Aug 2003
    Posts
    470
    Java VMs have a JIT compiler which converts java bytecode to machine code. The machine code for frequently used parts of the application are saved so that it doesn't have to be re-interpreted. So if you have a java program in which 95% of the CPU usage is done in a small loop, that loop wont be re-interpreted each iteration. In that case, the java program will run just as fast as its C/C++ equivalent.
    The Java VM could dynamically optimize the heavely used portions. For example, the Java VM could optimize a section of code to perform fast with respect to one program configuation, then reoptimize the code. I don't see any reason why a C++ compiler with priofiling information couldn't do this, but the Java VM ought to be able to outperform most C++ compilers.

  12. #27
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    With Apple changing over to a hybrid version of Intel x86, Sun is going to have to come up with a much better reason for using Java other than just cross-platform compatibility. They will either have to speed it up by dumping the VM or die. And if they do dump the VM and yet the syntax is so close to being C++ like, and C++ is still faster...and there is no longer any portability issues.......why use Java for anything but web-apps. C++ can do low-level sockets just as well if not better than Java.


    Will be interesting to see how these recent moves by Apple affect the whole issue.

    In fact it seems this very topic is popping up on forums across the net. Some say its good for Java and some say its not.

    And Apple is going to be x86 - even if they protect them somehow we all know someone is going to hack it so that their x86 can run any x86 software. Besides why would you move to an architecture that is so widely supported by tons of software only to change the chip internally so that support is gone? I think they will be true x86, but again this puts a big question in my mind now? What is the purpose of Apple computers and why do we need them if they are just x86 like every other system out there on the PC market?
    Last edited by VirtualAce; 06-09-2005 at 07:59 AM.

  13. #28
    C(++)(#)
    Join Date
    Jul 2004
    Posts
    309
    Err...correct me if I'm wrong but even if apple does use a standard x86, aren't there still going to be compatibility problems from the OS and such?
    To code is divine

  14. #29
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    Besides, why would Sun change their entire strategy because of the movement of a couple percent of the userbase? There are still plenty of people that use non-Intel cores.

  15. #30
    Bob Dole for '08 B0bDole's Avatar
    Join Date
    Sep 2004
    Posts
    618
    >Err...correct me if I'm wrong but even if apple does use a standard x86, aren't there still going to be compatibility problems from the OS and such?

    exactly, I can write ONE program, with a gui, and whatever I want in Java, and it will work on any computer with any OS as long as they have the java runtime environment... Just because Apple is switching archs doesnt mean that a windows program will work for OSX...
    Hmm

Page 2 of 3 FirstFirst 123 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, 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

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