• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Chapter 15. Xcode Tools > Programming Languages

15.5. Programming Languages

As with every operating system, Mac OS X supports as many languages as it has compatible compilers.[2] Some are described in the following list. Its status as a Unix-flavored system, arguably the most flexible platform for programming, means that it already has a wide support base.

[2] Or compatible virtual machines, in the case of such machine-independent languages as Java (see Chapter 16) or Squeak (a Smalltalk-based programming environment found at http://www.squeak.org).


As C is to a "generic" Unix system, and as C++ is to Mac OS 9, one language lies closest to Mac OS X's heart, in terms of support and programming ease: Objective-C. This elegant, object-oriented language, which adds a handful of syntax rules onto plain-vanilla C, is the lingua franca of Cocoa development.

In order to better support legacy code, Mac OS X also supports strange notions such as Objective-C++, which allows you to invoke and work with C++ object classes from Objective-C code, and vice versa.

One important downside to Objective-C programming is the fact that most newcomers to Mac OS X programming have likely never used or even seen it before; in fact, it's hard to find any application of it outside of Mac OS X. The developers most likely to already know Objective-C are those who already have programming experience with NeXTSTEP (Mac OS X's predecessor, whose OpenStep libraries evolved into the Cocoa frameworks we have today). Fortunately, Objective-C doesn't present large barriers to entry; people with any programming experience can start down this path by reading The Objective-C Programming Language, a concise, excellent, and free book found in /Developer/Documentation/Cocoa/Conceptual/ObjectiveC/.


Java has a dual-faced nature on Mac OS X. Through the Java Bridge software that lurks among the system's Xcode Tools, programmers more familiar with Java than with Objective-C can use it to develop Cocoa applications through the Xcode environment; all the Cocoa and Foundation classes have Java APIs identical in spirit (if not in syntax) to their Objective-C interfaces. You can find these documented in the Java folders of /Developer/Documentation/Cocoa/Reference/ApplicationKit and /Developer/Documentation/Cocoa/Reference/Foundation, or by browsing class documentation in a Cocoa-Java project as described earlier in "Built-in Documentation."

However, the resulting Cocoa applications will not be Java applications! They'll run solely on Mac OS X, just like any other Cocoa program. Xcode's Java Bridge exists solely as a convenience for new developers who know Java but not Objective-C (a situation far more likely than the opposite). We recommend that Cocoa programmers who do know Java consider learning Objective-C anyway.

Mac OS X also supports pure Java applications, which really do run within the Java VM, as described in Chapter 16. The trade-off is that they don't really use Aqua interface; instead, they must provide a UI of their own. Fortunately, Mac OS X ships with an Aqua-like PLAF (pluggable look-and-feel) plug-in for Java Swing, and even makes it the default swing interface, as predefined in the /Library/Java/Home/lib/swing.properties file.

While Xcode bends over backwards to accommodate Java-Cocoa development, it can only do so much with pure Java programming; you can't use Interface Builder at all to help you create Swing UIs, for example. Pure Java developers may wish to also investigate Emacs (see Chapter 24) or third- party solutions such as the Java-based, open source NetBeans (http://www.netbeans.org).


This scripting language has been a part of Mac OS since System 7.1. It's a rich language tuned specifically to act as the glue between applications.

Historically, AppleScript programs run in their own environment, doing whatever they do and then quitting, without any fancy UI. Mac OS X's Xcode Tools lets you build Cocoa-based applications using AppleScript Studio, which allows your AppleScripts to hook into Cocoa interface APIs. See Chapter 14 for more information on AppleScript.


Perl is a powerful, general-purpose language with a special knack for text processing that can be used for either simple cross-application scripting, high-level object-oriented application development, CGI programming, and just about anything else. Unlike AppleScript or Objective-C, Perl speaks expressly to Mac OS X's Unix side, so you'll probably find Perl programming most comfortable in a text editor such as Emacs (see Chapter 24); Mac OS X includes two Emacs modes for editing Perl code (the simple perl-mode and the highly configurable cperl-mode).

While Mac OS X ships with Perl (out of necessity, since so much of the distribution depends on Perl to install and run correctly), it doesn't include any connection between it and Aqua; you can write only non-Aqua applications, such as Darwin-based Terminal applications or system daemons, or use Perl/Tk to make GUI programs if you have X Windows installed (as described in Chapter 26). However, the infant CamelBones project (found at http://camelbones.sourceforge.net) aims to bridge the worlds of Perl and Cocoa programming.


Python is another open source, Unix-grounded, all-purpose programming language. Boasting a cleaner syntax and a sizeable support community of its own, Python proves an attractive alternative to Perl for many programmers. With Panther, Apple has added Python bindings to Quartz, making it possible for Python scripts to make calls to the CoreGraphics libraries.



Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint