Sloooow Java

Posted:
in macOS edited January 2014
Why is Java so incredibly terribly slow? I know Java is probably up there on the top ten worst programming languages, but at least it runs decently fast in Windows...
«1

Comments

  • Reply 1 of 32
    You know? I was just talking to a group that did a Java based PACS system.



    <a href="http://www.ultravisual.com/"; target="_blank">http://www.ultravisual.com/</a>;



    They said it runs fine on OS X. It does A LOT of image computations and networking too.



    Hummm? If Apple could make the Mac "the" Java system ....
  • Reply 2 of 32
    Java is slow because it is designed to be portable and secure. To accomplish this, Java progams are not compiled to run on any specific platform. They are compiled into an intermediate executable format called "byte code". (I'm oversimplifying here but...) Byte code is not executed directly on your processor. It is interpreted by a virtual machine. The overhead of the virtual machine, and the overhead of translating Java API calls to the operating system's native APIs is what makes Java so slow.
  • Reply 3 of 32
    [quote]Originally posted by Brian J.:

    <strong>Java is slow because it is designed to be portable and secure. To accomplish this, Java progams are not compiled to run on any specific platform. They are compiled into an intermediate executable format called "byte code". (I'm oversimplifying here but...) Byte code is not executed directly on your processor. It is interpreted by a virtual machine. The overhead of the virtual machine, and the overhead of translating Java API calls to the operating system's native APIs is what makes Java so slow.</strong><hr></blockquote>





    Duh.



    Anyway, I was wondering WHY Java was so slow on Mac OS X (and OS 9, for that matter) compared to Windows and Linux, which run Java programs at nearly the speed of native programs.
  • Reply 4 of 32
    Yea. The issue is not how slow Java is as a language buy why it's a slug on OS X.
  • Reply 5 of 32
    airslufairsluf Posts: 1,861member
  • Reply 6 of 32
    Anyone have any updated benchmarks?
  • Reply 7 of 32
    [quote]Originally posted by AirSluf:

    <strong>Java on OS X is not always slow. The OS X look and feel is pretty slow in swing, but Apple is working diligently to fix that. Some other Java functions are slow and some are faster than Linux/Windows. Mostly it will take a little longer before all the native libraries are fully optimized and the compiler/JVM optimized together to boot. I once talked to an ex-Sun JVM programmer and she said it was her third implementation when she really understood what worked really well and what didn't. The Apple engineering team will go through a similar ramp-up too.



    I do quite a bit of x-platform Java work on both Mac and Win and don't have any complaints speed-wise, but I am mostly doing networking/computational related stuff right now. This topic was hashed to death during the last month on the Apple Java-Dev mailing list and overall OS X Java speed is holding up pretty well with the exception of the graphics routines. With time and further optimization it will only get better.</strong><hr></blockquote>



    We keep hearing of Apple working on this or that, but now OS X has been out almost a full year now, with no great speed improvement, terrible memory management, slow java, and other problems.



    At least it's better than OS 9
  • Reply 8 of 32
    enderender Posts: 353member
    Terrible memory management?!? I'm wondering what you would consider good memory management...



    And while it's still not blazing fast, OS X has made good progress (especially in the pre-10.1 days).



    Anyway, I'm just learning Java, so all the stuff that I write happens immediately, but I have noticed that Java does seem noticeably slower (in the big apps) than it does on the wintel machines in the lab. But that's comparing it to different machines... how does Java in OS X compare to Java in OS 9?



    BTW-what's up with 1.4.1 JDK for OS X anyway?



    -Ender
  • Reply 9 of 32
    [quote]Originally posted by Ender:

    <strong>Terrible memory management?!? I'm wondering what you would consider good memory management...



    And while it's still not blazing fast, OS X has made good progress (especially in the pre-10.1 days).



    Anyway, I'm just learning Java, so all the stuff that I write happens immediately, but I have noticed that Java does seem noticeably slower (in the big apps) than it does on the wintel machines in the lab. But that's comparing it to different machines... how does Java in OS X compare to Java in OS 9?



    BTW-what's up with 1.4.1 JDK for OS X anyway?



    -Ender</strong><hr></blockquote>



    Dude, don't learn Java. I mean, you can do what you want, but I wouldn't recommend it. I know C/C++, which are much more efficient languages that are still easily portable. For example, I wrote a basic artificial intelligence program in C on my Mac, ported it to my PC in about 1 minute, then ported it to Linux on my K'NEX Cube in about 30 seconds. Java? Uh...I'd still be working on it. <img src="graemlins/lol.gif" border="0" alt="[Laughing]" />
  • Reply 10 of 32
    [quote]Originally posted by Ender:

    <strong>Terrible memory management?!? I'm wondering what you would consider good memory management...



    And while it's still not blazing fast, OS X has made good progress (especially in the pre-10.1 days).</strong><hr></blockquote>



    The JVM has it's own memory managment. You don't have to worry about memory leaks because it keeps track of references to objects. When an object is no long refered to then it's freed.
  • Reply 11 of 32
    [quote]Originally posted by Scott H.:

    <strong>Anyone have any updated benchmarks?</strong><hr></blockquote>

    I made this some time back (but on 10.1.2) when I was comparing Java on OSX to Java on other PCs. I don't have the scores for the PCs I had found before, but I recall that an Athalon 1600 did something like six to eight times what my Dual 500 G4 did on some tests.







    So, yes, Java on OSX SUCKS. :o



    [ 02-15-2002: Message edited by: starfleetX ]</p>
  • Reply 12 of 32
    airslufairsluf Posts: 1,861member
  • Reply 13 of 32
    applenutapplenut Posts: 5,768member
    [quote]Originally posted by kHack:

    <strong>



    We keep hearing of Apple working on this or that, but now OS X has been out almost a full year now, with no great speed improvement, terrible memory management, slow java, and other problems.



    At least it's better than OS 9 </strong><hr></blockquote>



    no great speed improvement? uh.. 10.1

    terrible memory management? it's only 10X better than OS 9s. what exactly is terrible about it?

    slow java? don't think its much to worry about as Sun is fully behind Apple with their java implementation



    [quote]Dude, don't learn Java. I mean, you can do what you want, but I wouldn't recommend it. I know C/C++, which are much more efficient languages that are still easily portable.<hr></blockquote>



    after viewing your website I would say you should have spent less time learning C/C++ and more learning how to author a web page
  • Reply 14 of 32
    THE COMMENT ABOUT MEMORY MANAGEMENT IS ABOUT THE JAVA VIRTUAL MACHINE WHICH HAS IT'S OWN MEMORY MANAGEMENT. IT'S NOT A OS 9 VS OS X ISSUE.



    Sorry. I had to get that out again. Java manages it's own memory. The JVM has a memory manager. If it's slow then Java is slow.
  • Reply 15 of 32
    Well, if anyone has a better Java benchmark, please step up to the plate and let us try it.



    As for the CaffeineMark I mentioned earlier, I found the other post I made. The other computer tested was a Athalon 1400 MHz running Windows 2000 Professional. Here's the link: <a href="http://www.excelsior-usa.com/jetbenchstd.html"; target="_blank">Excelsior JET Standard Microbenchmarks</a>.



    Let's compare, shall we?



    From the Athalon 1400:

    Sun Java HotSpot Client VM 1.3.1: 11,119

    IBM JRE 1.3 with JIT enabled: 23,427

    Excelsior JET 2.0 Professional: 24,355



    From my Dual 500 G4 Mac:

    Apple's implementation: 3,597



    Again, please! Give me a better benchmark to run if you have one! I'd love to be proven wrong here.
  • Reply 16 of 32
    [quote]Originally posted by Brian J.:

    <strong>It is interpreted by a virtual machine. The overhead of the virtual machine, and the overhead of translating Java API calls to the operating system's native APIs is what makes Java so slow.</strong><hr></blockquote>



    I remember somebody stating that the JVM, being a stack-machine, doesn't lend itself very well for execution on RISC processors because it can't make efficient use of the large amount of registers available. The x86 architecture, on the other hand, only has relatively few registers in the first place, and is more efficient in stack operations.

    I'm not quite sure this is technically completely accurate, or whether it still applies today, but it might account for some of the speed differences seen between Java on Macs and PCs.



    Bye,

    RazzFazz
  • Reply 17 of 32
    Why would Sun, a company that uses RISC CPUs, make a byte code language that does not run well on RISC?



    Every time someone posts a benchmark here, and in other threads, they are told that it's an old benchmark and does mean much. But it's the same freaking code running on different systems. OS X fails so badly that there can be little doubt that Java is slow on OS X.



    [ 02-16-2002: Message edited by: Scott H. ]</p>
  • Reply 18 of 32
    airslufairsluf Posts: 1,861member
  • Reply 19 of 32
    [quote]Originally posted by Scott H.:

    <strong>Why would Sun, a company that uses RISC CPUs, make a byte code language that does not run well on RISC?

    </strong><hr></blockquote>



    Cross-platform portability.

    Every architecture supports a stack of sorts, but hardly any two share the same register set.



    Bye,

    RazzFazz
  • Reply 20 of 32
    In response to applenut:



    On my 500MHz iBook, 256MB of RAM, I noticed very very little or no speed improvement when I upgraded to OS X.1 (which should be Mac OS X .1 ) Also, just because you can't handle the fact that Java programs run slower on Macs than PCs, doesn't mean you have to cast reproach on my web site, which everyone else thinks is kewl (people say, "That's not your site. No way, couldn't be. Really? Wow!"), and is very elegant and simple. I could build a very complex page, but on Fresh Apple I was aiming for simplicity. And also, I've known how to write HTML code since like 1994, and am very experienced at it. What do you use? Dreamweaver or some sh** like that? Those didn't even exist in 1994. Guess what I used? TeachText. Yes, that's a fact. And I made cool web pages with it.



    *deep breath*



    And another thing: If you want to go around animadverting people for no reason, AppleInsider Forums isn't the place to do it.
Sign In or Register to comment.