Objective-C
Cocoa is implemented with Objective-C. Chapter 4, "Objective-C," describes Objective-C's object-oriented additions to the standard C language. This chapter provides information intended to help developers select a language to use with Cocoa. Some of the features of Objective-C not shared by the other languages used with Cocoa are presented here to aid the comparison of languages. The details are not presented until Chapter 4.
Categories
Categories are an Objective-C feature that enables the specialization of classes without using inheritance. Categories can be used to add behaviors to existing classes without recompiling them. The instances of specialized classes gain the new behaviors. Even pre-existing instances and instances created and used entirely within the implementations of Cocoa classes gain the new behaviors. Categories and their many advantages are used and described throughout this book. Chapter 26, "Application Requirements, Design, and Documentation," includes detailed analysis of the use of categories when designing an application.
Protocols
Objective-C protocols are similar to Java interfaces. Protocols specify the behaviors provided by objects independent of the class of the objects. Cocoa contains many protocols.
Perform
Objective-C objects can be asked to invoke behaviors in a dynamic way. For example, a program can accept input from a user that specifies a behavior to invoke in a running application. The capability to ask an object to invoke a behavior without the aid of a compiler contributes to the integration of Cocoa with scripting languages.
Posing
Posing is the capability to universally substitute one class for another. Every time an attempt is made to create an instance of a class, an instance of the posing class is created instead. Posing classes even work with compiled libraries such as Cocoa. If a Cocoa application includes an object that poses as a Cocoa object, the posing class is used instead of the original class in every case. Posing is a feature of Objective-C that conflicts with Java's security features and should not be used in Java Cocoa applications.
Runtime
Objective-C includes a runtime system similar in many ways to the Java Virtual Machine. Objective-C's runtime provides many of the dynamic features of Objective-C and enables the dynamic loading of Objective-C objects. Unlike the JVM, Objective-C's runtime is small and does not provide cross-platform support or security features. Objective-C's runtime is written in standard C and can be used from C or C++ programs even if those programs are not compiled with an Objective-C or Objective-C++ compiler.