Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

MacDonaldsd

macrumors 65816
Original poster
Sep 8, 2005
1,005
0
London , UK
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.
 

Eraserhead

macrumors G4
Nov 3, 2005
10,434
12,250
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.
 

jakeOSX

macrumors regular
Mar 24, 2005
123
31
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.
 

bousozoku

Moderator emeritus
Jun 25, 2002
16,120
2,397
Lard
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.
 

SilentPanda

Moderator emeritus
Oct 8, 2002
9,992
31
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?
 

crackpip

macrumors regular
Jul 23, 2002
210
0
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
 

caveman_uk

Guest
Feb 17, 2003
2,390
1
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.
 

dr_lha

macrumors 68000
Oct 8, 2003
1,633
177
bousozoku said:
Using Java will make it easier to run whatever you create on multiple platforms.
Not if you're using Cocoa bindings though.
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.
 

MacDonaldsd

macrumors 65816
Original poster
Sep 8, 2005
1,005
0
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 ?
 

peharri

macrumors 6502a
Dec 22, 2003
744
0
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.
 

caveman_uk

Guest
Feb 17, 2003
2,390
1
Hitchin, Herts, UK
peharri said:
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.
 

bousozoku

Moderator emeritus
Jun 25, 2002
16,120
2,397
Lard
dr_lha said:
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. :rolleyes: )
 

peharri

macrumors 6502a
Dec 22, 2003
744
0
caveman_uk said:
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.
 

HiRez

macrumors 603
Jan 6, 2004
6,265
2,629
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.
 

dr_lha

macrumors 68000
Oct 8, 2003
1,633
177
Personally out of Objective-C and Java for Cocoa programming I choose..... python.
 

HiRez

macrumors 603
Jan 6, 2004
6,265
2,629
Western US
dr_lha said:
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.
 

dr_lha

macrumors 68000
Oct 8, 2003
1,633
177
HiRez said:
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". ;)
 
HiRez said:
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.
 

Mord

macrumors G4
Aug 24, 2003
10,091
23
UK
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.
 

Stella

macrumors G3
Apr 21, 2003
8,883
6,477
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.
 

dr_lha

macrumors 68000
Oct 8, 2003
1,633
177
AlmostThere said:
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.
 

SC68Cal

macrumors 68000
Feb 23, 2006
1,642
0
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.
 

janey

macrumors 603
Dec 20, 2002
5,316
0
sunny los angeles
bousozoku said:
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)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.