It really bothers me that Apple put an end to the Java-Cocoa bridge

Discussion in 'Mac Programming' started by jamdr, Nov 16, 2005.

  1. macrumors 6502a

    jamdr

    Joined:
    Jul 20, 2003
    Location:
    Bay Area
    #1
    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.
     
  2. macrumors 601

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #2
    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.
     
  3. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #3
    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.
     
  4. macrumors 6502

    Joined:
    Nov 10, 2005
    Location:
    New South Wales, Australia
    #4
    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.
     
  5. Guest

    caveman_uk

    Joined:
    Feb 17, 2003
    Location:
    Hitchin, Herts, UK
    #5
    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.
     
  6. macrumors 601

    generik

    Joined:
    Aug 5, 2005
    Location:
    Minitrue
    #6
    Has anyone else been noticing that you need to go through more hoops to get the latest java SDK for MacOS?
     
  7. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #7
    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
    Code:
    <in MyObject.h>
    @interface MyObject
    {
    }
    @end
    
    Then you can declare
    Code:
    <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)

    Code:
    <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!
     
  8. macrumors 6502

    Joined:
    Nov 10, 2005
    Location:
    New South Wales, Australia
    #8
    Yes you can. That's exactly what I did when I used the categories.
     
  9. Wes
    macrumors 68020

    Wes

    Joined:
    Jun 22, 2001
    Location:
    London
    #9
    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 :(
     
  10. Guest

    caveman_uk

    Joined:
    Feb 17, 2003
    Location:
    Hitchin, Herts, UK
    #10
    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?
     
  11. Guest

    caveman_uk

    Joined:
    Feb 17, 2003
    Location:
    Hitchin, Herts, UK
    #11
    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.
     
  12. macrumors 65816

    devman

    Joined:
    Apr 19, 2004
    Location:
    AU
    #12
  13. macrumors 65816

    devman

    Joined:
    Apr 19, 2004
    Location:
    AU
    #13
    it was a mercy killing. move on.
     
  14. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #14
    That sounds a lot simpler (and therefore better) :D
     
  15. Guest

    caveman_uk

    Joined:
    Feb 17, 2003
    Location:
    Hitchin, Herts, UK
    #15
    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.
     

Share This Page