1. Introduction to Mac OS X

“How do you describe Mac OS X? Batteries included!”

—Anonymous

Mac OS X is a Completely Redesigned implementation of the Macintosh operating system based on the BSD UNIX operating system. UNIX is an advanced multi-platform operating system that offers advanced features such as enhanced networking, high performance, and security. By focusing around the UNIX environment, the Macintosh now arguably becomes the most powerful consumer computer available today. It has so many built-in features now that you may well want for nothing more in an operating system. Simply, your Macintosh is still a Macintosh with the added benefit of being able to do anything that UNIX can do.

Figure 1.1. Terminal application in Mac OS X: Welcome to UNIX!

image

However, Apple didn't stop there. Not only is Mac OS X the most powerful Macintosh operating system to date, but it is also the most elegant by means of the Aqua user interface. Apple based the interface on the standard elements that Macintosh users expect and added many enhancements that make the user interface flow like nectar. Simply, the Aqua user interface is the most stylish ever created with its awesome three-dimensional widgets and drop shadows, as shown in Figure 1.2.

Figure 1.2. Aqua.

image

Mac OS X contains many pieces that make up this incredible puzzle we call our operating system. Let's look at them briefly with a quick explanation and real-world examples of how you might take advantage of the power they offer. Figure 1.3 shows how you might visualize the layers that make up Mac OS X.

Figure 1.3. The many pieces of X.

image

Darwin

Mac OS X's core OS layer, named Darwin, is based on version 4.4 of the FreeBSD (Berkeley Software Distribution) operating system. It therefore includes all the power, flexibility, and stability of that proven UNIX implementation. If that isn't enough, the Darwin source code is available as a free download from Apple, as shown in Figure 1.4. Apple also just recently released its own X11 implementation. It includes the full X11R6.6 technology, including a window server, libraries, and utilities.

Figure 1.4. Darwin Projects Directory where you can download all the Darwin source code.

image

Because the Darwin source code is available, not only can you study it, but you can also change it. You can fix any obscure bugs you might find or add new features. Apple even has a Web form that allows you to submit your modifications for evaluation and possible inclusion in future releases.

UNIX

For those of you not familiar, UNIX is a powerful, multiuser operating system that has been in use in various capacities since the 1970s. It was primarily intended for multiuser computing on servers. Apple has found a delicate balance and has been able to hide much of UNIX's complexity for the novice user while still making it 100% configurable for the geek and developer (see Figure 1.5).

Figure 1.5. Process Viewer lists current processes and resource usage.

image

Many different versions of UNIX are available including AT&T, BSD, Linux, and others. Some are free, whereas some are not. Mac OS X descends from the BSD-flavor of UNIX, which dates back to the mid-70s. At that time, the University of California at Berkeley licensed UNIX from AT&T and began to create its custom version, which became known as BSD. Because the BSD source code was available to all, Apple chose it as a base for Mac OS X.

If you've never used UNIX before, you are in for a real treat. UNIX servers are everywhere on the Internet and have a habit of acting like the Energizer Bunny; they just keep going and going. UNIX servers have some of the longest uptimes of any server on the Net. Given this penchant for few crashes and the fact that HTTP, FTP, TELNET, and SSH servers are all built into Mac OS X, you can be running and managing a high-powered network server in no time at all.

File Systems

Mac OS X supports compatibility with a number of file systems and protocols including the original Macintosh HFS, HFS+, FTP, UFS, NFS, ISO 9660, MS-DOS, SMB, AFP, UDF, and WebDAV. Not only can Mac OS X mount all these file systems, but it can also boot from many of them. Figure 1.6 shows Mac OS X connecting to a remote Windows File Sharing server.

Figure 1.6. Connecting to a Windows File Sharing server.

image

With the awesome support for numerous file systems, Mac OS X allows you to easily and quickly mount multiple file servers or shared directories on your desktop over the Internet. You can have your Windows machine at work mounted right next to your Mac iDisk and remote UNIX server—all at the same time. You can also make your own computer available to others as an SMB, FTP, or AFP server if you like—all at the same time. For developers, this is probably something you've been used to in the past in other environments; now it is finally a reality on the Macintosh without gobs of third-party programs.

Industry Standard Protocols

Mac OS X also supports a number of industry-standard network protocols including: TCP, UDP, PPP, PAP, HTTP, FTP, DNS, SLP, DHCP, BOOTP, LDAP, NTP, SOAP, and XML-RPC. The implementation of these protocols means that there are few, if any, limits to Mac OS X connectivity via the Internet. If you don't see it in Mac OS X, the odds are that it can be downloaded, built, and installed in just a few steps. Chapters 14, “XML-RPC,” and 15, “SOAP,” deal with network-based projects that pull data from a remote network server using HTTP, XML-RPC, and SOAP.

