Suffice it to say, Java and Objective-C are both great languages and
each have strengths. Objective-C had features which were copied into
Java (Protocols==Interface) yet Objective-C also has the benefits of
a more dynamic language passing around references of id. That is
incredibly powerful for building GUI applications. Another powerful
feature is delegates. Although it was written long ago, Objective-C
is a well thought out language and offers unique capabilities like
Categories that allow alternatives to subclassing. Java, like
Objective-C was also based on C. Ironically Java has been adding in
functionality similar to that in Objective-C in recent releases....
so I think Objective-C was actually ahead of it's time. The reverse
also appears to be happening. From Apple's Leopard XCode page, they
describe garbage collection being added. For me, that's been the one
difficulty with C-based languages, although Obj-C's retain/release
system is fundamentally how Java works, the only difference being
that the runtime handles that automatically in Java instead of the
developer in Obj-C... at least for now.
For any Java developers considering Cocoa, Objective-C is really easy
to learn. I picked it up rather quickly, the only difficulty coming
from Java is the need for manual memory management & that was
probably the primary reason for Cocoa-Java. I've also come to really
appreciate the syntax for code readability. Consider these snippets
with really badly named variables:
Java:
public void configureObject(MyObject pArg1, String pArg2, String
pArg3, int pArg4) {
//Set the object's name, description and repeat count
}
Objective-C
-(void) configureObject:(MyObject *)arg1 withName:(NSString*)arg2
description(NSString*)arg3 repeatCount:(int)arg4
{
//Set the object's name, description and repeat count
}
With Obj-C poorly named variable names don't prevent code
readability. With Java (and plain old C on which the Java syntax was
based) calling the method doesn't make it clear what each argument is
for, so you're constantly having to look at the docs. With Obj-C's
syntax, the purpose of each argument can be very clear. The runtime
features are also great, since messages to nil objects don't throw
NullPointerExceptions as they do in Java, which means you don't have
to put in if(obj!=null) checking code everywhere. Also you can send
any message (method) to any object. If it has the method, it runs
it, otherwise it ignores it like other dynamic languages. Java added
functionality to allow for more dynamic calls with reflection, but
that's still a pain to use. With Objective-C if it doesn't directly
handle a message, it can have a delegate object handle the message.
The responder chain is probably the most powerful feature of the
AppKit & it relies on message capabilities of Objective-C to do
that. So while Java has been adding features that get close to Obj-C
in the past few releases, Objective-C has had them for almost twenty
years. Java's biggest advantage is garbage collection & cross-
platform binary support. Since Cocoa is already based on Objective-C
and it really is a powerful, albeit not popular language, it makes
sense for Apple to deprecate Cocoa-Java & not bother re-implementing
Cocoa in another language, but perhaps extend Objective-C much like
Java has continued to be extended. As long as Java is still fully
supported on OS X, I'm fine with using Obj-C for Mac-only apps so I
can leverage Cocoa, just like I could use C# on Windows for the same
purpose.
Niels
On Aug 23, 2006, at 9:32 AM, Wagner Truppel wrote:
Elliotte Rusty Harold wrote:
But it's not 1987. It's 20 years later. Given the lack of legacy
code in Objective C and the few programmers who know it, wouldn't
it have made sense for Apple to choose a more modern language for
their platform? One that had learned from the mistakes of C, C++,
and Objective C?
If Apple had chosen to go with C++, then I would have understood
their reasoning. They were choosing familiarity over perfection.
However since they chose a language almost everyone was going to
have to learn for the first time anyway, they could have made a
much better choice than Objective C.
Cocoa is really an outgrowth of NeXTStep (and that's why many of
the Cocoa classes start with NS).
Recall that Apple bought Jobs' NeXTStep company in Feb 1997 and
that Jobs became Apple's interim CEO only a few months later, at a
time when Apple was not doing so well due to Amelio's abysmal
performance as CEO (Apple had missed beating Windows 95 to the
market, and Copland was a big failure).
Thus, Apple had already invested quite some money into NS when it
was in a dire financial situation and, so, from a purely financial
standpoint, it makes sense that Apple would choose to stick to Obj-
C rather than spend time and money re-writing all their NS code in
a new language.
That, I believe, is the ultimate reason why they did so, not how
great Obj-C's runtime model is (which is what I keep hearing,
despite the fact that (I believe) all of Cocoa could very well be
written in Java or some other similarly modern language).
I think Apple is now doing sufficiently well financially that they
could afford to start a parallel project to re-write all of Cocoa
using a more modern language, perhaps Java or perhaps a language of
their own design (incorporating the best of all previous efforts).
I think it would ensure a larger developer base and, in the long
run, benefit the company.
I can't be totally wrong about that since Apple has announced Obj-C
2.0...
Wagner
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden