PDA

View Full Version : It really bothers me that Apple put an end to the Java-Cocoa bridge




jamdr
Nov 16, 2005, 12:50 PM
I mean how hard could it have been to maintain it? The more cocoa bridges the better, because frankly Obj-C is a really annoying language to use, mainly because of the syntax. There are Python, Ruby, AS, C#, etc. bridges but now no Java bridge? I hope a third-party takes up this cause because Java is a great language to work with.



HiRez
Nov 16, 2005, 01:37 PM
I mean how hard could it have been to maintain it? The more cocoa bridges the better, because frankly Obj-C is a really annoying language to use, mainly because of the syntax. There are Python, Ruby, AS, C#, etc. bridges but now no Java bridge? I hope a third-party takes up this cause because Java is a great language to work with.I think if you spent more time with Objective-C, you would come to like its syntax. I know that was the case for me, as I did not initially like it, and now Java seems the clunkier of the two to me. But even though I think Objective-C is clearly the best language to use for Cocoa development, I agree with you that it's too bad Apple abandoned the Cocoa-Java bridge. They do have a history of abruptly abandoning technologies, or letting them wither on the vine for so long they become less relevant. Witness OpenDoc, Hypercard, QuickTime for Java, WebObjects, AppleWorks, KidSafe, QuickDraw3D, etc. If you really need to do Java development, I highly encourage you to give Objective-C more time to sink in. There is a point where is clicks and makes sense, and stops looking awkward to read.

robbieduncan
Nov 16, 2005, 03:33 PM
I think if you spent more time with Objective-C, you would come to like its syntax. I know that was the case for me, as I did not initially like it, and now Java seems the clunkier of the two to me. But even though I think Objective-C is clearly the best language to use for Cocoa development, I agree with you that it's too bad Apple abandoned the Cocoa-Java bridge. They do have a history of abruptly abandoning technologies, or letting them wither on the vine for so long they become less relevant. Witness OpenDoc, Hypercard, QuickTime for Java, WebObjects, AppleWorks, KidSafe, QuickDraw3D, etc. If you really need to do Java development, I highly encourage you to give Objective-C more time to sink in. There is a point where is clicks and makes sense, and stops looking awkward to read.

And once you get used to categories you'll begin to wonder who other languages don't have them! I write code in a number of languages both professionally and for fun and Java was my favourite until I learnt Obj-C/Cocoa.

hopejr
Nov 16, 2005, 10:40 PM
And once you get used to categories you'll begin to wonder who other languages don't have them! I write code in a number of languages both professionally and for fun and Java was my favourite until I learnt Obj-C/Cocoa.
Same with me. ObjC is a nice language. I prefer it out of all the languages (~15) that I know. Yeah, categories are great! The made life easier with a project I just did. I could add more code to a class without bloating the original implementation file :D.

caveman_uk
Nov 17, 2005, 02:52 AM
Was just wondering about categories. Is there any way to forward declare a method that's in a category but is called from the original class? I know this isn't how you normally use categories but sometimes I use them to break up the code into smaller chunks that aren't really separate classes (usually because they need access to the inner workings of the class). In this case the 'original' class may call a method in the category. This gives a warning (not the end of the world I know but I like to have no warnings) but the code works at runtime.

As to the Java bridge, how many people actually used it? Nearly everything I've ever seen said if you're using Cocoa use Objective-C don't use Java.

generik
Nov 17, 2005, 03:00 AM
Has anyone else been noticing that you need to go through more hoops to get the latest java SDK for MacOS?

robbieduncan
Nov 17, 2005, 05:01 AM
Was just wondering about categories. Is there any way to forward declare a method that's in a category but is called from the original class? I know this isn't how you normally use categories but sometimes I use them to break up the code into smaller chunks that aren't really separate classes (usually because they need access to the inner workings of the class). In this case the 'original' class may call a method in the category. This gives a warning (not the end of the world I know but I like to have no warnings) but the code works at runtime.

I'm not sure. It's obviously easily possible with no cross-calls.

I think this might work:
If you declare the main class with no methods at all like

<in MyObject.h>
@interface MyObject
{
}
@end


Then you can declare

<in MyObject+External.h>
#include "MyObject.h"
@interface MyObject(External)
-(void) externalMethod
@end

<in MyObject+Internal.h>
#include "MyObject.h"
@interface MyObject(Internal)
-(void) externalMethod
@end


Then of you can do something like this (not a good idea in practice)


<in MyObject+External.m>
#include "MyObject+External.h"
#include "MyObject+Internal.h"
@implementation MyObject(External)
-(void) externalMethod
{
[self internalMethod];
}
@end

<in MyObject+Internal.m>
#include "MyObject+External.h"
#include "MyObject+Internal.h"
@implementation MyObject(Internal)
-(void) internalMethod
{
[self externalMethod];
}
@end


Note I'm not on a machine where I can test that at the moment, it's just typed straight into the reply box, so may not work and may be full of errors!

hopejr
Nov 17, 2005, 05:34 AM
Was just wondering about categories. Is there any way to forward declare a method that's in a category but is called from the original class? I know this isn't how you normally use categories but sometimes I use them to break up the code into smaller chunks that aren't really separate classes (usually because they need access to the inner workings of the class). In this case the 'original' class may call a method in the category. This gives a warning (not the end of the world I know but I like to have no warnings) but the code works at runtime.

Yes you can. That's exactly what I did when I used the categories.

Wes
Nov 17, 2005, 06:01 AM
Has anyone else been noticing that you need to go through more hoops to get the latest java SDK for MacOS?
I'm having trouble with Java, my Jar files keep opening in 1.4.2 even though 5.0 is installed and I can't find anywhere to change that option. Java from the terminal still works with 1.4.2 :(

caveman_uk
Nov 17, 2005, 06:42 AM
Yes you can. That's exactly what I did when I used the categories.
How do you stop the warning messages though? robbieduncan's given a suggestion but that seems to be a bit complicated just to avoid a warning (sorry Robbie!). Is there a one liner a bit like the @class thing?

caveman_uk
Nov 17, 2005, 06:47 AM
Got it!

Just define an empty method with the same signature as the one you need to call in the base class. The definition in the category will override it - apparently. So...no warning but your method in the category gets called.

devman
Nov 17, 2005, 06:48 AM
I'm having trouble with Java, my Jar files keep opening in 1.4.2 even though 5.0 is installed and I can't find anywhere to change that option. Java from the terminal still works with 1.4.2 :(

http://forums.macrumors.com/showthread.php?p=1912890#post1912890

devman
Nov 17, 2005, 06:50 AM
I mean how hard could it have been to maintain it? The more cocoa bridges the better, because frankly Obj-C is a really annoying language to use, mainly because of the syntax. There are Python, Ruby, AS, C#, etc. bridges but now no Java bridge? I hope a third-party takes up this cause because Java is a great language to work with.

it was a mercy killing. move on.

robbieduncan
Nov 17, 2005, 07:25 AM
Got it!

Just define an empty method with the same signature as the one you need to call in the base class. The definition in the category will override it - apparently. So...no warning but your method in the category gets called.

That sounds a lot simpler (and therefore better) :D

caveman_uk
Nov 19, 2005, 04:18 AM
Got it!

Just define an empty method with the same signature as the one you need to call in the base class. The definition in the category will override it - apparently. So...no warning but your method in the category gets called.
Actually this doesn't work. The base class calls it's own method implementation. Maybe the overridding thing works if you're calling the method from outside the class.