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 > Which language for Cocoa Development?

Which language for Cocoa Development?
Thread Tools
TC
Senior User
Join Date: Mar 2001
Location: Milan
Status: Offline
Reply With Quote
Feb 19, 2002, 07:59 AM
 
I just wanted to get some feedback from people on whether I should go with Java or Objective C for writing cocoa apps?

My background is in both C and Java but I have never used Objective C (or C++). At the current time I do a lot more in Java than I do in C.

Basically can I do the same things with Cocoa in Java as I can with Objective C and have people seen major speed differences?
Nothing to see, move along.
     
Grizzled Veteran
Join Date: Feb 2001
Location: Germany
Status: Offline
Reply With Quote
Feb 19, 2002, 08:39 AM
 
i also used to be a pure java person (well, it's been a hobby) and then finally decided to give objective-c a try. the syntax first might give you the impresion of being a bit confusing, but it's not.

i wish every language were so readable.
it's fun and you'll get used to it within a few days, i promise.

go for objective-c. the only disadvantage i see is that you'll never want to go back to java again.
     
Addicted to MacNN
Join Date: Feb 2001
Location: zurich, switzerland
Status: Offline
Reply With Quote
Feb 19, 2002, 10:28 AM
 
I agree that ObjC has some dynamic features that are lacking in Java, although JDK1.4 has added generics which are similar to protocols. Apart from that I still find Java easier to read than ObjC but ObjC is really more powerful. I think it all depends on what one wants to do: If you have heavy calculations with massive object generation I think ObjC will be a lot faster and the same goes for GUI intensive apps as all calls have to go over the Java-ObjC bridge, but for your average app I don't think you'll notice much of a difference.

Seb2: Im Winter gehe ich auch schwimmen
weird wabbit
     
Grizzled Veteran
Join Date: Feb 2001
Location: Germany
Status: Offline
Reply With Quote
Feb 19, 2002, 10:41 AM
 
Originally posted by theolein:
<STRONG>...
Apart from that I still find Java easier to read...</STRONG>
ok, quick, without looking at the apis, what types are the letters:

GridBagConstraints(a, b, c, d, e, f, g, h, i, j, k)
and:
postNotificationName:a object:b userInfo:c

see what i mean?

but that's only my personal opinion.

<STRONG>
Seb2: Im Winter gehe ich auch schwimmen </STRONG>
brrrr...!
     
Fresh-Faced Recruit
Join Date: Dec 2001
Location: Fluidic Space
Status: Offline
Reply With Quote
Feb 19, 2002, 12:03 PM
 
I think Java is the way to go! Java is cross-platform and is not limited to Mac OS X as Obj-C is. If you're only going to write apps for Mac OS X then you should learn Obj-C.
     
Admin Emeritus
Join Date: Oct 2000
Location: Boston, MA
Status: Offline
Reply With Quote
Feb 19, 2002, 12:32 PM
 
Originally posted by Species 8472:
<STRONG>I think Java is the way to go! Java is cross-platform and is not limited to Mac OS X as Obj-C is. If you're only going to write apps for Mac OS X then you should learn Obj-C.</STRONG>
But without Cocoa, Java apps look, smell, and feel like crap. And if you're going to tie your app down to Cocoa, you might as well keep it ObjC. If you're worried about portability, just write a wrapper library (which you're likely to do anyway) with standard C calls.
"Against stupidity, the gods themselves contend in vain" (Schiller)
     
Clinically Insane
Join Date: Nov 1999
Status: Offline
Reply With Quote
Feb 19, 2002, 01:47 PM
 
Like Hillegass said in his book, if you want to program in Java then use Swing. It was designed for Java, takes better advantage of Java's features, and will generally give better results than Cocoa/Java would. Go with Objective-C if you want to use Cocoa.

Also note that Species 8472's bit about Java being cross-platform is irrelevant; you lose that aspect of Java if you use it for Cocoa anyway, so it's no longer an advantage.
You are in Soviet Russia. It is dark. Grue is likely to be eaten by YOU!
     
Addicted to MacNN
Join Date: Feb 2001
Location: zurich, switzerland
Status: Offline
Reply With Quote
Feb 19, 2002, 04:31 PM
 
Originally posted by seb2:
<STRONG>
ok, quick, without looking at the apis, what types are the letters:

GridBagConstraints(a, b, c, d, e, f, g, h, i, j, k)
and:
postNotificationName:a object:b userInfo:c

see what i mean?

but that's only my personal opinion.
</STRONG>
Do you know people that use single letters for variable names???
Normally in Java that would be:
GridBagConstraints(nameA, objectB, userInfoC)
and in ObjC when declaring a method there's nothing to stop you doing something silly like:
postNotification:a :b :c
But most people make their programmes at least semi legible
<STRONG>

brrrr...!</STRONG>
Es gibt ja Hallenbäder
weird wabbit
     
Senior User
Join Date: Feb 2001
Location: Rochester, uk
Status: Offline
Reply With Quote
Feb 20, 2002, 03:18 AM
 
Aside from personal preferences about syntax (i'm afraid that is what they are!), the big difference is that Java is garbage collected. If you don't know what that means and don't want to know, then Java is for you.

Objective-C isn't as bad at memory as C and C++, but you do still have work to do. In java you can almost forget about it.

That aside, both languages have nice features that you can learn from, so I suggest you learn it anyway - even if you don't use it!
All words are lies. Including these ones.
     
TC  (op)
Senior User
Join Date: Mar 2001
Location: Milan
Status: Offline
Reply With Quote
Feb 20, 2002, 04:37 AM
 
Thanks for the feedback people.

I think I will dip my toes into Objective C and see how it goes.

Sadie, you are bang on pointing out the garbage collection. It was while reading about how you have to take care of it in Objective C that I started having second thoughts.

Finally, any good references for learning Objective C, sites/books?
Nothing to see, move along.
     
Fresh-Faced Recruit
Join Date: Jan 2002
Location: Cambridge, England
Status: Offline
Reply With Quote
Feb 20, 2002, 06:56 AM
 
If you program Cocoa aps in Java they run in the Java Runtime Environment and therefore you get to use things like JDBC and your existing .JAR files.
mmmm - I'm a big Cinnamon bun.
     
Professional Poster
Join Date: Apr 2001
Location: Long Beach, CA
Status: Offline
Reply With Quote
Feb 20, 2002, 08:26 AM
 
Aaron Hillegaas' book is definately the way to go. The O'Reilly book just doesn't seem well laid out. Also, the Hillegaas book actually gives you homework (projects) to do on your own--it MAKES you learn the stuff.

ACSA 10.4/10.3, ACTC 10.3, ACHDS 10.3
     
Fresh-Faced Recruit
Join Date: Dec 2001
Location: Fluidic Space
Status: Offline
Reply With Quote
Feb 20, 2002, 01:45 PM
 


[ 02-20-2002: Message edited by: Species 8472 ]
     
Fresh-Faced Recruit
Join Date: Dec 2001
Location: Fluidic Space
Status: Offline
Reply With Quote
Feb 20, 2002, 01:54 PM
 
Originally posted by Millennium:
<STRONG>Like Hillegass said in his book, if you want to program in Java then use Swing. It was designed for Java, takes better advantage of Java's features, and will generally give better results than Cocoa/Java would. Go with Objective-C if you want to use Cocoa.

Also note that Species 8472's bit about Java being cross-platform is irrelevant; you lose that aspect of Java if you use it for Cocoa anyway, so it's no longer an advantage.</STRONG>
What I ment was Java syntax is cross-platform, so why learn a new language like Objective-C if you also need to program for other platforms than OS X. If you program in Cocoa Java you only loose the interface if you want to move your app to another platform. Java classes can be reused on any platform.

[ 02-20-2002: Message edited by: Species 8472 ]
     
Clinically Insane
Join Date: Nov 1999
Status: Offline
Reply With Quote
Feb 20, 2002, 02:38 PM
 
Originally posted by Species 8472:
<STRONG>

What I ment was Java syntax is cross-platform, so why learn a new language like Objective-C if you also need to program for other platforms than OS X. If you program in Cocoa Java you only loose the interface if you want to move your app to another platform. Java classes can be reused on any platform.

[ 02-20-2002: Message edited by: Species 8472 ]</STRONG>
Depending on how you write the app, the same can be done for Objective-C.

Consider: Objective-C is nothing more than an extension to plain old C, and can in fact use standard C stuff and interface with C code. If you only use Objective-C for the interface, and plain C (or even C++) for the rest, then just as with Java, all you lose is the interface.

Remember the multi-platform release of Quake 3? the whole game was something on the order of five million lines of code. Of these, only about 10,000 were plarform-specific; that's less than two percent. And if I have my figures right, Omni was able to pull off a Cocoa port with only 800 lines of platform-specific code.

My point is this: if you design your app right, going cross-platform is not any more difficult with Objective-C than it is with any other language. And furthermore, the benefits of such a design aren't just limited to Cocoa; it allows you to more easily port to other platforms too, because you reuse more code.
You are in Soviet Russia. It is dark. Grue is likely to be eaten by YOU!
     
Senior User
Join Date: Feb 2001
Location: Rochester, uk
Status: Offline
Reply With Quote
Feb 21, 2002, 03:38 AM
 
Rob Judd made the mistake of revealing:
<STRONG>I'm a big Cinnamon bun.</STRONG>
*big evil hungry grin*
All words are lies. Including these ones.
     
Mac Enthusiast
Join Date: Apr 2001
Location: 127.0.0.1
Status: Offline
Reply With Quote
Feb 21, 2002, 12:27 PM
 
ObjC may be the natural answer to this question, since it's the language Cocoa was originally designed for. However, I have to say that I'm really impressed with Apple and the way they have supported Java under Cocoa. As a Java programmer, it's refreshing to see this level of dedication. I'm still in the "learning stages" of becoming a Cocoa developer, but in my experiments so far I haven't noticed any substantial performance hits as the result of using Java (maybe due to HotSpot?). This is when using Cocoa mind you... there are still speed issues when using Swing. The only real problem I've had so far is a lack of documentation as compared to the ObjC side of the fence. Maybe one day I'll learn Objective C, but for now I'm having fun developing native Mac OS X apps using Cocoa + Java.

I'd say, if you already know Java, leverage that knowledge to get a handle on the Cocoa framework, rather than trying to learn a new language *and* a new framework at the same time. After you're comfortable with Cocoa itself, then you may want to look into ObjC (if you still feel the need).
     
Fresh-Faced Recruit
Join Date: Dec 2001
Location: Fluidic Space
Status: Offline
Reply With Quote
Feb 21, 2002, 02:51 PM
 
Originally posted by joltguy:
<STRONG>I'd say, if you already know Java, leverage that knowledge to get a handle on the Cocoa framework, rather than trying to learn a new language *and* a new framework at the same time. After you're comfortable with Cocoa itself, then you may want to look into ObjC (if you still feel the need).</STRONG>
I totally agree with joltguy. I also think that Swing sucks on OS X, it is way too slooooow compared to Cocoa. However, I think it would be good if developers would use Swing because it would force Apple to make faster hardware.

     
Fresh-Faced Recruit
Join Date: Dec 2001
Location: Fluidic Space
Status: Offline
Reply With Quote
Feb 21, 2002, 02:55 PM
 
Originally posted by joltguy:
<STRONG>I'd say, if you already know Java, leverage that knowledge to get a handle on the Cocoa framework, rather than trying to learn a new language *and* a new framework at the same time. After you're comfortable with Cocoa itself, then you may want to look into ObjC (if you still feel the need).</STRONG>
I totally agree with joltguy. I also think that Swing sucks on OS X, it is way too slooooow compared to Cocoa. However, I think it would be good if developers would use Swing because it would force Apple to make faster hardware.

     
Fresh-Faced Recruit
Join Date: Feb 2002
Status: Offline
Reply With Quote
Feb 28, 2002, 09:05 PM
 
Originally posted by Detrius:
<STRONG>Aaron Hillegaas' book is definately the way to go. The O'Reilly book just doesn't seem well laid out. Also, the Hillegaas book actually gives you homework (projects) to do on your own--it MAKES you learn the stuff.</STRONG>
I don't know about Aaron Hillegass' book, but I know that the O'Reilly book has an introduction into Objective C at the beginning of it &mdash; a rather good introduction, in my opinion.
     
TC  (op)
Senior User
Join Date: Mar 2001
Location: Milan
Status: Offline
Reply With Quote
Mar 20, 2002, 07:28 AM
 
Has anyone got any information about this book:
Early Adopter Mac OS X Java
by Wrox.
Nothing to see, move along.
     
Junior Member
Join Date: Mar 2001
Status: Offline
Reply With Quote
Mar 20, 2002, 01:30 PM
 
I also think that Swing sucks on OS X, it is way too slooooow compared to Cocoa.

No, Swing sucks on every platform.
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Mar 20, 2002, 01:57 PM
 
Originally posted by Species 8472:
<STRONG>What I ment was Java syntax is cross-platform, so why learn a new language like Objective-C if you also need to program for other platforms than OS X. If you program in Cocoa Java you only loose the interface if you want to move your app to another platform. Java classes can be reused on any platform.</STRONG>
1) Obj-C is a superset of C, so it's hardly an entirely new language if you know C (and you really should know C).
2) Java's syntax is very like C's, so after learning the syntax with C and objects with Obj-C, Java is like a walk in the park on a sunny afternoon.
3) Learning new languages and their ways of doing things is always good practice, it will make your coding skills better no matter what.
     
