Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Apr 11, 2006, 05:57 AM   #1
MacDonaldsd
macrumors 65816
 
MacDonaldsd's Avatar
 
Join Date: Sep 2005
Location: London , UK
Cocoa: Java or Objective-C?

Im wondering what is the differences or benefits of using java rather than object c to build cocoa applications. Or indeed is java the language of choice.
MacDonaldsd is offline   0 Reply With Quote
Old Apr 11, 2006, 06:14 AM   #2
Eraserhead
macrumors G4
 
Eraserhead's Avatar
 
Join Date: Nov 2005
Location: UK
java has no real benifits of Obj C, the only reason to use it is if, like me you don't know how to use objective C.
Eraserhead is offline   0 Reply With Quote
Old Apr 11, 2006, 08:34 AM   #3
MacDonaldsd
Thread Starter
macrumors 65816
 
MacDonaldsd's Avatar
 
Join Date: Sep 2005
Location: London , UK
Are there any reasons why I should use object c ?
MacDonaldsd is offline   0 Reply With Quote
Old Apr 11, 2006, 08:38 AM   #4
jakeOSX
macrumors member
 
Join Date: Mar 2005
it depends on what you are doing.

java will provide portability to other platforms. after java 1.4 it also includes some cocoa bindings. however, the java-cocoa bridge is no longer being updated by Apple.

objective C will let you use the full abilities of cocoa.
jakeOSX is offline   0 Reply With Quote
Old Apr 11, 2006, 08:51 AM   #5
bousozoku
Moderator emeritus
 
Join Date: Jun 2002
Location: Gone but not forgotten.
Using Java will make it easier to run whatever you create on multiple platforms.

Using Objective-C is a great way to write applications for Mac OS X but they will generally stay there because, with the exception of GNUStep, there isn't much else out there that's code compatible in the least.

Both languages are quite amazing and are more similar in thought than in style. Java is growing but Objective-C is holding steady after 20+ years.
bousozoku is offline   0 Reply With Quote
Old Apr 11, 2006, 09:11 AM   #6
SilentPanda
Moderator emeritus
 
SilentPanda's Avatar
 
Join Date: Oct 2002
Location: The Bamboo Forest
Wow... everything I had read on the web and in books was to go the Objective-C route. Then again by "books" I mean Cocoa Programming for Mac OS X by Aaron Hillegass.

I do Java at work (under Windows) but I am trying to learn Obj-C/Cocoa at home. Probably just doing it that way for the learning though. If your Java gets too bound up in Cocoa it's not really portable anymore is it?
__________________
My 24 hour web cam! ʕノᴥʔノ ︵ ┻━┻
And remember.
SilentPanda is offline   0 Reply With Quote
Old Apr 11, 2006, 09:23 AM   #7
crackpip
macrumors regular
 
Join Date: Jul 2002
Also don't forget that Apple has ceased updating the Cocoa-Java bridge.

From Developer Doc's:

Important: Cocoa-Java technology is only a learning tool. Applications targeted for release to customers must be developed using Objective-C to take advantage of all the programming interfaces available in Cocoa. Programming interfaces added to Cocoa in Mac OS X versions later than 10.4 will not be available to Cocoa-Java applications.


crackpip
crackpip is offline   0 Reply With Quote
Old Apr 11, 2006, 09:42 AM   #8
caveman_uk
Guest
 
caveman_uk's Avatar
 
Join Date: Feb 2003
Location: Hitchin, Herts, UK
There are no benefits in using java and cocoa instead of using objective-C cocoa cocoa unless you already know java and don't want to learn another language. The Cocoa frameworks were designed with objective-C in mind and made a number of design assumptions because of it. The java cocoa bridge was there just to help java programmers. It's a clever kludge that never fully supported the entire Cocoa framework anyway. It's no longer supported.

For a more technical description why you shoudln't use Java with cocoa see here.

Besides, one big advantage of Java is portability. If you use it with Cocoa you've lost that advantage.
caveman_uk is offline   0 Reply With Quote
Old Apr 11, 2006, 09:46 AM   #9
dr_lha
macrumors 68000
 
Join Date: Oct 2003
Quote:
Originally Posted by bousozoku
Using Java will make it easier to run whatever you create on multiple platforms.
Not if you're using Cocoa bindings though.
Quote:
Using Objective-C is a great way to write applications for Mac OS X but they will generally stay there because, with the exception of GNUStep, there isn't much else out there that's code compatible in the least.
Again you could say the same about writing Cocoa apps in Java.

Just as you can write Java apps that are portable to other platforms by not using Cocoa, you could write Objective-C programs that are portable to other platforms.

