Chapter 1. Introduction to Carbon

The element carbon is an essential building block for life on earth. For C programmers, Apple’s Carbon is the essential building block for applications on Mac OS X. With Carbon, you not only gain the benefits of Mac OS X, but you do so while using some of the simplest traditional C interfaces available. This combination makes it easier than ever to create world-class applications for a world-class operating system.

Carbon and Mac OS X

Carbon is the collection of C programming interfaces for Mac OS X, Apple’s next-generation operating system.

Note

A programming interface is the set of functions and data structures defined by one piece of software, such as an operating system service, for use by client software, such as applications and device drivers. For example, you would access one programming interface to enable your application to print and another to manipulate your application’s menus.

Carbon was originally designed to support the evolution of the Mac OS. Apple updated and reimplemented programming interfaces written for earlier versions of the Mac OS to take advantage of new features and enhancements in Mac OS X. Mac OS X brings many modern operating-system features to the Macintosh, including:

  • Protected memory. Each application lives in its own address space, which prevents errant applications from crashing the system or other applications.

  • Preemptive multitasking. Each application is guaranteed processing time, resulting in a more responsive user experience.

  • Dynamic resource allocation. Your application can allocate memory and other shared resources based on actual needs rather than predetermined values, such as fixed memory allocations.

  • Aqua look and feel. Apple’s new user interface is available only to applications that run natively on Mac OS X. Aqua provides a feast of visual effects—active buttons pulse, icons dance, windows spring to life—and showcases the sharpest graphics ever seen on a personal computer.

Note

Carbon is especially useful for developers who need to update older Mac OS code to run on Mac OS X. This book doesn’t cover this porting process, but if you’re interested, see Inside Carbon: Carbon Porting Guide (listed in Appendix A).

In addition to updating older features, Mac OS X adopts some industry-standard practices and introduces brand new technologies. To support these features for C-language programmers, Apple added new programming interfaces to the venerable Mac OS. The collection of updated and new programming interfaces is called Carbon.

As shown in Figure 1.1 Carbon is one of several application environments available on Mac OS X.

Carbon in relation to other Mac OS X environments

Figure 1-1. Carbon in relation to other Mac OS X environments

These other environments include:

  • Cocoa. The object-oriented interface for writing Mac OS X applications in Objective-C or Java

  • Classic. A compatibility environment for applications written for systems prior to Mac OS X. These applications do not gain all the advantages of Mac OS X

  • Java. A JDK-compliant virtual machine for running pure Java applications

These environments depend on the same application and core services for their operation, and the underlying services rely on Darwin (Apple’s open-source core operating system) and the Mach kernel.

Each environment (including the optional BSD command-line environment) has advantages and disadvantages, but for C and C++ programmers, Carbon is the best choice.

Get Learning Carbon now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.