Mac Elite
Join Date: Feb 2001
Location: Vancouver, WA
Status: Offline
Reply With Quote
Mar 20, 2002, 05:12 PM
 
Also, depending on what you're doing with a Mac OS X application, you may need to interact with C code quite a bit. Most of the things you'd need POSIX/BSD APIs for are provided by Java's System object, but some thigns aren't. And there are lots of things you might want to access in CoreFoundation or CoreServices or Carbon or CoreGraphics. It's a lot easier to do that from ObjC than from Java.

My position is that Cocoa/Java can be a great stepstone to learning Cocoa/ObjC if you're already familiar with Java, because it lets you learn the frameworks and design patterns separately from the language. But it's not viable for development of large complex applications (like Omni's).
Rick Roe
icons.cx | weblog
     
Senior User
Join Date: Nov 2000
Status: Offline
Reply With Quote
Mar 21, 2002, 01:52 PM
 
i also used to be a pure java person (well, it's been a hobby) and then finally decided to give objective-c a try. the syntax first might give you the impresion of being a bit confusing, but it's not.

i wish every language were so readable.
it's fun and you'll get used to it within a few days, i promise.

go for objective-c. the only disadvantage i see is that you'll never want to go back to java again.
Just thought that needed to be said again. It's very true.

All the other points are probably just as good but I can really relate to the above.
     
Forum Regular
Join Date: Jan 2001
Location: Boston, MA
Status: Offline
Reply With Quote
Mar 21, 2002, 03:36 PM
 
After much trepdiation, I'm just about finishing up my first Objective-C application. I had been writing in Cocoa using Java, but forced myself to give Objective-C a chance. I'm actually very impressed at how quick the language is to pick up. However, you're still dealing with C's memory management, although Cocoa objects have their own retain/release rules which makes life a bit easy. Still, Java's garbage collector and pointer-free environment can make development easier for some programmers - but there is a runtime overhead to pay.

One nice thing about Objective-C on Mac OS X is that you can call Java classes from Cocoa using the Java Bridge. I don't know if that's old or unsupported, but if you've got Java code to integrate it's the way to go.

In making your decision, you need to look at the type of apps you'll be creating. Apple hasn't provided any robust Cocoa classes for XML parsing and SOAP/web services, plus you'll still have to dip in Carbon to get some things done (using Icon Services for instance).

I'd say that it's well worth your time to learn both. I'll probably write most of my Mac OS X-specific stuff in Objective-C and keep using Java for server-side development and the occasional cross-platform application. Until Apple ships a Windows Cocoa runtime, Java and Swing are the only way to go!
     
Junior Member
Join Date: Feb 2002
Location: Atlanta
Status: Offline
Reply With Quote
Mar 23, 2002, 09:47 AM
 
go for objective-c. the only disadvantage i see is that you'll never want to go back to java again.
Hrm. Personally, after working with Obj-C, I can't wait to get back to Java.

I honestly don't see what the fuss over Obj-C is all about. Did C for years and I'm in no hurry to go back.

I'm contemplating setting up a website to discuss Cocoa/Java just to counteract some of the proselytizing of the NextStep faithful. Apple
promised us that they'd make Java a peer of Obj-C in the Cocoa world. In my view, they haven't yet delivered on that promise. It's time to hold them to it, not time to switch programming languages just because the 'experts' say we should.

Apple, give us well supported, well documented Cocoa Java, with plenty of good sample code. Is that so much to ask?


Sorry, this just has been bugging me lately. Obj-C syntax gives me a headache.

I freely admit that I have not explored the developers documentation since Apple's most recent update. They may have improved things somewhat.

#gheff
     
Grizzled Veteran
Join Date: Apr 2001
Status: Offline
Reply With Quote
Mar 23, 2002, 02:38 PM
 
Hrm. Personally, after working with Obj-C, I can't wait to get back to Java.
Why?

Other than GC, what's Java's advantage of Objective C? (And GC isn't necessarilly an advantage, either)

Wade
     
Dedicated MacNNer
Join Date: Feb 2001
Status: Offline
Reply With Quote
Mar 23, 2002, 03:04 PM
 
Originally posted by gheff:
<STRONG>Obj-C syntax gives me a headache.
</STRONG>
That's because you're not used to it. I felt exactly the same way when I started, but once I used it for awhile it was much more natural and readable than the "standard" Java/C/C++ syntax.
     
Junior Member
Join Date: Feb 2002
Location: Atlanta
Status: Offline
Reply With Quote
Mar 24, 2002, 10:08 AM
 
Originally posted by 3.1416:
<STRONG>

That's because you're not used to it. I felt exactly the same way when I started, but once I used it for awhile it was much more natural and readable than the "standard" Java/C/C++ syntax.</STRONG>
That may well be true, ~pi, but truthfully I don't want to become intimate with Objective C. To me, Apple (and the old NextStep cartel) is pulling the old bait and switch ploy on us. Steve got us all salivating over Cocoa and then he informed us that Java would be a peer of Objective C in the use of the Cocoa frameworks. Wheee! Cool!

But when push comes to shove, any of us who are interested in really using Java to do Cocoa are told, "Oh, you don't really want to use Java, you silly goose. Here, try Objective C instead. It's better. You'll get used to it eventually."

To me, this is the same as the car salesman who gets me into his showroom with an ad for one car and then says "Oh, we don't have any of that model. Try this one instead."

If it weren't for the fact that the Cocoa frameworks are so damned cool, I don't think we'd be even having these discussions. But Java AWT blows and Java Swing is adequate but not special, so the promise of a really cool framework to go with Java is a sweet one indeed. If Steve hadn't teased us with that promise, I'd be happily coding away on OS X using Swing. As it is, I'm unhappily thrashing between using Java/Swing and Obj-C/Cocoa.

For me, programming on OS X is a hobby. My work is done in Java (at the moment at least) on Windows. I get maybe an hour or two a day to even think about it. The Cocoa frameworks are daunting enough, but add to it the fact that I also have to learn this C mutation, all between the hours of 10pm and midnight.

Wade asks:
Other than GC, what's Java's advantage of Objective C? (And GC isn't necessarilly an advantage, either)
The biggest advantage to me is that Java is what's in my brain is right now. I did C years ago but was never really its biggest fan. When Java came along, it gave me the familiar syntax structure without all the pointer and memory heartburn. It was not that I couldn't deal with those things, but that I was tired of them. To me, garbage collection is a plus. Let the computer do that stuff, so I don't have to. Call me a selfish wussy if you want, but I don't want to go back to that.

I'll finish up this rant now.

If I were planning to switch my career to professional Mac OS programming, I would almost certainly invest the time in Cocoa using its native language. But I'm not going to do this. Can't afford to do this. But I think there's a certain class of programmer out there who, like me, is looking for Java on a cool platform with cool frameworks.

I wouldn't be nearly as pissed if Apple hadn't promised me this.

Oh, and the first person who suggests that Obj-C is too hard for me and that I should try Realbasic instead, gets hit over the head with a trout.

Thanks for suffering though this rant,
#gheff
     
Dedicated MacNNer
Join Date: Oct 2000
Status: Offline
Reply With Quote
Mar 24, 2002, 03:42 PM
 
In reply to gheff:

Personally, I don't like Java because I haven't learned enough about it to use it. I did take a class and struggled through it, whereas C and C++ haven't been a problem.

But that's not my point. Does anyone care to comment on this, from the "MacOS X Developer's Guide" by Jesse Feiler (2002, Academic Press):

"Cocoa is written in Objective-C. A mechanism called the Java bridge exists to let you call Objective-C code from Java (and vice versa). The bridge is so effective that you may not really notice it at all: You can write your Cocoa code, calling apparently Java classes and methods, without being aware of the bridge in most cases.

"There are two situations in which you do need to be aware of the bridge. In the first, you should realize that, yes, there is a slight effect on performance when using the Java bridge. This does not mean that Cocoa applications written in Java are slow: Most applications on personal computers spend most of their time waiting for user input. Even the fastest typist cannot keep u with today's processors. If you are writing an extraordinarily demanding application, you may need to consider this. For most people, that is not the case.

"The second occasion when you need to worry about the Java bridge is when you need to call a Cocoa framework method or use a Cocoa class and yo do not have documentation for it in Java. Most of the Cocoa documentation is provided both in Java and Objective-C, bu there are some lacunae."

Java bridge: Apple documentation

So, is Mr. Feiler writing from experience. or is he just repeating claims that have been made about OS X and Java interoperability?
     
Senior User
Join Date: Feb 2001
Location: Rochester, uk
Status: Offline
Reply With Quote
Mar 27, 2002, 03:39 AM
 
I've written serious projects in both Java and Objective-C (but oddly enough not Cocoa), and I like them both. My quiet personal opinion is that Java is better, but then I'm paid for it.

I think it should be possible to use a solid object framework like Cocoa from within ANY object-oriented language - meaning C++ (with actual C++ syntax), Perl, Eiffel, SmallTalk, etc.

Apple should be applauded for making the Java-ObjC bridge as smooth as it is. Now let's do the same for a dozen other combinations, and make Cocoa into a universal framework. Eventually, it could even replace Carbon (or rather, botched Carbonized Classic) as the default for C++ ports.

<STRONG>Even the fastest typist cannot keep u with today's processors.</STRONG>
Unless it's written in botched Carbonized Classic, of course.
All words are lies. Including these ones.
     
   
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 03:16 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