Figure 1.7. Network Utility helps keep things running smoothly.

image

With the plethora of preinstalled software with Mac OS X, you can quickly be running the Apache Web server with full secure connections and Perl or PHP CGI support. An FTP server is just a click away as well. The most common servers are very simple to get up and running and monitor, so no matter what your skill level, you can have a working Internet presence using only Mac OS X. This is a boon for Web-based software developers who need to be able to test their code in a real UNIX environment. Running Apache on your Macintosh desktop is a dream come true for Web developers.

Quartz

Quartz is a high-performance window server and a 2D graphical rendering library. It contains numerous advanced features to manage multiple windows throughout the system including buffering, compositing, and device-independent color. Its drawing library is based on the cross-platform PDF format made popular by Adobe. It provides simplified access to PDF data within an application (on the screen) and ultimately to hard copy (on paper).

Take the best of what you remember from QuickDraw, especially the CopyBits functionality, mix in some steroids and caffeine, and you have the makings of Quartz. The Quartz implementation offers many useful functions that handle everything from drawing detailed icons to anti-aliasing Bezier curves and making shadows a snap—and did we mention transparency? Quartz is an incredible advance in 2D drawing for the Macintosh that promises to not only make an application look better, but also make complex graphics easier for everyone to implement. Quartz Extreme, new with Jaguar (Mac OS X 10.2), takes these advances and makes them even faster!

Figure 1.8. The Mac OS X desktop, drawn by Quartz.

image

OpenGL

Mac OS X contains the industry-standard, cross-platform OpenGL library for 3D graphics. OpenGL is a set of high-performance drawing functions optimized for games, medical imaging, CAD/CAM, animation, and other high-end needs. Figure 1.9 shows iTunes drawing colorful animation to a frantic piece by Dizzy Gillespie.

Figure 1.9. Apple iTunes using OpenGL.

image

Need to write a game with full support for textures and 3D graphics? How about a screen saver that waves a colorful flag in the computerized wind? 3D images of the human body that rotate and allow zooming in, out and between individual cells? OpenGL allows all of this and more. The Mac OS X development tools come with a lot of cool OpenGL examples that are sure to make you want more. Sure, it'll make the fan in your PowerBook come on, but what do you expect?

QuickTime

QuickTime is Apple's original multimedia software allowing the recording, playback, and editing of digital movies, sound, animation, live streaming audio and video, and more. QuickTime makes use of a plug-in architecture to allow it to be expanded and enhanced as necessary to include support for new hardware and software. QuickTime supports a variety of platforms including all newer Macintosh and Windows operating systems. Figure 1.10 shows interactive QuickTime in action.

Figure 1.10. Apple QuickTime Player.

image

Whether you want to sit back and watch movie trailers, listen to music, or watch a streaming webcast, you can do it with QuickTime. For that matter, using the free iMovie software, you can even create your own QuickTime movies with music, sound, special effects, and titles. Once complete, it only takes a few minutes to upload your creation to a Web site and make it available to the world.

From a developers point of view, you can use the QuickTime frameworks to implement movie playback, editing, and recording from within your application. Your application can support digital video without ever having to write a driver for any video camera—by supporting QuickTime, you have access to everything else that supports QuickTime. QuickTime can also be a great way to implement simple animation in your application or game. The possibilities are endless.

Classic (OS 9)

The Classic environment is a full version of Mac OS 9.2 running within Mac OS X. Classic runs in a protected memory space and allows most Mac OS 9 compatible software to run side by side with Mac OS X software. Figure 1.11 shows a computer booted into Mac OS X but running Mac OS 9 software side by side with its newer cousins.

Figure 1.11. Classic software running within Mac OS X.

image

Apple has done a wonderful job at integrating the old with the new. Classic is really only made available to protect the software investment that users have made in the Macintosh. If you have a few old programs that only run under Mac OS 9, you can still run them under Mac OS X using the Classic environment. I wouldn't make a habit of it and try to get free of the clutches of Classic as soon as you can, but if you need the crutch, it's there. Developers, avoid writing pre-OS X software if you can.

Carbon

The Carbon APIs are based on pre-Mac OS X versions of the system software. These APIs allow developers to take advantage of many Mac OS X features, especially protected memory and preemptive multitasking, while still maintaining support for Mac OS 8.1 and later. The Carbon APIs bridge the gap for developers who have legacy software that they need to move toward Mac OS X. Figure 1.12 shows a Carbon application being developed in Project Builder, one of Apple's free developer tools. Chapters 5, “Carbon Plug-ins,” and 6, “Frameworks,” deal with Carbon-based projects.

