Wednesday, November 15, 2006

Quartz, Classic/Carbon/Cocoa, and Aqua

Names like "Quartz", "Carbon" and "Aqua" get thrown around a lot when people talk about OS X, and it takes some digging to figure out what they mean. (Especially since they're often used loosely or even inaccurately.) In this post, I'll try to disentangle the semantic mess and draw parallels between the OS X graphics system and the X graphics system used on most Linux desktops.

I'll start with a diagram showing the two graphics stacks side-by-side:


 OS XLinux
Window ManagerAquatwm,mwm,kwin,sawfish,enlightenment,fvwm,etc...
ToolkitsClassic, Carbon, CocoaMotif, Qt, gtk, etc...
Display ServerQuartzX11
Non-graphical CoreDarwinLinux kernel + libs + non-graphical programs


Quartz sits at the base of the graphical stack, corresponding to the role of the X server on a Linux desktop, where it handles the drawing of graphics primitives on the display. Quartz is the descendant of the Display Postscript system used in the NeXT operating system. Instead of Postscript, though, Quartz internally represents graphical elements as PDF. Graphics entities are represented inside Quartz as high-level, scalable abstractions which can be zoomed, rotated, stretched, drop-shadowed or otherwise manipulated dynamically as they are rendered to the screen. Applications built on top of Quartz inherit these capabilities for free. This is very different from the X server world, where primitives are drawn as raster images, and any more sophisticated manipulations have to be done at higher levels in the graphics stack.

Sitting on top of Quartz are several APIs. The "Classic" API allows backward-compatibility with OS 9 applications. The "Carbon" API is a new interface allowing programmers to take better advantage of the capabilities of Quartz. "Cocoa" is an object-oriented API, also developed for use with Quartz. Classic/Carbon/Cocoa correspond roughly with the various tookits used for writing X applications.

Finally, Aqua is a user interface sitting at the top of the stack. It implements window decorations and allows the user to manipulate entities on the graphical display through the keyboard and mouse. It corresponds to the window manager in a typical Linux desktop configuration.

For much more information, see this excellent article by John Siracusa at Ars Technica.

No comments: