 |
 |
Objective C or Java
|
 |
|
 |
|
Forum Regular
Join Date: Jan 2001
Location: Dallas, TX
Status:
Offline
|
|
I want to start to write some apps for the Mac OS X platform and can't decide if I should use Objective-C or Java.
My first thought is Java, since I have been doing development professionally with Java for the past 3 years.
Are there any benefits of developing with Objective-C over Java? If I use Java do I have access to the entire toolbox (api) that is available with Objective-C? Any comments would be appreciated.
Thanks in advance.
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Jan 2001
Location: Beverly Hills, CA, USA
Status:
Offline
|
|
i will probably learn java and C, i think C is a good basic foundation for all programming...about java accessing all of obj-c classes, i'm not sure...this i would want to know also, tz3gm
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Oct 2000
Location: Pasadena, CA, USA
Status:
Offline
|
|
> Are there any benefits of developing with Objective-C over Java?
There are clear resource benefits: Objective C apps use significantly less RAM and may use less of the processor. There is some debate as to whether Objective C applications run faster than Java apps - personally I say they don't.
> If I use Java do I have access to the entire toolbox (api) that
> is available with Objective-C?
Most of the Objective C library of objects are available to Java applications via a clever bridging technology. Using Interface Builder (Apple's GUI building tool) you can create complete user interfaces, and then have Java classes receive events from them. In my experience, it works very well, and UI performance is much better with Cocoa than with Java's other UI systems (AWT or Swing).
If you already know Java, stick with it and start reading the Java Cocoa documentation and looking at the sample applications. They'll give you a good idea of what's what. Although, IMHO the sample applications don't really have good Java style.
Erik
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Mar 2001
Location: Seattle, WA
Status:
Offline
|
|
I have been programming in Objective-C for about 7 or 8 years now and I think it is the most elegant, flexible, powerful and easy to read programming language I've ever used. For comparison, I've also done software development in Fortran, C, Java and Visual Basic (yech!)
I've written several programs in Java as well and although Java is a good Object-Oriented language, IMHO I feel that it was designed for another purpose entirely and Sun merely "positioned" the language into the space it occupies today. In fact, the designer of Java borrowed several language features from Objective-C.
I was able to learn Java and become productive in only a couple of weeks due in part to my experience with Objective-C. I'm sure than most Java developers would have a similar experience learning Objective-C.
If you already know Java, why not try learning something new like Objective-C?
The bottom line, however, is learning the API to the frameworks that Apple provides. What language you choose to program in is largely immaterial...
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Jan 2001
Location: Beverly Hills, CA, USA
Status:
Offline
|
|
so, what lang. should a beginner learn...w/java you can write cross platform and w/Obj-C u can only write for apple.....
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Jan 2001
Location: ny ny usa
Status:
Offline
|
|
observations (talking out my ass)
1) The Java bridge sounds scary, an extra layer to break and an extra layer that might decrease performance. Violates the Keep It Simple Stupid principal
2) The cocoa api are not 100% accessable from Java. Why work in a language that can't deliver the full potential of Cocoa.
|
|
'Satisfy the urge and discover the need' Q-Tip
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status:
Offline
|
|
Uhm... I'm pretty sure almost all of Cocoa is accessible from Java, if not all. Apple has really worked hard to get Java 2 on par with Objective C when it comes to Cocoa development.
|
|
|
| |
|
|
|
 |
|
 |
|
Junior Member
Join Date: Apr 2001
Location: Seattle, WA, USA
Status:
Offline
|
|
Originally posted by eyadams:
> Are there any benefits of developing with Objective-C over Java?
There are clear resource benefits: Objective C apps use significantly less RAM and may use less of the processor. There is some debate as to whether Objective C applications run faster than Java apps - personally I say they don't.
I was a Java programmer for more than six years. I started out trying to use the bridge a little before public beta and found it really buggy. I left my machine alone until I got 4K78, at which point I decided to read the Objective-C book that you can download. I learned the language in a couple of days, and got facile with the Cocoa framework in a week. I've been programming 12 hours a day in ObjC/Cocoa for the last two weeks and am having a great time. Once I figured out the reference counting mechanism, I was home free.
As far as performance goes, I did a test. Since I really hate NSScanner, I ported java.io.StreamTokenizer to Objective-C... line-by-line. No changes in the algorithm at all. It produces identical results to the Java version. I then put it in my benchmark harness and was surprised to find that the JVM on OSX is fast! The Objective-C version was only about 10% faster than the Java one.
The only downside I can see to writing in Java would be the absolutely HUGE hit you take in starting the JVM. A tiny Java/Cocoa app will eat up over 200 megabytes of VM... and I'm sure a fairly bug chunk of real ram too.
As a side note, I found porting from Java -> Objective C to be so simple it felt like a sed script could do it automatically... modulo retain/release.
class Foo {
void bar(int first, String second) { ... }
}
...
foo.bar(a, b);
@interface Foo {}
- (void)bar  int)first secondFormalParameterName  NSString *)second;
...
[foo bar: a secondFormalParameterName: b];
Pretty much just robotic replacement once you get the hang of it.
[This message has been edited by tom_waters (edited 04-11-2001).]
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Jan 2001
Location: Areas 51 thru 55 :P
Status:
Offline
|
|
Well, the real answer is "it depends" (similar to the Economists saying "all other things remaining constant, ..."). I have been programming in Java for about 5 years and I just learned ObjC this last weekend. ObjC is not a difficult language to learn. In may ways it is far more elegant than most other OO programming languages. I really like the concept of Category and the true message sending was done quite well. I like separating the interface of a type from its implementation (i.e. .h and .m files) over the Java mechanism of interface and implementation in the same file.
If you are going to write MacOS X specific apps using Cocoa, then ObjC is the way to go. IB does not yet work well with Java (cannot parse Java code to pick up changes from PB, does not work real well with packages IMO).
If your intent is to write platform indepdent stuff, then JFC or AWT and Java are probably your best bet. You can use Cocoa or the Toolbox with Java, but IB (as I stated earlier) does not yet fully support Java. You can also create MacOS X application bundles using PB or MrJAppBuilder. One quick gotcha is the fact that the Aqua LnF for Swing by default puts the menu inside the frame. I forget what system property you need to change, but you only have to change the system property and you get the menu bar where god intended  .
The other side of the equation is what you want to spend your time doing. While I like doing ObjC/Cocoa/MacOS X stuff, for me these are not really a marketable skills (I'm probably not going to find any ObjC/Cocoa/WebObjects/MacOS X work in my marketplace and I really do not feel like moving), while Java is quite marketable. You *may* want to take into account the marketability of the skill as well. Of course, if you write the next Lotus 1-2-3 type of software, it really does not matter
Just my $2*10E-02. YMMV.
|
|
Well, let's just say, 'if your VCR is still blinking 12:00,you don't want Linux'
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|