AddThis Social Bookmark Button

Listen Print

An Interview with the Authors of Learning Carbon

09/05/2001

Apple Computer recently teamed up with O'Reilly & Associates to publish books aimed at Macintosh developers and administrators. O'Reilly is working with Apple to produce titles on Mac OS X, Apple's new operating system--a move consistent with O'Reilly's commitment to the Open Source Movement. One of the first books to come out of this collaboration is Learning Carbon, which was written by a team of Apple writers and engineers. We asked the team at Apple to tell us about the Carbon application environment and how this technology will benefit developers.

O'Reilly: Mac OS X represents a revolutionary change in Apple's operating system. How does Carbon fit into Apple's new OS scheme?

Apple: Carbon is the evolution of the Mac OS API, from a single-user, cooperatively-scheduled system to a modern multi-user system with memory protection and preemptive multitasking in Mac OS X. Carbon was initially intended to help developers with existing Mac OS code or development experience quickly bring to market applications that take advantage of the performance, features, and reliability of Mac OS X.

O'Reilly: What percentage of the Mac OS APIs does Carbon support?

Apple: About 70 percent of the classic Mac OS APIs are fully supported in Carbon, and Carbon adds many new APIs specifically to take advantage of Mac OS X.

O'Reilly: Carbon seemed to be initially presented as an intermediate tool for developers working on porting applications to OS X, but recently it appears that Carbon is being repositioned as a stand-alone development environment, especially for developers who are not interested in using object-oriented programming languages. Which is it? Would it make sense to develop an application from scratch using Carbon?

Apple: The advantages Cocoa brings in providing a rich set of high-level application objects leads us to believe that most new application development for Mac OS X will happen in Cocoa. But there certainly are excellent reasons for considering Carbon as a starting point for a Mac OS X application, one of the most frequent reasons being language choice. If a developer chooses to use FORTRAN or Basic, for example, they must use the Carbon API set to do so.

Related Reading

Learning Carbon
By Apple Computer, Inc.


Read Online--Safari Search this book on Safari:
 

Code Fragments only

O'Reilly: What software development tools and languages can developers use when creating Carbon applications?

Apple: There are quite a few. Apple provides interfaces, compilers, and tools for Carbon programming in C and C++, while other languages, such as Basic and FORTRAN, are offered by other tool vendors. Developers can choose from a range of tools, including Metrowerks CodeWarrior, Real Software's REALbasic, Absoft Pro Fortran, and Apple's own IDE combination, Project Builder and Interface Builder. In addition, the two most popular object-oriented application frameworks for Macintosh are now Carbonized: MacApp (part of Apple's suite of C++ frameworks) and Metrowerks' PowerPlant.

O'Reilly: What is Carbon Dater, and how does it work?

Apple: Carbon Dater is a tool that helps developers determine the degree to which their classic Macintosh applications are compatible with Carbon. The Carbon Dater performs a static analysis of compiled PowerPC code by extracting information from PEF containers, and it uses MacPerl scripts to perform compatibility analysis and to generate a Carbon compatibility report.

Anyone can download Carbon Dater. Apple relies on the Web in this way to ensure that developers always get the most up-to-date porting information.

Apple then returns via email an HTML Carbon compatibility report. This customized document lists function calls and code usage that may need to be changed, along with suggestions about how to make such changes.

O'Reilly: Carbon applications get to take advantage of some of the most important aspects of Mac OS X, like protected memory and preemptive multitasking. What are the implications of these features for Macintosh applications?

Apple: Probably the biggest benefit of running a Carbon application in Mac OS X is increased reliability compared to Mac OS 8 or 9. Each application lives in its own address space in Mac OS X, which prevents an errant application from crashing the system or other applications.


To keep on top of all the latest developments in Mac OS X, visit O'Reilly's Mac DevCenter.


Another important feature is responsiveness. Each application on Mac OS X is guaranteed processing time, which results in a more responsive user experience.

Users will also appreciate Apple's new user interface, Aqua, which is available only to applications--such as Carbon applications--that run natively on Mac OS X. Aqua has the sharpest graphics ever seen on a personal computer, and it uses pulsing buttons, document-specific dialogs, and animated icons to make the user experience both more intuitive and fun.

The last major feature of Carbon-on-X is efficient resource handling. Mac OS X applications can allocate memory and other shared resources based on actual needs rather than on predetermined values, such as the fixed memory allocations in Mac OS 8 and 9.

O'Reilly: What are the roles of Project Builder and Interface Builder?

Apple: Project Builder is the native IDE on Mac OS X. It integrates well with the system and it knows how to deal properly with Java, Objective-C, C++, and other features of Mac OS X, such as the Mach-O executable format, bundles, and frameworks. Project Builder is great for developing Carbon applications, and provides robust support for Mach-O and the full Carbon API set. Project Builder will import CodeWarrior projects, allowing for an easy transition for existing Mac OS 9 developers who wish to move to Project Builder.

Interface Builder is the GUI design tool used with Mac OS X. It is primarily designed to create Cocoa applications and relies on some key features of Cocoa and Objective-C to do amazing things. However, Carbon developers can and should consider using Interface Builder to create the menus, windows, and dialogs they use in their applications. In cooperation with Interface Builder, the Carbon API set has been extended on Mac OS X to read 'nib' files and build Carbon interface elements.


We've expanded our publishing program at O'Reilly & Associates with books aimed at Macintosh developers and administrators, and we have recently released Learning Cocoa. To find out more information about Cocoa, read this oreilly.com Interview with the Authors.


O'Reilly: Explain the differences between the old "polling for events" model imposed by WaitNextEvent and the new Carbon Event model. Also, what does the Carbon Event Manager do?

Apple: With the classic Event Manager, the program repetitively requests events. When the Event Manager reports an event, the program dispatches the event to its event-handler routines. When there are no events for the program to handle, it yields. If there's an event for another application, it gets to execute. Otherwise, the yielding application gives other applications only a short period of time to execute background tasks. At the end of this yielding period, the yielding program resumes execution, and it again requests the classic Event Manager for events.

In the Carbon Event model, Mac OS X suspends a program's execution pending the arrival of an event for the program. This approach allows other programs and system processes to run in the meantime. Each time an event occurs that requires a program's attention, the Carbon Event Manager reports the event by calling the event handler, if any, that the program installed for that type of event. On return from the event handler, the program is suspended again while waiting for the next event.

So, a program that uses the classic Event Manager dissipates valuable processor time by continuously polling the Event Manager for events, even when there are no events for the program to handle. By comparison, a program that uses the Carbon Event Manager spends most of its time in a suspended state, using no processor time except to respond to events from the user, the system, or other programs.

O'Reilly: Learning Carbon is one of the first books to be released under the new publishing partnership between Apple and O'Reilly & Associates. Why did Apple choose O'Reilly to work with on OS X-related titles?

Apple: After a lot of consideration, we felt that O'Reilly's well-deserved reputation for publishing top quality developer books fit beautifully with our own standards, reputation, and philosophy. Also, O'Reilly is a well-respected name in many of the development areas that Mac OS X is quickly becoming associated with (such as BSD, open source, and Java). It seemed like a natural fit. We look forward to this book and the many other coming titles.


O'Reilly & Associates recently released (May 2001) Learning Carbon.