Mobility

Introduction to Palm programming

Learn more about developing software for the popular Palm-compatible handheld computer. This article gives the lowdown on how you can get started, with a look at some of the more popular Palm development tools available.


Handheld computers are becoming increasingly common, and as their popularity grows, they’re becoming more powerful as well. Developing for the Palm platform—the current standard—is somewhat similar to developing for a desktop system. There are enough differences, however, to make this a difficult task for the unprepared. In this article, we’ll take a look at some of these differences and briefly discuss some popular tools available for developing applications for the Palm OS.

Code small
Today’s Palms are roughly as powerful as desktop computers from 15 years ago—which is, relatively speaking, not very powerful at all. The top-of-the-line models have 8 MB of storage; most have less. The typical CPU speed is 16 MHz and the largest code segment and memory allocation size is 32 KB. Applications and their data are typically limited to a maximum size of 1 MB. But regardless of such draconian limitations, users have come to expect fast, responsive applications and minimal waits for processing.

All of this means that Palm applications must be small, quick, and lightweight. Programmers should always be aware of their application’s memory usage and use the smallest variables possible. It also means that those miniscule performance differences between programming constructs—a For loop versus a While loop, for example—can suddenly become very important.

In principle, programming the Palm OS is similar to programming any other modern, windowed operating system. The OS communicates with applications via a simplified event model, manages memory allocation, and swaps applications in and out of execution space as they become active or inactive. The system’s API is exposed as a set of C Libraries that are loaded into an application’s address space.

User interface considerations
A Palm OS application’s user interface is built from a standard set of widgets: buttons, edit boxes, list boxes, menus, and so on. While this means that the same commonsense UI guidelines for desktops usually apply to handheld applications, some special considerations do exist:
  • A handheld’s display is much smaller—typically 6 cm by 6 cm (160 pixels wide) for Palm devices—and, for the most part, monochrome. This is the only resolution setting supported, and it’s not a lot of real estate to work with.
  • Users of handhelds are often moving, poking at the screen with a stylus and working in less-than-optimal lighting. Where possible, UI elements should be large, high contrast, and clearly labeled. A balance must be struck between this consideration and the size constraints of the display.
  • For the most part, handheld users do not use keyboards. Data entry is instead done with the stylus. Consequently, there should be very little data entry required for your app. Where data entry is required, try to supply the user with alternatives to entering text: option groups, combo boxes, and the like.

As a general rule, the Palm’s built-in applications are very good UI examples. They minimize scrolling, make the application’s data fit the screen, and make the important assumption that theuser is going to maintain most of the data on the desktop; the handheld is typically used for reference. This assumption is fundamental to handheld application development and leads us neatly to our final special consideration: communication with the desktop.

Conduits: Sharing data with the desktop
The easiest way to get your data onto the desktop is to get Palm OS to do it for you at every HotSync. A default conduit is provided that backs up any database marked as needing backup via the DmSetDatabaseInfo API function.

The other alternative is to program a custom conduit to handle transferring your data and dealing with any contention or conflicts. Palm offers a Conduit Development Kit (CDK) for the creation of custom conduits for use on Windows or Macintosh desktops. Previously, conduit development required knowledge of C++, but version 4.01 of the CDK includes COM support, allowing conduits to be built using any COM-aware language. As we’ll see in the next section, some tool vendors provide their own alternatives to the CDK.

Development tools
A wide variety of tools and languages are available for developing Palm OS applications. The more popular tools include Palm OS-optimized C compilers, Java and Basic interpreters, and higher-level visual RAD tools.

C has a reputation for delivering small, lightweight, fast code, making it ideal for Palm OS programming. Two good options for C Palm OS development are PRC-Tools and Metrowerks CodeWarrior for Palm OS. Both packages include resource editors, debuggers, and Palm emulators. PRC-Tools is a GCC-based solution freely available for most operating systems. CodeWarrior, the “official” Palm development tool and my personal favorite, is a popular Macintosh IDE ported to Linux and Windows featuring project templates and on-the-device debugging. Be forewarned, however: Unless you’re used to Macintosh GUI standards, CodeWarrior’s UI can be, well, funky.

Java was designed from the beginning for cross-platform applications, so it naturally has a presence on the Palm OS. Sun’s KVM is a low-memory Java virtual machine designed to operate with the Java 2 Platform, Micro Edition. Combined with its native libraries, KVM requires a minimum of approximately 80 KB of memory, making it an excellent choice for Palm OS development.

CASL (pronounced castle) is a language syntactically similar to Visual Basic. Virtual machines currently exist for Windows and Palm OS, and one is in development for Windows CE, making CASL an attractive cross-platform alternative to Java.

Several high-level RAD tools also exist. Two of the more popular are PumaTech’s Satellite Forms and Pendragon Software’s Pendragon Forms. Satellite Forms is a powerful Visual Basic-like RAD environment featuring a dBase 5-compatible database format on the desktop, a VB-like scripting language, and an ActiveX control for conduit programming. Pendragon Forms is a higher-level form design tool that uses a programming model similar to Access macros or Dreamweaver behaviors. Pendragon Forms also features a comma-delimited file upload for getting data from the handheld to the desktop.

Something for everyone
As you’ve seen, developing applications for a Palm OS handheld is similar to developing for its desktop cousin. Still, downsizing can be difficult. Developers comfortable with C will have an easier time making the switch than those attempting to transfer other skills. However, there are a variety of tools that allow developers to use whichever paradigm and language they know best.

Editor's Picks

Free Newsletters, In your Inbox