Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Cocoa: Java v. ObjectC Speed Issues

Cocoa: Java v. ObjectC Speed Issues
Thread Tools
Justin W. Williams
Mac Elite
Join Date: Jul 2001
Location: Evansville, IN
Status: Offline
Reply With Quote
Oct 8, 2001, 07:27 PM
 
I am reading into Cocoa programming as a new hobby. According to documentation, it can be used with both ObjectiveC and Java. Anyone have opinions on which is better? I know that Java is slow, but how noticeable is it?
Justin Williams
Chicks Really Dig Me
AIM - iTikki [NEW AND IMPROVED!]
http://www.tikkirulz.com
     
gralem
Dedicated MacNNer
Join Date: Nov 2000
Location: Malaysia
Status: Offline
Reply With Quote
Oct 8, 2001, 09:48 PM
 
(sorry for yelling)

** I DO NOT WANT TO SEE A SINGLE REPLY TO THIS MESSAGE!! **

This is either trolling or true innocence. If you are innocent, please do a search for both words "objective" and "java" in this message board. This has been commented ad nauseum in the past. Here is a summary of past meaningful discussions on the subject:

Everyone either loves only Objective-C, Java, or both. And if you don't look at it their way, you are a dork/idiot/worse.

Both are available to you in Cocoa. If you cannot find the info you want with a forum search, perhaps a visit to a local bookstore and flipping through a Cocoa programming book would give you a reasonable answer.

---gralem

[ 10-08-2001: Message edited by: gralem ]
     
Justin W. Williams  (op)
Mac Elite
Join Date: Jul 2001
Location: Evansville, IN
Status: Offline
Reply With Quote
Oct 8, 2001, 10:03 PM
 
I did. Nothing came up. That is why i Posted the message. Do a search yourself and see the results.


[QUOTE]Originally posted by gralem:
[QB](sorry for yelling)

** I DO NOT WANT TO SEE A SINGLE REPLY TO THIS MESSAGE!! **

This is either trolling or true innocence. If you are innocent, please do a search for both words "objective" and "java" in this message board. This has been commented ad nauseum in the past. Here is a summary of past meaningful discussions on the subject:
Justin Williams
Chicks Really Dig Me
AIM - iTikki [NEW AND IMPROVED!]
http://www.tikkirulz.com
     
Rick1138
Forum Regular
Join Date: Dec 2000
Location: Rehoboth Beach,DE USA
Status: Offline
Reply With Quote
Oct 8, 2001, 11:36 PM
 
Actually,I think it is a god question.Does anyone know of any benchmarks comparing the speed of Objective C to Java in Cocoa.Everyone knows that Java is slower,but what exactly is the difference.
     
Angus_D
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Oct 9, 2001, 02:38 AM
 
Have a look and compare the Objective-C and Java versions of Sketch, which is included with the Developer Tools. There was a page describing some other reasons not to use Java. For one, there is less documentation on the Java side. Also, Obj-C is not much more difficult to learn than Java, and I see no downside to learning it, so why not just use Obj-C?
     
sundip01
Fresh-Faced Recruit
Join Date: Oct 2000
Location: Ann Arbor, MI
Status: Offline
Reply With Quote
Oct 9, 2001, 02:55 AM
 
I developed in Java and Objective C this past summer...Right off the bat, I can't say whether one is better than the other. It REALLY is a matter of personal preference.

There are pro's and con's to each language. The best way to choose is to pick the one you are most familiar with. If you know C, then you're probably about an hour away from knowing Objective C.

If you're a Java programmer, for a quick development path, this would probably be the way to go.

Some of my opinions:
- I like managing memory and often get disgruntled when it is done for me like in Java.

- On a nominal machine, a lot of Java threads can kill the VM very easily.

- The documentation is definitely sketchy. I actually learned Objective C by weeding through the docs and I was more or less forced to learn it to understand some of the advance topics that the Java docs were lacking.

- Lately it seems as if everyone has been obsessed with the number of bounces it takes for an app to start. Using Java will more than likely lead to more bounces on startup.

- On the other hand...I knew Java going in, so it was definitely easier to go that route in the beginning.

The most important part of all this is to not get bogged down in details like programming languages. Before you do any Cocoa programming, sit down with Learning Cocoa from O'Reilly, and learn the Cocoa paradigms and methodologies. Those are the most important ideas when programming in Cocoa.

hope that helps
-Sandeep
     
gralem
Dedicated MacNNer
Join Date: Nov 2000
Location: Malaysia
Status: Offline
Reply With Quote
Oct 9, 2001, 01:34 PM
 
Originally posted by Justin W. Williams:
<STRONG>I did. Nothing came up. That is why i Posted the message. Do a search yourself and see the results.

</STRONG>
(APOLOGY...sorry, I guess older stuff was deleted during the forums upgrade...and the responses are pretty good so far).

There are lots of pro's and con's for each language. I think it all comes down to your target audience. If you want to only develop for Mac OS X, using Objective-C is a fine way to acheive it. If you know you want cross-platform capabilities, using Java is a fine way to acheive it.

