Hot Chocolate
Volume Number: 16
Issue Number: 5
Column Tag: Mac OS X Development
Hot Chocolate!
By John Hörnkvist
An Introduction to Cocoa
Introduction
Mac OS X is Apple's great gamble for the future. It does away with almost two decades
worth of heritage, and brings advances such as preemptive multitasking, virtual
memory and memory protection to the Macintosh. The transition, however, requires
that developers port their applications to one of two new APIs; Carbon or Cocoa. While
Carbon is clearly the basic element in Apple's plan for bringing existing Mac OS
applications to the new operating system, Cocoa offers great opportunities for
developers that bring new applications to the market, and to those that are to rewrite
from a clean slate. In this article, I will describe what Cocoa is, and how you can take
advantage of it.
Apple has repeatedly pointed out that you can write Cocoa applications in either
Objective-C or Java. However, Cocoa itself is an Objective-C system, and you'll
probably enjoy more of its benefits if you use Objective-C yourself. Therefore, all
code examples in this article will be in Objective-C.
Heritage
Cocoa is the latest name for the object oriented software frameworks and technoligies
Apple received in the NeXT takeover. In previous incarnations, the technology has been
know as YellowBox, OpenStep and NEXTSTEP - and until now, the largest step by far
happened in the transition from NEXTSTEP to OpenStep.
The greatest difference between Cocoa and its predecessor is the replacement of
Display Postscript by Quartz. While DPS was a very powerful graphics engine, it was
a client server system, and an interpreted language, which combined to make life
difficult for the performance oriented developer - it was possible to get excellent
performance out of DPS, but it required an intimate understanding of the graphics
pipeline[1]. With Quartz, graphics display has been moved to a shared memory model,
making graphics programming as convenient as the rest of Cocoa - at the cost of
making remote display "a third party opportunity".
Cocoa has also gained many important components since Apple took over, such as the
document architecture and scriptability.
Cocoa is the latest name for the object oriented software frameworks and technoligies
Apple received in the NeXT takeover. In previous incarnations, the technology has been
know as YellowBox, OpenStep and NEXTSTEP - and until now, the largest step by far
happened in the transition from NEXTSTEP to OpenStep.
The greatest difference between Cocoa and its predecessor is the replacement of
Display Postscript by Quartz. While DPS was a very powerful graphics engine, it was
a client server system, and an interpreted language, which combined to make life
difficult for the performance oriented developer - it was possible to get excellent
performance out of DPS, but it required an intimate understanding of the graphics
pipeline[1]. With Quartz, graphics display has been moved to a shared memory model,
making graphics programming as convenient as the rest of Cocoa - at the cost of
making remote display "a third party opportunity".
Cocoa has also gained many important components since Apple took over, such as the
document architecture and scriptability.
The Objective-C Language
Objective-C is the brain child of Brad J. Cox, and the result of his worries about the
difference in productivity between the hardware and software industries. In the early
eighties, he noticed that software development productivity was on a worrying growth
curve, and predicted a software crisis if development methodologies did not change. Dr.
Cox attributed the difference between hardware and software industries to the fact that
the hardware industry used components, such as integrated circuits, ICs, in their
designs, and created new components only when necessary. The software industry, at
the time using C or Pascal, lacked the component based approach to development, and
Dr. Cox set out to change that.
The result of Cox's work was Objective-C, a dynamic object oriented language in the
Smalltalk tradition, but built on C. Objective-C allows you to use "software ICs", using