pietrop.com Rotating Header Image

Cocoa: what is it?

Here’s an extract from Cocoa programming for Mac OS X, third edition, wrote by Aaron Hillegass. It explains in a clear way the story of Cocoa and its related world.

The story of Cocoa starts with a delightful bit of history. Once upon a time, two guys named Steve started a company called Apple Computer in their garage.

The company grew rapidly, so they hired an experienced executive named John Sculley to be its CEO. After a few conflicts, John Sculley moved Steve Jobs to a position in which he had no control over the company at all. Steve Jobs left to form another computer company, called NeXT Computer.

NeXT hired a small team of brilliant engineers. This small team developed a computer, an operating system, a printer, a factory, and a set of development tools. Each piece was years ahead of competing technologies, and the masses were excited and amazed. Unfortunately, the excited masses did no buy either the computer or the printer. In 1993, the factory was closed, and NeXT Computer, Inc., became NeXT Software, Inc.

The operating system and the development tools continued to sell under the name NeXTSTEP. Although the average computer user had never heard of NEXTSTEP, it was very popular with scientists, investment banks, and intelligence agencies. These were people who developed new applications every week, and they found that NeXTSTEP enabled them to implement their ideas more quickly than any other technology did.

What was this operating system? NeXT decided to use Unix as the core of NeXTSTEP, relying on the source code for BSD Unix from the University of California at Berkeley. Whi Unix? Unix crashe much less frequently than Microsoft Windows or Mac OS and came with powerful, reliable networking capabilities.

Apple has made the source code to the Unix part of Mac OS X available under the name Darwin. A community of developers continues to work to improve Darwin. You can learn more about Darwin at http://macosforge.org/.

NeXT then wrote a window server for the operating system. A windows server takes events from the user and forwards them to the applications. The application then sends drawing commands back to the windows server to update what the user sees. One of the nifty things about the NeXT window server is that the drawing code that goes to the window server is the same drawing code that would be sent to the printer. Thus, a programmer has to write the drawing code only once, and it  can the be used for display on the screen or printing. In the NeXTSTEP days, programmers were writing code that generated PostScript. Whit Mac OS X, programmers are writing code that uses the CoreGraphics framework (also known as Quartz). Quartz can composite those graphics onto the screen, send them to the printer, or generate PDF data. The Portable Document Format is an open standard created by the Adobe Corporation for vector graphics.

[...]

NeXTSTEP came with a set of libraries and tools to enable programmers to deal with the windows manager in a elegant manner. The libraries were called frameworks. In 1993, the frameworks and tools were revised and renamed OpenStep, which was itself later renamed Cocoa.

[...]

Programming with the frameworks is done in a language called Objective-C. Like C++, Objective-C is an extension to the C programming language, making it object oriented. Unlike C++, Objective-C is weakly typed and extremely powerful.
With power comes responsibility: Objective-C allows programmers to make ridiculous errors. Objective-C is a very simple addition to C, and you will find it very easy to learn.

Programmers loved OpenStep. It enabled them to experiment more easily with new ideas. In fact, Tim Berners-Lee developed the first Web browser and the first Web server on NeXTSTEP. Securities analysts could code and test new financial models much more quickly. Colleges could develop the applications that made their research possibile. I don’t know what the intelligence community was using it for, but intelligence aggencies bought thousands of copies of OpenStep. Because they were so useful, the OpenStep development tools were ported to Solaris, Windows NT, and the NeXTSTEP operating system was ported to most of the popular CPUs of the day: Intel, Motorola, Hewlett-Packard’s PA-RISC, and SPARC. (Oddly enough, OpenStep didn’t run on a Mac untile the first version of Mac OS X Server, known as Rhapsody, shipped in 1999.)

For many years, Apple Computer had been working to develop an operating system with many of the features of NeXTSTEP. This effort was knows as Copland. Project Copland gradually spun out of control, and Apple finally decided to pull the plug and buy the next version of Mac OS from another company. After surveying the existing operating systems, Apple selected NeXTSTEP. Because NeXT was small, Apple simply bought the whole company in December 1996.

Where do I fit into this story? I was writing code for NeXT computers on Wall Street until NeXT hired me to teach OpenStep programming to other developers. I was an employee at NeXT when it merged with Apple, and I taught many of the Apple engineers how to write applications for Mac OS X. No longer an Apple employee, I now teach Cocoa programming for Big Nerd Ranch, Inc.

NeXTSTEP became Mac OS X. It is Unix underneath, and you can get all the standard Unix programs, such as the Apache Web server, on Mac OS X, which is more stable than Windows and Mac OS 9. The user interface is spectacular. You, the developer, are going to love Mac OS X because Cococa will enable you to write full-featured applications in a radically more efficient and elegant manner.

I hope it will let you know what makes Mac OS X applications look so beautiful and useful.

It’s wonderful programming using Cocoa, and if you want to enter the Cocoa’s world I suggest you this good manual.

Leave a Reply