As the guy wants to write Cocoa apps, I'm guessing cross system portability is not high on his agenda.
__________________
Me: 1Ghz 12" PB and Mac mini Intel Core Solo 1.5Ghz, The Wife: 1.86Ghz CD MacBook, Me@Work: 2.66Ghz Mac Pro and a 2.33Ghz C2D 15" Mac Book Pro
dr_lha is offline   0 Reply With Quote
Old Apr 11, 2006, 09:52 AM   #10
MacDonaldsd
Thread Starter
macrumors 65816
 
MacDonaldsd's Avatar
 
Join Date: Sep 2005
Location: London , UK
I want to learn cocoa.

Im currently doing C++ at university and next year I will be learning java.

Do you think I can pick up object c from C++ easily ?
MacDonaldsd is offline   0 Reply With Quote
Old Apr 11, 2006, 10:04 AM   #11
caveman_uk
Guest
 
caveman_uk's Avatar
 
Join Date: Feb 2003
Location: Hitchin, Herts, UK
Objective-C is a superset of C. It's a lot easier than C++. The power of the language comes from the Cocoa frameworks not the language itself.
caveman_uk is offline   0 Reply With Quote
Old Apr 11, 2006, 10:04 AM   #12
peharri
macrumors 6502a
 
Join Date: Dec 2003
Don't

Java is a "better" language than Objective C. It's fully managed and strongly typed, whereas Objective C gives you a lot of rope to hang yourself without really giving you any benefits over Java. Both languages are largely equals when it comes to OO features, Java is just safer. There are subjective points about the readibility of both languages, but I don't think there's much to it.

But as others have pointed out, the Cocoa bindings for Java have been frozen. So my advice would be:

Either:
- write your app in Objective C
- write in Java, but use the Java libraries where possible rather than Cocoa. You can still make Java applications that look, feel, and run like Cocoa programs unless you're doing something very obscure.

