Important: The Java API for Cocoa is deprecated in Mac OS X version 10.4 and later. You should use the Objective-C API instead. For a tutorial on using Cocoa with Objective-C, see Cocoa Application Tutorial.
The Objective-C language is based on the C language, which has a very simple syntax. The Java language borrows heavily from C’s syntax; therefore, it should be easy for Java programmers to familiarize themselves with the syntax used in Objective-C.
These are some of the salient differences between Java and Objective-C:
Java source files are compiled into bytecode object files and archives that can be used in more than one platform. Objective-C source files are compiled into machine-language object files. These files contain code tailored to a specific platform. Therefore, to build an Objective-C program targeted at more than one platform, each source file must be compiled once for each of the targeted platforms.
C uses header files. Header files declare the interface that a module’s client uses to interact with the corresponding implementation (a set of object files or libraries). The separation of public interface from implementation allows developers to conceive and release the interface to a module before implementing it. Objective-C maintains this separation.
Like C, Objective-C has no automatic garbage collection. You must explicitly release the memory occupied by unused objects. Fortunately, Cocoa provides a mechanism you can use to facilitate this task. See “Learn Memory Management in Cocoa” for details.
Objective-C is a late-binding language. That is, the compiler doesn’t bind method invocations to the corresponding implementations at compile time. Instead, the Objective-C runtime binds method invocations to the appropriate implementation at runtime. This eliminates the need to cast objects to the type that implements a particular method and allows the development of generic code.
For an in-depth discussion of Objective-C, see The Objective-C 2.0 Programming Language.
Last updated: 2006-10-03