Figure 1.12. Creating a Carbon application in Project Builder.

image

As a developer, you might be responsible for some Macintosh software that you wrote “back in the day” that simply is not ready for Mac OS X. By using the Carbon APIs, you can “Carbonize” your application so that it will still run under these previous OS's while also sporting the new Aqua look and feel under OS X and—most importantly—run under OS X as if it belonged! This saves your users from having to launch the Classic environment each time they want to run your application. I say it again: Developers, avoid writing pre-OS X software if you can.

Cocoa

The Cocoa application environment is the native Mac OS X development environment. It allows rapid application development by the use of tools such as Project Builder and Interface Builder. It also includes many frameworks that make it relatively simple to put together an entire application while writing only the code specific to the application. The Cocoa frameworks handle everything from window management to printing to network access.

Cocoa applications can be developed in either Objective-C or Java. All new application development should be done using Cocoa. You can also call the Carbon APIs from within a Cocoa application if necessary, which can prove very helpful. Figure 1.13 shows a Cocoa application being developed in Project Builder and Interface Builder—two of Apple's free developer tools. Many of the chapters in this book deal with Cocoa-based projects.

Figure 1.13. Creating a Cocoa application in Project Builder and Interface Builder.

image

The classes used throughout Cocoa development are broken up into two kits. The Application Kit (AppKit) framework contains mostly user interface and graphics oriented classes such as windows, buttons, menus, and drawing primitive classes. The Foundation framework contains mostly non-user interface type classes that pertain to data storage and manipulation or provide some sort of service such as scripting, networking, or messaging.

Cocoa is the future. Cocoa is based on the NEXTSTEP development environment and is simply a joy to use. Using Apple's built-in developer tools gives you a rapid application development environment that still gives you enough to sink your teeth into. This is not some poor attempt at a graphically integrated environment. This is a professional set of tools to create the next generation of killer apps! Embrace Cocoa and live a full life.

Java

Mac OS X users can also create 100% Pure Java applications and applets using the Java development environment. Mac OS X supports the Java 2 Standard Edition (J2SE) version 1.4. Write it once in Java, and it will run on a variety of platforms. Figure 1.14 shows the Java Web Start demonstration application that allows you to download and launch full-featured applications from within a Web browser.

Figure 1.14. Java Web Start.

image

Aqua

Aqua is the name for the Mac OS X user interface. Apple based the interface on the standard elements that Macintosh users expect and added many enhancements to help the novice and advanced user alike. Aqua is the most elegant user interface for any computer yet. Figure 1.15 shows a users home directory open on the Macintosh desktop, a hierarchical menu, and the System Preferences, as well as the dock at the bottom of the screen.

Figure 1.15. Aqua.

image

When you first start implementing applications for Mac OS X, it will take some getting used to in regard to following the new Aqua user interface guidelines. Whether you came from the Macintosh, UNIX, NeXT, or Windows worlds, things here are different. Take the time to read Apple's Human Interface Guidelines and practice them to give yourself and your users the best possible experience using your application. Aqua is a fun user interface to work with, and the Interface Builder application makes it a pleasure.

Software

Mac OS X comes with tons (if software can be measured by weight) of industry-standard software preinstalled. Try these on for size: Apache, Perl, PHP, sendmail. These programs and others like them essentially run the Internet. You can now have a complete Web server, email server, and DNS server running on your Macintosh serving files, streaming audio or video and database results to the world. Figure 1.16 shows some of the UNIX applications available on a default Mac OS X installation.

Figure 1.16. About 1/10th of the programs in /usr/bin.

image

Many utilities, command line and graphical, are included with Mac OS X. UNIX folks as well as Macintosh folks will all feel at home. If you're a GUI person, be sure to dip your toes into the world of the command line. Some things you can only do from the command line. Other things are just more fun to do from the command line. Some GUI applications that come with Mac OS X actually mimic or interface directly to the command line. Chapter 13, “Terminal,” shows you how to do this. Figure 1.17 shows some of the GUI applications available on a default Mac OS X installation.

Figure 1.17. Some of the native utilities packaged with Mac OS X.

image

Conclusion

As you can see, there are many new layers to Mac OS X. Don't plan on learning it all. There was a day when the entire Macintosh operating system fit on a 400K floppy disk. Those were the days when you could know it all. Today, 400K is about the size of some of the icons that represent the software that runs our computers. Don't be overwhelmed; it will come to you as you need it. Just keep exploring and gathering tidbits of information and make use of the excellent Web sites and newsgroups. Macintosh developers are a helpful lot, and you'll find excellent camaraderie with them.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.253.198