Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newbie question



James,

A lot of that 10 seconds could have been taken up loading and initializing the JVM rather than actually running your program. If you put some timing logging statements in your code, you should find that it takes much less time to execute than the full 10 seconds.

Ray



From: James Mooney <email@hidden>
Reply-To: email@hidden
To: email@hidden
Subject: Re: Newbie question
Date: Thu, 31 Oct 2002 13:34:39 -0500

Well let me give you an example and perhaps thing become clearer.

I wrote two apps......basic command line style with no gui.

One was written is Java and one is straight C (carbon api)

Each did the same thing....takes an image, calls quicktime to decode the image data, recompress the image data into a newly resized jpg.

Each was tested and the C app took about a half a second and the Java one took about 10 seconds. Mind you I did not implement QT in the Java one. I fed the app a jpg and just asked it to resize the image and store it again.

On top one would think the Java app had a lot less work to do. But do to what I assume was the sluggish running of Java Runtime. I would expect this.

My original question is directed to how Java is implemented in Cocoa. What is the end product, a compiled app, or a collection of byte code and library files that will need to be passed through a Java engine to run (hence a performance hit).

I realize Sun would probably hate Apple doing that but it would seem like a great tool if Java apps ran native code upon a recompile....ie set target to byte code or machine code........



On Thursday, October 31, 2002, at 12:47 PM, email@hidden wrote:

jim wrote:
|If you create a Cocoa app the uses Java....in the project builder, When
|the app compiles, does it compile and run as a compiled app....like C
|or does it execute hidden in the Java engine? Or something else.

When you say "a Cocoa app that uses Java", do you mean one written in Objective-C that calls Java classes, or do you mean one written in Cocoa-Java, using the com.apple.cocoa classes? If the former, the main execution will be regular compiled code. (How the Java classes are handled I don't really know.) If the latter, then pretty much the whole thing runs on the JVM (or so I understand).



|Point of question? Do Cocoa Object C apps execute faster than Java
|ones?
As with so many other "does A run faster than B?" questions, the answer is, it depends. Assuming that the apps are otherwise identical, I suspect that an Objective-C application would run somewhat faster, simply because it doesn't need the interpretation that Java bytecode does.
However, Cocoa and Java encourage different styles of writing code, and have different underlying libraries, and that means that a *well-written* program in Cocoa will do things differently from a well-written one in Java. Since the two programs would no longer be identical, asking "which one would run faster" becomes a relatively meaningless question; all you can do is to *write* one in each, and time them.
If you're asking because the answer will affect which language you choose to write your programs in, I'd say, "don't worry about it." Designing the program well--which includes using the language and libraries effectively--will have a much larger effect on the running time than which language you choose.

Glen Fisher
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Be sure to read the FAQ http://developer.apple.com/java/faq/ before posting
Do not post admin requests to the list. They will be ignored.
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Be sure to read the FAQ http://developer.apple.com/java/faq/ before posting
Do not post admin requests to the list. They will be ignored.


_________________________________________________________________
Get faster connections -- switch to MSN Internet Access! http://resourcecenter.msn.com/access/plans/default.asp
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Be sure to read the FAQ http://developer.apple.com/java/faq/ before posting
Do not post admin requests to the list. They will be ignored.


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.