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

Chapter 15. Development 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 machine-independent languages like Java (see Chapter 10) 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 elegeant, object-oriented langauge, 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 a programmer 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 envolved into the Cocoa frameworks we have today). Fortunately, Objective-C does not 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/ObjectiveC/.


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

However, the resulting Cocoa applications will not be Java applications! They'll run solely on Mac OS X, just like any other Cocoa program. Project Builder'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 10. 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/HomeLib/swing.properties file.

While Project Builder bends over backwards to accomodate 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 17) 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 glue and gopher between other existing applications. For example, an AppleScript application that comes with Developer Tools called Watson will use Apple's Mail application to search through all of your mailboxes for a user-specified string.

Historically, AppleScript programs run in their own environment, doing whatever they do and then quitting, without any fancy UI. Mac OS X's Developer Tools introduce AppleScript Studio, which allows your AppleScripts to hook into Cocoa interface APIs, turning them into full-fledged Aqua applications with interfaces that you can design with Interface Builder.

See Chapter 16 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 17); 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 23). 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 progamming language. Boasting a cleaner syntax and a sizeable support community of its own, Python proves an attractive alternative to Perl for many programmers.



Not a subscriber?

Start A Free Trial

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