Having said that, if you only want to develop for Mac OS X, Apple allows you to do something special. It is called a Java-based Cocoa application. This means you use Java for the logic, Cocoa (direct into Aqua) for the gui. No need for "slow" java stuff like swing. This results in quite fast applications, usually with some highly portable logic.

That is why I always lean towards Java. You can use it anywhere. I, too, would like to see some Java/ObjC benchmarks, if someone has any. Another place to start is Apple's developer area (http://developer.apple.com/techpubs). If you dig deeper, you will find examples of ObjC and Java apps for OSX. Sign up for a free ADC membership for additional info right from that page. Also check out http://www.stepwise.com/, perhaps the best online resource for OSX/Cocoa development.

---gralem
     
nonhuman
Posting Junkie
Join Date: Jun 2001
Location: Baltimore, MD
Status: Offline
Reply With Quote
Oct 9, 2001, 02:00 PM
 
Originally posted by gralem:
<STRONG>Having said that, if you only want to develop for Mac OS X, Apple allows you to do something special. It is called a Java-based Cocoa application. This means you use Java for the logic, Cocoa (direct into Aqua) for the gui. No need for "slow" java stuff like swing. This results in quite fast applications, usually with some highly portable logic.</STRONG>
This is exactly what I'm looking for! I'm just starting to develop in Java, and until now have been using AWT for my interface. It certainly has the advantage of being cross-platform, and I need to use it for my CS classes, but it's so ...not Mac. Where can I get more info on this? Should I just check the ADC page and Stepwise, or are there some other sources that would be worth looking into?
     
Rickster
Mac Elite
Join Date: Feb 2001
Location: Vancouver, WA
Status: Offline
Reply With Quote
Oct 9, 2001, 11:53 PM
 
Apple has said that the new Jav a VM in 10.0.x and newer should make for very little performance difference between Java and ObjC Cocoa apps. While your Java-based Cocoa program is running, it'll be slower than an equivalent ObjC program, but only by a negligible amount. Where you're far more likely to notice a performance difference is in startup time, since a Java Cocoa app will have to load the Java VM before it can get going.

So, performance shouldn't really matter in your choice. What does matter is your familiarity with the languages, and the goals of the project you're working on.

Personally, I think Java is good for developers who are new to Cocoa. Many such developers' experience with OO design comes from Java, JavaScript, C++, or another language with similar syntax; programming for Cocoa in Java lets you get used to its design patterns while still using a syntax you're familiar with. Then later you can move on to ObjC without the confusion of learning both the syntax and the design patterns at the same time. (Many a C++ programmer has tried to learn Cocoa and become quite frustrated as they attempt to use C++ concepts in a completely different type of dynamic OO system.) On the other hand, if you have little or no OO programming experience, or your experience comes from the likes of Smalltalk, start with ObjC.

However, I also think Java's uses as a Cocoa programming language are limited. In a more complex application, it's quite likely you're going to want to have some plain-old-C code. Maybe it's a 3D renderer, or some other chuck of your application where performance optimization is far more important than OO design. Or maybe it's some third-party code that you need to integrate, like a PNG parser or JavaScript runtime. Or maybe you're needing to use features of Mac OS X that aren't accessible through ObjC/Java API, like CoreGraphics or the Security Framework. It's a lot easier to use plain-C in Objective-C (since ObjC is just a superset of C) than it is to use JNI or JDirect or whatever to call C APIs from Java. Now that the ObjC++ compiler is back, it's also really easy to interface ObjC Cocoa code to C++, which is useful if you have some cross-platform backend logic that you'd like to put a Mac UI on.
Rick Roe
icons.cx | weblog
     
Kickaha
Forum Regular
Join Date: May 2001
Status: Offline
Reply With Quote
Oct 10, 2001, 02:44 AM
 
Rick, that last bit was the point I was going to make. It was earlier stated that you could use Java for the logic... now you can use C++ for it as well, and get even quicker backend logic.

Cocoa really is turning out to be 'use whatever you like, or are comfortable with, or makes sense for your business model'... quite possibly the only API that does so.

For the record, I come from a solid C++ background, so I tend towards the Obj-C++ solution (due to huge amounts of legacy code at the moment), but the Java/Cocoa approach also makes sense to me - I'm not a fan of the Java libs, but the language itself isn't too shabby. Mating the Java lang with the Cocoa libraries isn't a bad choice by any means.

[ 10-10-2001: Message edited by: Kickaha ]
     
proceedNeXT
Forum Regular
Join Date: Aug 2000
Location: the chair in front of my Mac
Status: Offline
Reply With Quote
Oct 10, 2001, 03:48 AM
 
I, personally, like ObjC better.
     
Kickaha
Forum Regular
Join Date: May 2001
Status: Offline
Reply With Quote
Oct 10, 2001, 04:33 AM
 
