Why is java so slow in OSX?

2»

Comments

  • Reply 21 of 38
    dfilerdfiler Posts: 3,420member
    [quote]Originally posted by Macasaurus:

    <strong>Java is a good language because it is not platform dependant

    ...

    </strong><hr></blockquote>



    Very few languages are 'platform dependant'. Instead, it is usually the upper level APIs, used for hardware abstraction, which are platform dependent. This includes graphics/windowing systems, disk access, etc.



    The concept of Java has always been quite good, in theory. However, to create polished Java apps or applets, it is usually necessary to include platform specific code in many places. Also, there are many other development environments and API kits which allow code to be about as platform-agnostic as java.



    I've done a considerable amount of work with Java and it?s always been necessary to work around platform specific bugs. Thus, while the java's API is supposedly platform independent, in the real world, it isn't. This is part of the reason why some Java code runs extremely slowly on OS X. While buggy or un-optimized portions of virtual machines can be avoided, developers must take extra care to do so for each platform.



    [ 09-20-2002: Message edited by: dfiler ]</p>
  • Reply 22 of 38
    shetlineshetline Posts: 4,695member
    [quote]Originally posted by Aquatik:

    <strong>Why DO people use Java? Seriously? It's slow and unwieldy, it looks to me like it "sucks" sure enough. The only reason I am reluctant to diss it is because it's anti-M$...</strong><hr></blockquote>



    First of all, I think the most important question here is "Why is Java so slow on the Mac?" before arguing about the merits of the language. Because whether you like the language or not, it still matters to many people how well Java runs on a particular platform, and Java is particularly slow on the Mac, more so with OS X, even when comparing to Wintel systems at the same MHz speed -- not to mention in comparison to Java running on a +2 GHz Wintel hardware.



    Apple's Java has a number of performance problems that should be easy to remedy, if Apple has the will do so, that would make Java run much better on OS X. Their Java is still very usable, however, for many uses right now.



    I worked in C++ for nearly seven years. For the last four years or so, I've worked almost exclusively in Java. It's certainly possible to make good, fast, responsive software in Java. It's certainly much easier to produce stable code faster in a language with automatic garbage collection and safety from accidental memory corruption. The cross-platform aspects of Java, while not perfect, are still very helpful for software developers.



    Where Java hasn't had much success is in being used for "shrink-wrapped", off-the-shelf commercial software. It's cross-platform GUI will always be a little short of the slickest platform-dependant GUIs out there. (You can write in Java, but tie yourself to OS X, and get nice GUI result with Cocoa from what I hear -- I haven't personally tried this.) Java's not going to be fast enough on any platform, however, for the latest and greatest I-want-1000-frames-per-second-three-D-holographic-imagery with 5.1-channel surround-sound games.



    Where Java has been very successful is in server side applications, in code running behind the scenes for web sites and transaction processing. A faster Java for the Mac will be a great aid to OS X's use as a server platform.



    [ 09-20-2002: Message edited by: shetline ]</p>
  • Reply 23 of 38
    Well, my CS professor may have answered one of my questions, which was "what is a misaligned double?"



    Here is his response:



    "Computer CPUs tend to use an extra cycle when loading/storing a 4-byte data value whose address is not divisible by 4. The same may be true for loading/storing an 8-byte data value whose address is not

    divisible by 8. I imagine that this is what the posters were thinking of when they refered to a 'misaligned double'.



    The amount of penalty for 'misalignment' can be very different between processors."



    So, I guess that's what a misaligned double is. Any ideas on how to fix this aside from waiting for Apple to fix it?
  • Reply 24 of 38
    quote:

    ------------------------------------------------------------------------

    Originally posted by gmon:



    Umm, he means that the same source code can be compiled for different platforms. Obviously you have never strayed away from a GUI or you would be familiar with this and the following sequence of commands:



    ./configure

    make

    make install



    which is usually all it takes to compile gnu or other open source software on any platform (unix that is - OSX included).

    ------------------------------------------------------------------------



    I've tried SOOOO many times to compile my own apps under Mac OS X using the terminal. Each time I try I'm missing the essential parts it needs to compile like amake etc. If you check out my post entitled "Direct Connect for Mac OS X: Second post you'll see all my attempts of trying to compile apps from their sources under Mac OS X. After you guys view that, can you please tell where I can find the nessacary parts and how I can install them? I've tried to use Apple's Developement Tools April 2002 but it doesnt seem to add the missing components. I've even downloaded some "BSD tools" from various sites but its havent figured out how to install them into my system. Typing ./configure didnt do the trick. So if anyone who can help me with this I'd very greatful.



    PS. Is there an RPM component for OS X? There are plenty of precompiled apps that I'd like to try.
  • Reply 25 of 38
    -_- come on ppl.... theres gotta be someone here that can help me....
  • Reply 26 of 38
    All i did was install the dev tools what does it say you are missing? Is it different every time?
  • Reply 27 of 38
    check out my other post called !<a href="http://forums.appleinsider.com/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=3&t=001146"; target="_blank">Direct Connect for Mac OS X Second Post</a>. Search for it if you have to. everything is there..... g2g gotta wake up early tomorrow, Tuesday... Its 11:07 PM here.,..





    Tootles..!!



    [ 09-23-2002: Message edited by: Proud iBook Owner 2k2 ]</p>
  • Reply 28 of 38
    airslufairsluf Posts: 1,861member
  • Reply 29 of 38
    [quote]Originally posted by AirSluf:

    <strong>



    Generally untrue. Compiled java is pure JVM bytecode, the compiled code is identical for EVERY platform, app or applet.



    You can run into problems if you use extensions to Java that aren't part of the prescribed default install. Then your bytecode might expect native libraries to be present that haven't been installed. But it's still the same compiled bytecode.</strong><hr></blockquote>



    You know what? I know that. I have no idea what I was thinking when I made that post.
  • Reply 30 of 38
    I converted my applet from awt to swing and the speed wasn't noticeably faster.



    I believe the math functions (Math.sin(), Math.cos(), etc) or fillOval are the slow parts of my program.



    Or perhaps it's just the high amount of math involving doubles, but I don't think that is the problem since my teacher's <a href="http://mathlab.nmu.edu/~bpeterso/CS446/RayTrace-JDK/PanelApplet.html"; target="_blank">ray-tracing applet</a> runs relatiely fast on my PowerBook. In fact, my 400Mhz G3 in 10.2.1 runs it almost twice as fast as a 450Mhz G4 in OS 9.
  • Reply 31 of 38
    123123 Posts: 278member
    [quote]Originally posted by rogue27:

    <strong>

    You know what? I know that. I have no idea what I was thinking when I made that post.</strong><hr></blockquote>



    You were probably thinking of a native java compiler (http://gcc.gnu.org/java/).
  • Reply 32 of 38
    [quote]Originally posted by rogue27:

    <strong>I converted my applet from awt to swing and the speed wasn't noticeably faster.</strong><hr></blockquote>



    Swing isn't really fast. As it is platform independent, it has to do all the drawing by itself.



    An interesting alternative for writing Java applications with 'original' platform widgets is SWT. It is included in the eclipse workbench (www.eclipse.org). One of the best java IDEs - and free... The first development builds for MacOS X are now available.
  • Reply 33 of 38
    123123 Posts: 278member
    [quote]Originally posted by rogue27:

    <strong>I converted my applet from awt to swing and the speed wasn't noticeably faster.

    </strong><hr></blockquote>



    Swing has always been slower than AWT because it's implemented entirely in Java. And Java IS dog slow, especially drawing.





    [quote]Originally posted by rogue27:

    <strong>I believe the math functions (Math.sin(), Math.cos(), etc) or fillOval are the slow parts of my program.</strong><hr></blockquote>



    You can profile (eg. <a href="http://www.codework.com/optimize/product.html)" target="_blank">http://www.codework.com/optimize/product.html)</a> your program to find out what exactly slows it down. Depending on how you use sin() and cos() and the maximum error permitted, you might want to build a lookup table or use approximation methods to speed up your code. Here's a collection of sine optimization techniques: <a href="http://www.interstice.com/~sdattalo/technical/theory/sinewave.html"; target="_blank">http://www.interstice.com/~sdattalo/technical/theory/sinewave.html</a>;



    123
  • Reply 34 of 38
    [quote] PS. Is there an RPM component for OS X? There are plenty of precompiled apps that I'd like to try.<hr></blockquote>



    Ever heard of Fink? It is similar in nature to RPM managers. It is a big help getting GNU software onto OS X. Check it out.



    -Aslan
  • Reply 35 of 38
    [quote]Originally posted by Aslan:

    <strong>Ever heard of Fink? It is similar in nature to RPM managers. It is a big help getting GNU software onto OS X. Check it out.



    -Aslan</strong><hr></blockquote>



    and, in case s/he/they's not heard of it: <a href="http://fink.sf.net"; target="_blank">http://fink.sf.net</a>; . it doesn't use rpm, but packages more similar to debian. <a href="http://sf.net"; target="_blank">http://sf.net</a>; is great for all kinds of really free programs. i dont mean juarez, i mean programs made by the developer(s) with the intent of giving them away (freedom has finally arrived).



    compiling programs with `./configure && make && sudo make install` may be difficult, but if ur supporting a bunch of people, then you have a techie build it, and install it for them. `real` people have trouble using regular gui installers, so of course they'll botch a cli installer.
  • Reply 36 of 38
    Thanks for the link to the sin and cos optimization. I might have to see if I can do that, but since my code is using radians, it might be harder to do.
  • Reply 37 of 38
    I'm running Netbeans 3.4 under 10.2.1 on my 867Mhz Quicksilver and there is NOTHING slow about Java on this machine.



    I regularly use a 1.5GHz Dell machine running W2K and JDK 1.4 and the speeds are comparable.



    I would be nice to know where 1.4 is though. Not being able to use some of the new stuff in 1.4 is beginning to get annoying.

  • Reply 38 of 38
    amorphamorph Posts: 7,112member
    Apple is apparently skipping right over 1.4 and going to 1.4.1.



    When Jaguar was still under development, someone asked on the Omni-dev list about Java 1.4, and an Apple employee replied that their customers had asked for a more robust implementation of 1.3 first. So that's what shipped. But they have been working concurrently on 1.4.
Sign In or Register to comment.