The benefits of the former are slightly better integration with OS X (if you want to create Services, for instance (you know, the "Services" submenu of the application name's menu. What? You never use that? Wow, and I thought it was just me ;-) Additionally, XCode integrates very well with it.

The benefits of the latter are much greater platform independence. No need to care about "Universal Binary" type issues (well, you still need to check the box, but the notion something you missed might cause the program to work fine under PPC but not under Intel is, well, not an issue.) You can take advantage of tools like WebStart. Debugging is easier. While XCode isn't really the best tool for this, Netbeans is getting really good at the moment.

Cocoa under Java though? Nope, I wouldn't do it. It's a nice idea, but if Apple's going to deprecate the API, then it's probably best left alone.
peharri is offline   0 Reply With Quote
Old Apr 11, 2006, 10:11 AM   #13
caveman_uk
Guest
 
caveman_uk's Avatar
 
Join Date: Feb 2003
Location: Hitchin, Herts, UK
Quote:
Originally Posted by peharri
Either:
- write your app in Objective C
- write in Java, but use the Java libraries where possible rather than Cocoa. You can still make Java applications that look, feel, and run like Cocoa programs unless you're doing something very obscure.

The benefits of the former are slightly better integration with OS X (if you want to create Services, for instance (you know, the "Services" submenu of the application name's menu. What? You never use that? Wow, and I thought it was just me ;-) Additionally, XCode integrates very well with it.
Of course you wouldn't have cocoa bindings, core data, spotlight, or .mac integration as well as a ton of other stuff that Objective-C/cocoa developers take as a given. Saying it's just the services menu you get from using Cocoa is ignorant and misleading.
caveman_uk is offline   0 Reply With Quote
Old Apr 11, 2006, 10:15 AM   #14
bousozoku
Moderator emeritus
 
Join Date: Jun 2002
Location: Gone but not forgotten.
Quote:
Originally Posted by dr_lha
Not if you're using Cocoa bindings though.

Again you could say the same about writing Cocoa apps in Java.

Just as you can write Java apps that are portable to other platforms by not using Cocoa, you could write Objective-C programs that are portable to other platforms.

As the guy wants to write Cocoa apps, I'm guessing cross system portability is not high on his agenda.
Of course, that's true. I've never suggested to anyone to bother with the Cocoa-Java bridge. It was a quick-and-dirty thing to allow people who didn't understand Objective-C to get by.

Using Objective-C is the best way to write Cocoa applications.

(You'd think that I hadn't fixed the thread title. )

Last edited by bousozoku; Apr 11, 2006 at 11:11 AM.
bousozoku is offline   0 Reply With Quote
Old Apr 11, 2006, 10:32 AM   #15
peharri
macrumors 6502a
 
Join Date: Dec 2003
Quote:
Originally Posted by caveman_uk
Of course you wouldn't have cocoa bindings, core data, spotlight, or .mac integration as well as a ton of other stuff that Objective-C/cocoa developers take as a given. Saying it's just the services menu you get from using Cocoa is ignorant and misleading.
Did I say it's just the Services menu? Nope. Saying I did is ignorant and misleading.

Saying you don't get cocoa bindings though is a little ridiculous. That's like saying if you use Objective C you can't get SWING bindings. Except, of course, that you can get them in Java, it's just not wise to use them.
peharri is offline   0 Reply With Quote
Old Apr 11, 2006, 12:40 PM   #16
HiRez
macrumors 601
 
HiRez's Avatar
 
Join Date: Jan 2004
Location: Western US
I can see how learning C, Onjective-C, and Cocoa all together could be very intimidating, if you are let's say coming from a Java-only backgraound. So perhaps using Cocoa-Java (which should be called Mocha! Duh!) would be a more gentle introduction to the Cocoa APIs. After doing some projects this way maybe it would then be easier to switch over to Objective-C with Cocoa, as you'd already have some familiarity with the basics in a form that you're comfortable with.

Having said that, I learned Cocoa and Objective C coming from a mostly Java background, with very little C experience. It can be a steep learning curve at first but it doesn't take that long to get it. Start with the Hillegass book.
__________________
Go outside, the graphics are amazing!
HiRez is offline   0 Reply With Quote
Old Apr 11, 2006, 01:03 PM   #17
dr_lha
macrumors 68000
 
Join Date: Oct 2003
Personally out of Objective-C and Java for Cocoa programming I choose..... python.
__________________
Me: 1Ghz 12" PB and Mac mini Intel Core Solo 1.5Ghz, The Wife: 1.86Ghz CD MacBook, Me@Work: 2.66Ghz Mac Pro and a 2.33Ghz C2D 15" Mac Book Pro
dr_lha is offline   0 Reply With Quote
Old Apr 11, 2006, 01:47 PM   #18
HiRez
macrumors 601
 
HiRez's Avatar
 
Join Date: Jan 2004
Location: Western US
Quote:
Originally Posted by dr_lha
Personally out of Objective-C and Java for Cocoa programming I choose..... python.
I love Python, I just wish for two things from it:

1. Native Cocoa API for it. The Py-ObjC bridge kind of works, but isn't exactly elegant.

2. A real, modern, comprehensive framework for web applications la Ruby on Rails.

I love the Python language but it's lacking in terms of strong built-in GUI support and web platform services. I haven't tried much with Ruby yet, but I don't like the syntax nearly as much as Python.
__________________
Go outside, the graphics are amazing!
HiRez is offline   0 Reply With Quote
Old Apr 11, 2006, 02:30 PM   #19
dr_lha
macrumors 68000
 
Join Date: Oct 2003
Quote:
Originally Posted by HiRez
I love Python, I just wish for two things from it:

1. Native Cocoa API for it. The Py-ObjC bridge kind of works, but isn't exactly elegant.

2. A real, modern, comprehensive framework for web applications la Ruby on Rails.

I love the Python language but it's lacking in terms of strong built-in GUI support and web platform services. I haven't tried much with Ruby yet, but I don't like the syntax nearly as much as Python.
Yeah, I wasn't being entirely serious - although I do code everything these days python, most of the stuff I need to write are command line tools, and the only GUI stuff I've done with it is some minor Tkinter stuff.

Still I use python all the time for "mission critical" programming, and when I say "mission" I mean "mission" as in "NASA mission", not "real estate mission".
__________________
Me: 1Ghz 12" PB and Mac mini Intel Core Solo 1.5Ghz, The Wife: 1.86Ghz CD MacBook, Me@Work: 2.66Ghz Mac Pro and a 2.33Ghz C2D 15" Mac Book Pro
dr_lha is offline   0 Reply With Quote
Old Apr 11, 2006, 03:04 PM   #20
AlmostThere
macrumors 6502a
 
Join Date: Feb 2005
Location: The royal throne of kings, the sceptred isle, the other Eden, the fortress built
Quote:
Originally Posted by HiRez
I love Python, I just wish for two things from it:

1. Native Cocoa API for it. The Py-ObjC bridge kind of works, but isn't exactly elegant.

2. A real, modern, comprehensive framework for web applications á la Ruby on Rails.

I love the Python language but it's lacking in terms of strong built-in GUI support and web platform services. I haven't tried much with Ruby yet, but I don't like the syntax nearly as much as Python.
1. I am not sure how the first point would be addressed without creating a maintenance nightmare. While it does feel a little odd to start with, I have found that it actually becomes very easy to use especially with the wealth of existing Cocoa documentation. It would be nice if Apple took it on formally as a RAD environment, which OS X seems to lack at the moment. It seems like it would be a lot of effort for not much, if any, benefit but feel free to elucidate.

2. Django? Turbogears?

For the last bit though ... well IMHO I am quite happy having external modules involved rather than built-in functionality. It means existing knowledge can rapidly be brought to bear rather than learning yet another interface to do the same thing again, plus offers the reusability of existing tutorials and documentation. Not to say that a built-in option wouldn't be nice but all too often these just seem to be lowest common denominator feature sets that result in programmes that never really properly mesh with the native environment.

Tools like py2app and py2exe dispose of many of the dependency worries that modular distribution often implies.
__________________
Join the army of the dead: http://www.urbandead.com
AlmostThere is offline   0 Reply With Quote
Old Apr 11, 2006, 03:57 PM   #21
Mord
macrumors G4
 
Mord's Avatar
 
Join Date: Aug 2003
Location: Old York
objective c is a superset of c, which will run on anything, if you learn objective c while noteing what wont work in plain c you'll get the best of both.
Mord is offline   0 Reply With Quote
Old Apr 11, 2006, 08:03 PM   #22
Stella
macrumors 603
 
Stella's Avatar
 
Join Date: Apr 2003
Location: Canada
Depends what you want to do.

Java would be the most useful - if you want platform independence - where as Objective C ( Cocoa ) would restrict you to OSX. If you want to create GUIs under OSX then ObjC is the way to go - far easier than Java, imo - I hate Swing, SWT etc.

Also, if you learn Java, then you can get into J2EE etc. Java would have the possibility of broadening your horizons more so than ObjC.
__________________
Hardware / Software: The right tools for the job - be it Apple or otherwise.
Stella is offline   0 Reply With Quote
Old Apr 11, 2006, 08:25 PM   #23
dr_lha
macrumors 68000
 
Join Date: Oct 2003
Quote:
Originally Posted by AlmostThere
1. I am not sure how the first point would be addressed without creating a maintenance nightmare. While it does feel a little odd to start with, I have found that it actually becomes very easy to use especially with the wealth of existing Cocoa documentation. It would be nice if Apple took it on formally as a RAD environment, which OS X seems to lack at the moment. It seems like it would be a lot of effort for not much, if any, benefit but feel free to elucidate.
Agreed. It would be really nice if Apple picked up Python and PyObjC as their "managed code" programming environment.
__________________
Me: 1Ghz 12" PB and Mac mini Intel Core Solo 1.5Ghz, The Wife: 1.86Ghz CD MacBook, Me@Work: 2.66Ghz Mac Pro and a 2.33Ghz C2D 15" Mac Book Pro
dr_lha is offline   0 Reply With Quote
Old Apr 12, 2006, 06:56 PM   #24
SC68Cal
macrumors 68000
 
Join Date: Feb 2006
It's a tough decision. I come from a Java-only background because that's what they use for the AP Computer Science courses now, I plan on using Java as much as possibly and slowly wean myself of it. Frankly though, I'm not programming at a very high level though, so I imagine that the whole cocoa library/ java library conflict is very much over my head in terms of application. Most of the stuff I import are math functions like the Random number generator, array lists, so on and so forth.
SC68Cal is offline   0 Reply With Quote
Old Apr 13, 2006, 03:31 PM   #25
janey
macrumors 603
 
janey's Avatar
 
Join Date: Dec 2002
Location: sunny los angeles
Quote:
Originally Posted by bousozoku
Both languages are quite amazing and are more similar in thought than in style. Java is growing but Objective-C is holding steady after 20+ years.
Objective-C isn't as widely used as Java (not that that's a good or bad thing), and there's almost no incentive to use objc for development without using open/gnustep or cocoa, which would lead to the fact that it's pretty much only the Mac OS X people who are using objc for anything (sorta lame)

so like, if you don't know either language, java would be better (unless you plan on only OS X development), both would be best, and cocoa+java nullifies one benefit of java.

not to say objc sucks, i'm plodding through the kochan and hillegass books, and i'm liking it so far just, sorta useless when it comes to most of the stuff I end up doing in school and outside of class (where java and C++ tend to be more popular)
__________________
iPad | 15" MacBook Pro | black (iPhone 3GS|MacBook) | Mac mini server
moof!

janey is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Cocoa Touch and Objective C phalgun27 iPhone/iPad Programming 7 Aug 1, 2013 07:09 PM
Basic Objective-C Cocoa questions? cpuin Mac Programming 8 Jun 3, 2013 07:10 PM
BecomeAnXcoder : A free book for starting with Cocoa using Objective-C msaljaber iPhone/iPad Programming 0 Feb 7, 2013 05:30 AM
WebView in Cocoa (Objective-C) tr!pf!3 Mac Programming 0 Aug 28, 2012 09:48 AM
cocoa objective c pdfview not loaded in nsviewcontroller subview haseena Mac Programming 0 May 30, 2012 01:59 AM

Forum Jump

All times are GMT -5. The time now is 12:16 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC