Skip to main content

skip to main content

developerWorks  >  Linux | Open source  >

PalmOS-hosted programming languages

Using the Palm as a development environment

developerWorks
Document options

Document options requiring JavaScript are not displayed


Rate this page

Help us improve this content


Level: Introductory

David Mertz (mertz@gnosis.cx), Freelance writer, Gnosis Software, Inc.
Andrew Blais (onlymice@gnosis.cx), Researcher and writer, Gnosis Software, Inc.

01 Aug 2001

Most people who think of developing PalmOS applications probably imagine writing C/C++ code on a desktop, then cross-compiling to the PalmOS. There is a completely different approach to PalmOS development. Authors David Mertz and Andrew Blais take a look at complete programming language and development environment products that can run entirely on a Palm handheld, all the way from program editing to final run. These tools open new possibilities for mobile programmers.

At first blush, the compact physical form of a PalmOS handheld might lead you to think of it as a device dedicated to a few pre-packaged applications. Appearances, however, can be deceiving.

It's all in the PalmOS of your handheld

A PalmOS handheld is actually a moderately powerful computer in its own right. With more memory and CPU power than many earlier computers, using the right tools, a PalmOS handheld can act as a complete program development environment -- allowing customization of application functionality without the need for a desktop PC.

The Palm is a rather unusual device for people used to programming desktop computers -- whether MacOS, Windows, UNIX/Linux, or other environments. In a lot of ways, the architecture will be more familiar to embedded programmers. In particular, in almost ironic juxtaposition to the UNIX philosophy of "everything is a file," the PalmOS wholly lacks the concept of a file. This means there are no special files for STDIN, STDOUT, and STDERR. But, even more interesting, it means there are no files in which to store source code for interpretation/compilation.

The route traveled to solving this "problem" of missing files (by most of the development environments we review) is twofold: On the one hand, most PalmOS-hosted IDEs have their own mini-editors to run one-shot code (sort of like one-liners in Perl or other script languages). On the other hand, most of these IDEs utilize the PalmOS Memo Pad to compose persistent programs. Program source "files" are identified by Memo Pad category and/or by special memo naming conventions.

After looking at Pippy in a previous developerWorks article (see Resources), we were particularly curious about how different PalmOS programming environments handled floating point and various higher-order mathematical functions (Pippy came up short here). We were also interested in the types of input and output (like forms) provided by different environments.



Back to top


HotPaw Basic

HotPaw Basic is one of the two Basic implementations we review. HotPaw claims to implement over 95% of the ANSI/ISO Basic Programming Language Standard. It supports most GW-Basic functions and statements as well. As with other modern versions of Basic, HotPaw uses structured programming constructs rather than the old-fashioned line numbers and GOTOs (beloved by one of the present authors). HotPaw supports color; custom forms, and dialogs; serial, IR, and IP communication; access to several database formats; and both double precision and transcendental mathematical functions (using the LGPL MathLib.prc, which is also used by other programming environments).

We found HotPaw easy to install and use. There is a short tutorial and some examples available at the HotPaw Web site (see Resources). Knowing a little Basic opens the possibility of writing your own PalmOS applications for the Palm, on the Palm. In order to install HotPaw, you will need to install the file yBasic.prc by the means usual to your desktop platform. You will probably also want to install MathLib.prc (version 1.1+), which you need to obtain from a separate site (see Resources). yBasic.prc itself is the virtual machine that allows you to run either source code files from Memo Pad or bytecode compiled applications (the applications can have their own icon, and run without the HotPaw interactive interface). The distribution has a few extra helpers and samples, but they are not strictly required.

One of the nicest things about HotPaw is form support. You can use the form() function to define a few basic parameterized input/output forms, making it easy to create a PalmOS GUI, at least for simple applications. With a little more work -- but not too much -- you can create more customized forms, and even output graphical elements to the screen (lines, shapes, pictures).



Back to top


SmallBASIC

SmallBASIC is another Basic environment (this one under GPL license and also available for Linux/SVGALib and Linux/SDL environments). Like most of the development environments we look at, SmallBASIC is a code interpreter rather than a native compiler. SmallBASIC echoes the feel of 1986: it refers to "files" and VGA colors; uses line numbers and GOTOs; and even recreates the F-KEY prompts of IBM-PC ROM BASIC. All this may sound crude, but actually SmallBASIC has one of the better development interfaces of the IDEs we've seen. Even though there is no filesystem on the PalmOS, SmallBASIC's sophisticated built-in source code editor uses menu options for "File Save," "Save As," "Close," and "Open." This built-in editor allows for larger documents than Memo Pad supports. It has "search," "goto line", and "search again" options, clipboard support, and a unique online help system.

Installing SmallBASIC is pretty much the same as installing HotPaw. You just install the sbpad.prc and MathLib.prc files that come with the distribution archive. After that, run SmallBASIC from its icon, and create and run scripts using the SmallBASIC interface. We do wish that SmallBASIC was a bit stronger in documentation -- like many free software projects -- or at least in English language documentation (Greek and Japanese are better supported).

SmallBASIC supports a good variety of functions (mostly the same ones as GW-BASIC and QBASIC, actually). You can draw graphic primitives to screen, create sounds, output texts in different fonts, get keyboard input, and basically everything you need for a useful application. We do wish that the underlying language used more modern structured programming techniques (OOP and FP are too much to wish for), but SmallBASIC is still a good way to quickly write ad hoc Palm-hosted applications.



Back to top


PocketC

PocketC is a C-like language for the PalmOS, with versions of the same compiler available for Win32 and WinCE. (The Win32 "Desktop" version lets you target PalmOS and WinCE handhelds, but we are interested in the Palm-hosted version here.) PocketC operates much like most of the languages we have looked at in that it provides its own runtime environment; this amounts to a virtual machine to interpret PocketC compiled bytecodes. The language is basically C, but a number of functions for the Palm and a few C++ syntax conventions were added. You do also get some features typical of bytecode languages, such as a string data type and garbage collection. Being a PalmOS application, some extra functions for graphics, sounds, database I/O, and form I/O are included in the "standard library." Writing an application consists largely of calling these Palm-specific functions, but with flow control in a familiar C style.

The environment for PocketC is generally similar to the other IDEs. As with the others, the Memo Pad is used to store source code. You can even use the Memo Pad to store #include headers. Unlike some of the "fully interpreted" languages, PocketC requires a separate compilation step before you can run an application; but you can do this compilation right within the same interface (and when you do it once, the bytecode sticks around). One nice touch to PocketC's interaction with the Memo Pad is that in the instance of a source code error, PocketC gives you the opportunity to jump straight to the error, and highlights it.

While PocketC is nice for C programmers, it seems to us that C is inherently more verbose than this niche requires. The high-level functions, string types, and garbage collection of PocketC save a bit of code length, but if you need those features (which you do want for Palm-hosted quick application development), why not use a language like Basic, Scheme, or Python, rather than one whose syntax is designed around low-level efficiency? Nonetheless, PocketC is quite nicely done, and tastes in programming languages are largely a matter of personal faith and devotion.



Back to top


OnBoard C

OnBoard C really aims at a different target than the other development environments we reviewed. It supports true native compilation of source code to PRC executables or HackMaster hacks, rather than using a virtual machine and bytecodes. Moreover, OnBoard C is a real project-based IDE, with a choice of source code and resource editors, and the ability to include a variety of "files" in a given project. The source code editors supported by OnBoard C include pedit, pedit32, QED, and SmartEdit; of course, you can just use Memo Pad too. The applications you create with OnBoard C can, therefore, be distributed without including any sort of runtime or library (other than the Palm ROM's API).

Developers using OnBoard C will usually also want to get the resource editor RsrcEdit. RsrcEdit allows you to create forms, text strings, bitmaps, menus, and other GUI elements you might want to call from your OnBoard C applications. Like OnBoard C, RsrcEdit is entirely Palm hosted.

OnBoard C will generally appeal to those developers already pretty familiar with the ins-and-outs of PalmOS development (it is not as good for those just wanting to bang out a quick custom application). Obviously, you get much faster applications using OnBoard C, and a lot more low-level control, than you will with other IDEs that are Palm hosted. The price for speed and control is verbose and explicit source code, and the need to hand-tweak resources.



Back to top


Poplet Kit

The Poplet Kit is an interesting creature. Most of the IDEs reviewed here are basically full-cycle write/compile/run environments. The Poplet Kit, however, does not allow you to run scripts within its environment (nor is it meaningful to do so, in most cases). Instead, each "poplet," created and enabled within Poplet Kit, adds enhanced capabilities to every PalmOS application. This is much like what HackMaster hacks do, but with a friendly and interpreted language. To call a poplet in an application, you just call up the PalmOS Command Bar. For many poplets, whatever text is highlighted will act as the input for the poplet (for example, computing a calculated expression, or reformatting some selected text).

The language of Poplet Kit is called Handscript, and is similar to Javascript. The OOP features of Javascript are left out, but the syntax and function semantics are the same. Some modularity is added by grouping functions into poplets. A few shortcut commands for using PalmOS features are added as well. Basically, if you know Javascript, Handscript will be easy.

The interface for Poplet Kit is well done. A number of views of your poplets are presented, similar to the different views in an application like DateBook+. In one area you can read documentation about a poplet; in another you can browse functions; in another you can edit function definitions. You can also quickly enable or disable each of the installed poplets (a good sample collection comes with the system).

Even though Poplet Kit might strike you as a mere system enhancement rather than a programming environment, the programs you can run using Poplet Kit are just as general as with the other languages/IDEs. You can input anything you want by highlighting relevant inputs, and anything can be output to the active application and/or presented in dialogs. In terms of practical usage and interaction with the rest of your Palm, Poplet Kit even shines above the other IDEs.



Back to top


Conclusion

Check out Michael Winikoff's page (see Resources) for even more Palm-hosted IDEs than we looked at here. Some "exotic languages" like Forth and Lua are included in the list. We did make a start at looking at the environment LispMe, which is a Scheme for the PalmOS. Unfortunately, at least on our test platforms, LispMe was too unstable to really examine (constant resets); this might be a problem with particular ROM/OS versions. But those we have not yet looked at might still interest readers.



Resources

  • Read David's related article on developerWorks: Python for the PalmOS covers the programming environment Pippy (a version of Python for the PalmOS).



  • Read David and Andrew's related article on developerWorks: Palm-Linux integration with Pyrite describes the Pyrite Project tools, which allow Python programmers to access and control PalmOS handheld devices.



  • Dr. Michael Winikoff has compiled an excellent list of links to development environments for the PalmOS. Winikoff includes in his page ("PalmPilot Software Development - Alternatives to C") both PalmOS hosted and PC hosted software development kits (SDKs).



  • Visit the Palm OS Developer Documentation Web site, which provides additional resources -- including tutorials and specifications -- related to the platform. The Palm OS SDK HTML Documentation covers versions up to and including 4.0. Palm also offers a Development Support site that includes source code, licensee information, and an FAQ section.



  • IBM's alphaWorks offers a Bluetooth protocol stack that enables programmers to easily develop Bluetooth applications for the Palm OS.



  • IBM's WebSphere Everyplace Suite software development kit can be used to create and test wireless applications.



  • The HotPaw Basic demo is available for free. The full system may be purchased for $20.



  • SmallBASIC is free. Version 0.5.6 supports PalmOS, Linux/SVGALIB (console or graphics, with or without OSS audio), Linux/SDL..



  • PocketC version 4.0 is available from OrbWorks. There is a free (time-limited) demo there.



  • The OnBoard C home page offers version updates and operating instructions. The shareware fee is $15.



  • If you use OnBoard C, you will probably want to pick up the accompanying resource editor, RsrcEdit ($15).



  • The Poplet Kit costs $20, or you can download a demo version.



  • The LispMe home page offers news, version updates, downloads and links.



  • The MathLib Information Page offers information on downloading MathLib.prc and maintenance.



  • Browse more Linux resources on developerWorks.



  • Browse more Open source resources on developerWorks.



  • Browse more Wireless resources on developerWorks.


About the authors

David Mertz worries that if the density of transistors doubles every eighteen months, he may lose his next computer in a haystack. David may be reached at mertz@gnosis.cx; his life pored over at gnosis.cx/dW/. Suggestions and recommendations on this, past, or future columns are welcome.


Andrew Blais divides his time between home schooling his son, writing for Gnosis, and teaching philosophy and religion at Anna Maria College. He can be reached at onlymice@gnosis.cx.




Rate this page


Please take a moment to complete this form to help us better serve you.



YesNoDon't know
 


 


12345
Not
useful
Extremely
useful
 


Back to top