Since the Palm OS is part of an embedded system, you would think (quite rightly) that C is the language of choice for most applications. The API is in C, the SDK targets C, and only C gives the optimized size and speed that many programs require. But the Palm OS is both powerful and popular enough to invite over a dozen dialects to the platform. Some non-C compilers generate native binary code (.PRC files) for installing directly to a handheld; others generate pseudocode and require the installation of a companion runtime. Either way, C certainly isnt the only game in town. Here are alternative languages available for the Palm OS:
- C++. If you prefer the object-oriented structures of C++, making the switch is simple. Most development environments that target the Palm OS, such as Metrowerks CodeWarrior, offer seamless C++ support. Even in the free development tools provided by Palm, switching to C++ is as easy as compiling with g++ instead of gcc. Deciding whether to switch is not so simple, however. Code bloat has always been an issue with C++, and given the tiny amount of storage on Palm OS devices, its even more of a concern. As an experiment, I once added a skeleton class to a 3 KB Palm program. When rebuilt with a C++ compiler, the executable ballooned to 19 KB. Reports from the Palm OS Programmers FAQ (<http://tangentsoft.net/palmfaq>) show programs quadrupling in size when rewritten using C++ templates. My advice: avoid C++ unless you truly need OOP for building custom classes and recycling them. Even then, you should be wary of the undersized heap on the Palm OS (184 KB or less on most devices). It can quickly become exhausted when allocating objects dynamically a common practice in C++.
- Java. For programmers who favor Java, or those who merely cringe at the thought of learning yet another API, you neednt abandon Suns language when targeting the Palm OS. The company has repackaged the Java core into a so-called Micro Edition known as the KVM (referring to a virtual machine whose size is measured in kilobytes). The KVM defines a standard called CLDC (Connected Limited Device Configuration). Simply put, this specification throws out large chunks of the Java API, paring down the VM (virtual machine) in order to run Java on cellular phones, point-of-sale terminals, and similar embedded systems with limited memory. The result is a VM that falls well short of Suns promise of Write Once, Run Anywhere. Floating-point types, for instance, are not allowed, and the garbage collection mechanism is primitive (defragmentation of the heap is not performed). Still, many of Javas advantages have been preserved: there is limited support for multithreading, and the data types, classes, and methods that remain in the KVM are identical to the original Java API. Though you may not be able to cut-and-paste Java code into the Palm OS, porting applets to a handheld should require much less effort than porting similar code written in C. (A case in point: Cs startup function main, the most basic part of any program, must be completely rewritten for the Palm OS.) Even when writing from scratch, the KVM provides a shorter learning curve for programmers already familiar with Java; they neednt learn the Palm OS API. The major dilemma with Java, like C++, is bloated code. Java programs for the Palm OS must piggyback on a VM that takes up anywhere from 40 KB to 350 KB, depending on how much of the Java API you need.
- BASIC. Although it predates C++ and Java, BASIC is still popular, and developers who prefer it wont be left out when they target the Palm OS. Several vendors offer BASIC compilers, yet none conforms to a single standard. Instead, each of these tools compiles its own version of a language similar to Microsoft VB (Visual Basic). Many of them, such as NS Basic, look and feel like clones of VB, and one (AppForge) is simply a Palm OS add-on for VB. Ideal for developers already experienced with VB, such products have the disadvantage of tying applications to a proprietary language.
- RAD tools. For corporate programmers in a hurry, a small selection of visual, forms-based development tools is available. Usually featuring a drag-and-drop atmosphere and a scripting language to tie user-interface elements together, these RAD (rapid application development) tools are great for linking code to databases. Kinectivity Studio, for instance, provides a companion server that synchronizes Palm OS applications to a back-end database, even wirelessly through the Internet if the hardware is available. Such tools work well for simple, pre-defined jobs, but they can hit a brick wall if your code needs to access the Palm OS directly or perform some special task unforeseen by the tools creator. Visit <http://palmos.com/dev/tech/tools> for a list of the most popular RAD products.
- Everything else. Forth, Pascal, Python, and, to a lesser degree, Scheme and Tcl, are all represented on the Palm OS. Perl is perhaps the only popular language not available for the platform. Palm-exclusive languages have also appeared, such as CASL and PocketC (a derivative of C that features a built-in string type), each with proprietary development environments and run-time libraries. With so many choices, developers are free to pick their poison.