Oh, so do I, between the three options, but given the large amount of C++ code I have laying about, Obj-C++ makes a better choice for my needs at this time. I hope to move that more towards full Obj-C as time goes on, but for now this is my situation.

The beauty of Cocoa is that I have the *choice* of using a mix of three distinct languages with one well crafted API to meet my needs and likes.
     
Raman
Mac Elite
Join Date: Mar 2001
Status: Offline
Reply With Quote
Oct 29, 2001, 10:31 PM
 
Originally posted by Angus_D:
<STRONG> Also, Obj-C is not much more difficult to learn than Java, and I see no downside to learning it, so why not just use Obj-C?</STRONG>
Because they might want to be able to write something for more than 1 platform.
     
Raman
Mac Elite
Join Date: Mar 2001
Status: Offline
Reply With Quote
Oct 29, 2001, 10:52 PM
 
Originally posted by Angus_D:
<STRONG> Also, Obj-C is not much more difficult to learn than Java, and I see no downside to learning it, so why not just use Obj-C?</STRONG>
Because they might want to be able to write something for more than 1 platform.
     
sadie
Senior User
Join Date: Feb 2001
Location: Rochester, uk
Status: Offline
Reply With Quote
Oct 30, 2001, 05:31 AM
 
Since I started doing serious Java and Swing development a few months ago, I've learned that Java really isn't that slow. When you forget about GUIs and just use straight logic, it's only a little slower than ObjC. The comparison with straight C wouldn't be fair, because Java has a large OO runtime to support - just like ObjC has.

However, there are two things which slow Java down: strings and bitwork. And you know what needs to use bitwork heavily? Graphics, especially Swing.

All of Cocoa's bitwork is done by Quartz - you just issue the commands in Java, and it takes care of them. So my guess is that the difference is minor.

There is, however, one other possibility people are forgetting: at some point, Apple could move to a different chipset - either G5/G6/G7 or something from AMD or someone else. Java, even with Cocoa, would happily move over without a glitch. Objective-C would need at least a recompile, and possibly other changes as well.
All words are lies. Including these ones.
     
Millennium
Clinically Insane
Join Date: Nov 1999
Status: Offline
Reply With Quote
Oct 30, 2001, 11:07 AM
 
Java is probably a bit slower than Objective-C on OSX, which is itself a bit slower than C++/Carbon. However, the differences in speed between these languages are now so slight that they aren't likely to be an issue unless you're doing massive amounts of CPU-intensive work. So speed isn't really something to worry about.

Java has a big advantage in that you get the Java class libraries. Don't underestimate these; they can be very useful indeed. It's also the officially-sanctioned language for Cocoa by Apple, despite appearances. Plus, if Apple does decide to switch platforms at some point, you probably won't even need to recompile the app (much like a fat binary from the old 68K/PPC days, but not as bloated size-wise).

Objective-C, on the other hand, is a much cleaner language to learn and read, once you get used to the message-passing syntax. It also has more documentation, which I find ironic since Apple Wants You To Use Java(tm).

In the end, it comes down to a matter of personal taste. I use Objective-C, but part of that is because I don't actually know Java (though I do want to learn it).

And hey, Real Men Code Cocoa in AppleScript
You are in Soviet Russia. It is dark. Grue is likely to be eaten by YOU!
     
Angus_D
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Oct 30, 2001, 04:09 PM
 
Originally posted by Raman:
<STRONG>Because they might want to be able to write something for more than 1 platform.</STRONG>
Cocoa/ObjC is more cross-platform than Cocoa/Java because of GNUstep.
     
Rickster
Mac Elite
Join Date: Feb 2001
Location: Vancouver, WA
Status: Offline
Reply With Quote
Oct 30, 2001, 05:43 PM
 
...since Apple Wants You To Use Java(tm)
I wouldn't be so sure about that. At WWDC last May, all the discussions of Cocoa were primarily ObjC, with "oh, and you can also use Java" being almost an afterthought.
Rick Roe
icons.cx | weblog
     
sadie
Senior User
Join Date: Feb 2001
Location: Rochester, uk
Status: Offline
Reply With Quote
Oct 31, 2001, 11:44 AM
 
Millennium was of the opinion:
<STRONG>And hey, Real Men Code Cocoa in AppleScript </STRONG>
Isn't there a project to make Cocoa available in Perl? I remember reading about it somewhere...

Failing that, how about LISP?
All words are lies. Including these ones.
     
Millennium
Clinically Insane
Join Date: Nov 1999
Status: Offline
Reply With Quote
Oct 31, 2001, 12:06 PM
 
I'm not entirely certain on that.

If Apple has played its cards right, then the Cocoa support will not be for AppleScript, per se, but for OSA (AppleScript, being an OSA language, thus gets it as a side effect). The reason I say this is that any scritping language can have OSA support; it's already been done for JavaScript, and others will likely get support in the future. That would make adding Cocoa support to languages much easier.
You are in Soviet Russia. It is dark. Grue is likely to be eaten by YOU!
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 08:32 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,