Re: Java or Objective-C for Cocoa?
Re: Java or Objective-C for Cocoa?
- Subject: Re: Java or Objective-C for Cocoa?
- From: "M. Uli Kusterer" <email@hidden>
- Date: Fri, 2 Apr 2004 15:13:28 +0200
At 12:43 Uhr +0200 02.04.2004, Claus Atzenbeck wrote:
I can see that learning Java would be cool, because I also would be able
to develop platform independent apps as well.
Claus,
well, my personal grudges against Java aside (I know it, and I use
it regularly, but I just don't like it), you will obviously not
really write cross-platform code if you use Cocoa-Java (okay, there's
GNUstep if you're really desperate). You'd have to use Swing/AWT, not
Cocoa (I know you know, it's just for anyone coming across this in
the archives).
If you use Cocoa-Java, the portability will be the same as with
Cocoa-ObjC. The C code will port over just fine, and you will have to
rewrite the Cocoa code just the same.
On the other side, I have
heard that Objective-C might be the better choice for Cocoa, especially
for heavy graphical stuff. Is there really a big difference?
Well, first and foremost, most (decent) books and documentation on
Cocoa are for Objective C. There are some people using Cocoa-Java
here, but whenever they've asked a question here, there were few
people around who could give Cocoa-Java-specific help. IMHO you'll
make it easier on yourself if you use ObjC. Especially considering
the framework was originally designed for ObjC.
Second, ObjC is a real compiled language. No matter how fast the JVM
gets, it still has an additional level of indirection between itself
and the hardware. If you're doing speed-critical stuff, you'll be
faster going with ObjC's compiled code. Okay, the dynamic dispatch
parts are probably not much different from Java's (both are heavily
optimized), but ObjC lets you mix regular C code in with the rest
much more easily and without the JNI overhead.
Third, if you want to do high-performance graphics, you may want to
use OpenGL. While its lines aren't quite as pretty as the stuff
Quartz generates, if most of what you're doing is image scaling,
OpenGL will let you get rid of a lot of clever code in Quartz you
won't need in that case. OpenGL is basically a C API, easily called
from ObjC. It may not be that easy with Java (though I vaguely recall
hearing about Java3D...?).
Fourth, ObjC is a much more simple and compact language than Java or
C++. It is simply C with a handful of new constructs, and you need
about three of them to get started with Cocoa.
Any recommendation for good beginners tutorials for Java/Objective-C and
Cocoa? Would be nice if those would be free for download and easy to
print (one PDF rather than many HTML pages), like Apple's "The
Objective-C Programming Language".
If you want free, people keep telling me the "Vermont Recipes" were
very good. However, I bought Aaron Hillegass' book on Cocoa
programming, which is very good in teaching you the basics of Cocoa.
Got me started in a weekend (I know, I keep repeating that ... but
after taking months to get through Effective C++ and the likes, I'm
still surprised).
Hillegass doesn't really go into the ObjC language details that
much, though. You should already know C, and a general knowledge of
an Object-Oriented language is definitely helpful as well. To fill
out the remaining gaps, Apple's ObjC PDF will do just fine (though it
*is* horribly dry).
Now, before it seems as if Cocoa-ObjC was perfect, there are a few
things to watch out for:
- It uses reference-counting as its memory management scheme. The
rules are very simple, and it has a more effective use of memory than
most garbage collectors, but as with all manual memory management,
it's easy to make errors you won't notice until four function calls
later.
- The most annoying weakness of Cocoa is its terseness when it comes
to reporting errors. Most of the time it simply tells you an
operation failed, with no indication why. This is aggravated by the
fact that ObjC allows sending messages to NULL, which will simply
fail silently. So, you will often find something just not happening.
Sometimes the docs help, often they don't. But that's a problem
you'll partially have with Java as well...
Choose wisely ;-)
--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.