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 > difference of obj c to java?

difference of obj c to java?
Thread Tools
Fresh-Faced Recruit
Join Date: Feb 2001
Location: Amstelveen, Netherlands
Status: Offline
Reply With Quote
Mar 1, 2001, 03:57 PM
 
Hello,

Can someone tell me the differences (advantages, disadvantages) of making applications with project builder in objective C compared to java?

Because I want to create an application and have as little knowledge of Obj C as of Java.
But I am a little undecided in which language to program.

Thanks
     
Senior User
Join Date: Feb 2001
Location: Rochester, uk
Status: Offline
Reply With Quote
Mar 1, 2001, 04:35 PM
 
Java suffers from being too slow, because it's emulated (or interpreted, or whatever they call it today). Any given program is likely to be three-five times slower in Java than in any native language.

Objective-C has most of the features of Java, but compiles directly to native code the same way that uglier languages like C++ do.

Java is technically cross-platform, but to use this you need to use the Swing libraries, which slow it down even more because they attempt to recreate all the widgets that native libraries like Cocoa provide already. It's the same reason Netscape 6 sucks.

In the long term, knowing any variant of C will make you a lot more employable. Most of the real programming that goes on is in *some* C-derived language, so starting with Objective-C is a smart move.
All words are lies. Including these ones.
     
Fresh-Faced Recruit
Join Date: Feb 2001
Location: Ottawa, Canada
Status: Offline
Reply With Quote
Mar 1, 2001, 08:19 PM
 
Okay, I'll bite...

In terms of features Java and Obj-C are very similar. They are both very advanced object-oriented languages, and any feature that one has over the other is generally balanced vice versa. Their syntax is also pretty close when it comes down to it.

When making an application using Apple's Cocoa AppKit both languages are supposed to have equal access, although Apple currently has more examples using Obj-C code. Therefore, you won't *lose* anything by writing in one language or the other.

In terms of speed, I think three-five times slower is a little excessive. Yes, Java is *currently* slower because it is compiled from byte code into machine code at runtime (Obj-C also takes a hit over regualar C because a lot is done at runtime). I say currently because I've recently read a number of articles suggesting that there are certain efficiencies that can be exploited at runtime in order to make Java just as fast, if not faster than compiled code.

On modern machines, the theory is, most people won't notice the difference between Java and Obj-C (things happen in 1.5 milliseconds instead of 1 millisecond).

That being said Java on OS X PB is currently pretty slow, although word on the street is that it screams on Final.

Finally, my suggestion is to stick with Java if you already know it. Even if you don't, Java is easier to learn and forces you into a lot of good OO programming habits that can be carried over to other languages.
     
Fresh-Faced Recruit
Join Date: Feb 2001
Location: Ottawa, Canada
Status: Offline
Reply With Quote
Mar 1, 2001, 08:20 PM
 
Okay, I'll bite...

In terms of features Java and Obj-C are very similar. They are both very advanced object-oriented languages, and any feature that one has over the other is generally balanced vice versa. Their syntax is also pretty close when it comes down to it.

When making an application using Apple's Cocoa AppKit both languages are supposed to have equal access, although Apple currently has more examples using Obj-C code. Therefore, you won't *lose* anything by writing in one language or the other.

In terms of speed, I think three-five times slower is a little excessive. Yes, Java is *currently* slower because it is compiled from byte code into machine code at runtime (Obj-C also takes a hit over regualar C because a lot is done at runtime). I say currently because I've recently read a number of articles suggesting that there are certain efficiencies that can be exploited at runtime in order to make Java just as fast, if not faster than compiled code.

On modern machines, the theory is, most people won't notice the difference between Java and Obj-C (things happen in 1.5 milliseconds instead of 1 millisecond).

That being said Java on OS X PB is currently pretty slow, although word on the street is that it screams on Final.

Finally, my suggestion is to stick with Java if you already know it. Even if you don't, Java is easier to learn and forces you into a lot of good OO programming habits that can be carried over to other languages.
     
Senior User
Join Date: Feb 2001
Location: Rochester, uk
Status: Offline
Reply With Quote
Mar 2, 2001, 03:56 AM
 
In terms of speed, I think three-five times slower is a little excessive. Yes, Java is *currently* slower because it is compiled from byte code into machine code at runtime (Obj-C also takes a hit over regualar C because a lot is done at runtime). I say currently because I've recently read a number of articles suggesting that there are certain efficiencies that can be exploited at runtime in order to make Java just as fast, if not faster than compiled code.
I've been reading those articles ever since i started with Java, and I've yet to see it working. To be fair, most of the slowdown in the Java i used was the fault of Swing, so in Cocoa it should be a lot closer to equal.

On the whole, use whatever you think you're most comfortable with. But employers like it if you know C.

All words are lies. Including these ones.
     
Dedicated MacNNer
Join Date: Oct 2000
Location: Pasadena, CA, USA
Status: Offline
Reply With Quote
Mar 2, 2001, 12:03 PM
 
I've written several small Cocoa apps in both Java and Obj C, and the performance differences were negligible. I think the biggest problem with developing Java Cocoa apps is that Apple's documentation is poor (I would love to see javadoc generated documentation) and incomplete. Furthermore, the examples of Java Cocoa apps they provided with the developer tools on the Public Beta were not IMHO very well written Java apps - they looked like someone had written them first in Obj C, and then did the minimum amount of work necessary to make them compile under Java.

If you're thinking of writing Swing applications, the story is very different. Swing on OS X is slower than Cocoa apps of any stripe. But the difference in performance is no worse than it is on other platforms. I've done Swing development on Solaris, Linux, NT, and Mac OS 9, and Swing applications (and AWT applications for that matter) are always slower and often more clunky than native apps. This may improve on OS X when it is released, but frankly I don't think Swing apps are ever going to be as fast Cocoa or Carbon apps.
     
ali
Forum Regular
Join Date: Sep 2000
Status: Offline
Reply With Quote
Mar 2, 2001, 08:23 PM
 
As others have pointed out, Obj-C and Java are on par as far as object-orientedness and language features. If you learn one, you should have quite an easy time learning the other. The larger part of the learning curves in both is mastering object-oriented design, and learning the APIs. So either one should be fine; if you learn to program Cocoa in one, it won't take much time to start writing programs in the other.

As far as what to write a real app in... The reality today is that apps written in Obj-C are more efficient. This isn't necessarily because Java is interpreted and is slower to execute; today's just-in-time compilers are actually pretty good at getting code to run as fast as their compiled C counterparts. The main reason is that Java's design and this on-the-fly compiling ends up causing running apps to use way more memory than equivalent C or Obj-C applications. As a result, your apps will probably take longer to startup and your machine will swap more on low memory machines. This also means trying to run multiple apps simultaneously will cause you to run out of memory sooner.

But, get a machine with big enough memory and accept the longer launch time, and a Java app might very well execute most operations as fast as a pure C or Obj-C app.

Ali



[This message has been edited by ali (edited 03-02-2001).]
     
Grizzled Veteran
Join Date: Oct 2000
Location: Cardiff, Wales
Status: Offline
Reply With Quote
Mar 7, 2001, 09:34 AM
 

From a non-technical point of view, I would say that being able to program Java is far more useful in the real world, and it means you can build Mac apps, cross-platforms apps, applets and websites with the same language.

Is Obj-C really as elegant as Java? I might give it a go if it is, but my memories of C/C++ are too painful to ever go back.

Chris
     
evdmeer  (op)
Fresh-Faced Recruit
Join Date: Feb 2001
Location: Amstelveen, Netherlands
Status: Offline
Reply With Quote
Mar 8, 2001, 05:21 AM
 
Thank you all for your replies.

So itīs basically just about the same.
Seems like I am now involved in a project that will do objective C. So Iīll start there and probably try doing some java in the future.

regards
     
   
Thread Tools
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
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 12:30 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2