WARNING: This article is now four years old, and has not been updated significantly. I'm seriously considering removing it. If anyone out there reading this has the time and inclination, I would gratefully accept a new article that covers the current state of things.

CodeWarrior vs. GCC

by Wade Hatler

This is an HTML version of an article I wrote for the November 1997 issue of Handheld Systems Journal. It compares CodeWarrior and GCC for C development in detail. [Ed. I have left this article more or less intact, but where hyperlinks were out of date, I updated them where possible and removed the rest. This comparison still refers to the state of the tools as of 1997, so factually this article is not up-to-date.]


Windows users have a lot of choices for developing Palm applications. An overview of these choices can be found at the Palm OS Programmer's FAQ. The most common programming environment is C. This is what the built-in applications are written in. For C development, there are two platforms available: the freeware GCC system and the commercial CodeWarrior system. This article will compare the two, and help you decide which is right for you.

Overview

So you've read the FAQ and decided that C is the way to go for Palm programming. Then you're left with the choice of using the free GCC system or paying for Metrowerks CodeWarrior. The question is which one? Which one will give you the best result? Which is easier to use? Is it worth spending the money for CodeWarrior? This article will attempt to answer that question for you.

I'd like to be able to just give you a cut and dried answer but I really can't. Both choices are usable and each has some advantages over the other. Your choice will have to depend on the type of development you plan to do and your experience. I'll try to give you enough information to apply to your situation and decide for yourself.

History

CodeWarrior is Palm Computing's officially sanctioned development platform. CodeWarrior for the Macintosh was the original Palm development system. It made use of a Macintosh resource editor and compiler. Since the Macintosh used a Motorola processor with the same instruction set as the Palm, this leveraged existing tools. Roughly coinciding with the release of the Palm, Metrowerks changed their development platform over to a cross-platform system that runs on both Windows and the Macintosh. The original code is written for the Macintosh, and this system provides a translation layer for the Mac Toolbox onto the Windows SDK. This is their current product. It had some serious reliability and usability problems for the first few releases, which you may have heard about. However, most of these problems have been worked out and the system is quite usable now.

GCC is a compiler development system developed by the Free Software Foundation. This is an organization that believes compilers and other development tools should be free. To that end, various volunteers have produced a whole series of compilers for many platforms. Anyone can get the source for any GCC compiler, modify it and distribute the results as long as they also distribute all their modifications. A group of talented and energetic people took the GCC 68k compiler, combined it with a Palm resource compiler and a bunch of other Palm specific tools to produce a complete system that's free to anyone.

With either system, your primary task will be to write C code that makes use of the Palm API to do the tasks you want to accomplish. Both systems work from the same API and in fact come with the same API documentation so there are more similarities than differences between what you'll spend most of your time doing.

User Interface

In use the two systems look and feel quite different. Both systems show their history clearly, and neither system is a native Windows application. GCC is developed under Un*x and ported to Win32, and CodeWarrior is developed on the Macintosh and runs under Metrowerks cross-platform system that allows one program to run on both Windows and Macintosh platforms.

The upshot of this is that both systems have some quirks in their user interface. For example, CodeWarrior has buttons and windows that look just like Macintosh buttons and don't respond properly to some keystrokes. GCC's editor doesn't have any accelerator keys on its menus, and many common Windows keys don't work as expected. Metrowerks has a person working on this now, so some of these problems should go away sometime in the near future.

For either system, making a Palm program would consist of the following steps (more or less):

  1. Create your resources. This includes definitions of all your forms, and all the components of these forms. These are the screen items that the user will see.
  2. Create some C code to interact with these resources and do what you want your program to do.
  3. Build a project to tell your development system which files are to be combined into your program, and how the program is to be built.
  4. Build the project. This consists of combining the output from your C code and your resources into a Palm program.
  5. Run the program in a debugger and fix the bugs you almost certainly introduced.
  6. Repeat the process adding resources and code until you're done.

Both GCC and CodeWarrior have everything you need to do all of these tasks, but they accomplish them in quite different ways. Both systems have the three basic components you need to write Palm applications:

  • Source Code Editor: CodeWarrior has an IDE that ties it's editor into a project system. GCC uses the Emacs editor. You can also use your own editor with either system.
  • Resource Editor/Compiler: Resource compilers are used to define the user interface parts of your program, such as the forms, buttons, fields and labels. CodeWarrior has a WYSIWYG resource editor called Constructor. This uses drag and drop and a set of Windows fonts that look exactly like the Palm fonts to let you design forms on screen. GCC uses the PilRC resource compiler that works from a text file that describes your user interface. This means that you need to essentially write a description of all the parts for your user interface, and then try it and see how it looks. If you don't like it, you change some values and try again.
  • Build Process Manager: Either system needs to tell the compiler and other assorted tools how to put your project together. CodeWarrior uses an integrated project system in it's IDE. GCC uses Make files which you edit manually.
  • Debugger: No development system is really complete without a debugger. Both systems have good source level debuggers.

Resource Editor

CodeWarrior uses a WYSIWYG resource editor called Constructor. It looks like Figure 1.

Figure 1: CodeWarrior's Constructor Resource Editor

The top window is the control center for the editor and exists mainly to provide a pull-down menu. The partially hidden window on the left is a summary of all the major components of this particular resource file. This file has only one form but it could have as many forms, menus, strings, bitmaps and other components as you like.

The window on the right is the form edit window. As you can see, it looks pretty much like a Palm. You design forms by dragging controls from the Catalog window (lower left) onto the form, and then placing them in the appropriate position on the form. As you click on controls on the form, the properties show up just to the left of the form image, and you can change any of the control or form's properties manually.

Bitmaps are edited using the built in bitmap editor which is barely adequate. You can't use external bitmap editors right now but that should be fixed very soon (possibly by the time you read this).

GCC uses a resource script concept. This means that you edit a text file that describes your resources. The resource script matching the above Constructor entry is shown in Figure 2.

Figure 2: Resource Script shown in GCC's Emacs Editor

The formatting isn't critical, I just line up the columns for readability. To edit resources in Emacs, you need to know the syntax for all these statements, and must enter the statements manually. This is definitely harder to do than using Constructor, because you can't do it visually. You need to guess at the position and other attributes, run a Windows display utility to see what it will look like, and then manually change the parameters and try it again until it looks right.

While this approach is definitely harder to do than CodeWarrior's, keep in mind that even a very complicated Palm application typically only has for or five forms so it's not like you'll be slaving over resource scripts day and night forever. The resource script is also more flexible.

Advantage: CodeWarrior for ease of use, GCC for Flexibility

Source Code Editor

CodeWarrior's IDE looks a lot like Visual Basic. When you open it up, you get a window at the top of the screen that acts as your main menu and control center. Whenever you do anything with it, another unattached window opens up or gains focus and you work within that window. For example, Figure 3 shows CodeWarrior with both it's project window and a source window opened.

Figure 3: CodeWarrior's IDE, Project Window and Editor

You can resize and move the windows but their new position is lost next time you start up CodeWarrior. The window at the top of the screen is the IDE. They also have a resource editor and debugger window which aren't integrated with the IDE. This means that whenever you want to edit resources or debug your program you need to either minimize this window or close it down and then switch over to the other application.

This system works all right, but it's frustrating in practice because the accelerator keys are never available to you. For example, if you are in the editing window, it has the focus and the main menu's window doesn't. If you want to save the file by typing Alt-F to get to the file menu you're out of luck because it won't work. You're pretty much forced to use the mouse to use the main menu or remember the Ctrl keys for the more common operations.

The other thing you'll find strange is that the application looks like a Macintosh application. The windows and buttons look strange and don't respond properly to the tab key so you're stuck with using the mouse. This Mac/Windows cross platform strategy is also pretty slow. Every time you do anything, screen refresh takes a couple seconds. This doesn't chew up a significant amount of time but it's annoying.

On the up side, other than the few annoyances mentioned above, CodeWarrior's editor is a very standard Windows text editor. It's easy to learn and use. Any Windows user can sit right down with it and not find any real surprises except those mentioned above.

The editor has user-configurable key bindings so you can make it act like other editors. It also has a class/source browser that makes it easier to navigate your code. You can open up the browser window and get a list of all functions, constants, etc. and go right to the code by double clicking on the name. When they get their C++ working, it also works with classes. This makes working with large or multiple files much easier.

GCC's IDE is all tied into it's Emacs editor. It looks something like what you see in Figure 4.

Figure 4: GCC's Emacs Editor

The first thing you will notice is that none of the menu items have any accelerator keys and that the layout of the menu is very non-standard. Emacs is a port of a Un*x editor and more attention is placed on conformity with Emacs on other platforms than on Windows conformity. The end result is an editor that's kind of weird for a Windows user to use. Many standard keys don't work like you expect them to. For example, such fundamental keys as Home, End, Escape and Delete don't do what they do in almost all other Windows apps. It uses quite a few keystrokes that are unexpected, and hard to remember.

On the up-side, Emacs is an incredibly powerful editor. Once you get over the learning curve with it you'll find that it can do lots of things. In fact, it's so powerful most users don't ever even scratch the surface of what it can do, and you're very unlikely to ever find a task that it isn't up to.

Emacs also comes with a very powerful command and control language. For example, if you wanted to write something that would take a resource file, read through it and extract a bunch of information and then write out a header file for it you could do all that in Emacs. You can do lots of things right in the editor that you might think you might have to write a program for. This gives you a lot of power and flexibility. You just have to pay the price in learning curve.

While we're on the subject of editors, there's nothing forcing you to use either of these. I won't use either because I already have a superior editor (Visual SlickEdit). I will use it for code editing with either platform. If you want to do this, GCC is easier to work with because it is all command line driven. It can be done with CodeWarrior, but it's a little more difficult to set up.

Advantage: CodeWarrior

Project Manager

CodeWarrior's project configuration is all done through the project window you see on the right of Figure 3. To add or change components of a project, or change the overall project settings you just select the appropriate component and a dialog box pops up with all the appropriate settings. This makes it pretty easy to change global project settings, or to add or change components. You don't even need to know exactly what you're doing in a lot of cases, because you can just stumble around the project window until you find what you want to change.

The project manager allows you to have settings for release builds, debug builds, etc., all in the same project file. Changing from one to another is done with a combo box at the top of the project manager window. This makes it easy to switch between different build states.

GCC manages the process through Make files or batch files. These are text files that you need to maintain that list all the files that need to be processed and the processing that needs to be done with them. On the up side, this gives you a lot of control over the process, and allows advanced developers to do custom processing easily. On the down side, this system is more difficult to learn and maintain. You always need to know exactly what you're doing, and there isn't any set of screens that you can just wander through to see what the possibilities are.

You can also have support for different build versions like release build, debug build, etc. as with CodeWarrior, but to this you need to do some more manual work.

Advantage: CodeWarrior

Debugger

Both packages come with symbolic debuggers that are reasonably good. CodeWarrior requires that you debug while running your program on your Palm. You can also debug on your PC using Copilot, but this requires a spare serial port. GCC requires you to debug your program on your PC using Copilot. (without the spare serial port), and the next release will also allow you to debug on your Palm.

Both approaches have their advantages but overall I like the idea of debugging on the PC Better. It's a little more convenient, and quite a bit safer, since there's less of a chance of messing up your Palm with an evil program. (Note: you can debug with Copilot with CodeWarrior, but you need a spare serial port to do it).

To debug your program with CodeWarrior, you start up the CodeWarrior debugger. It tells you to put your Palm in the cradle and execute a special shortcut that puts it in a console debugging mode. (Note: There is a shortcut program for this called dotdottwo.) Then you accept a dialog box and it downloads your program to the Palm, and enters debugger mode which looks something like Figure 5.

Figure 5: CodeWarrior Debugger

The debugger window is broken up into three panes. The bottom pane shows your source code you're debugging. The small arrow on the left shows you current position. You set breakpoints by clicking on one of the lines on the far left. The pane on the upper right shows any variables that are currently in scope, and the pane on the upper left shows your stack trace. You step through your program using the toolbar buttons or menu commands. You can expand structures like the cmdPBB structure shown in the variable pane by clicking on the small arrow to the left of the structure.

With GCC, you use the GDB debugger that's integrated into Copilot and Emacs. Like CodeWarrior, startup is kind of complicated and requires more steps than I'd like but it isn't too bad. The running debugger looks like Figure 6.

Figure 6: GCC's GDB Debugger

What you see here is a debugging session in progress. The bottom half of the split window shows the current source file. The small arrow to the left (=>) shows where we're currently stopped. The top half of the window is the debugger window, where you type in commands to execute your debugging session. I started up the debugger, and then typed in the step command to go a single step, and then pressed Enter a few times to repeat that step command.

If I wanted to examine the value of a variable, I would need to know the name of it and type in a command in the GDB window. This isn't as convenient as the variable window in CodeWarrior, but some people prefer it. If you know exactly which variable you want, you can type it into the command much easier than hunting for it in a variable list. However, if you don't remember the exact spelling it's easier to use CodeWarrior. CodeWarrior's is also easier for beginners to use.

While neither debugger is as convenient and easy to use as I would like, they are both serviceable. I rate the CodeWarrior debugger as easier to use, and the GCC debugger as safer. I'd say that you shouldn't let the debugger be the deciding factor.

Advantage: Neither

Price

CodeWarrior costs $280 while GCC is free. If you're going to spend a lot of time developing Palm apps, this isn't a huge investment but it's still not spare change. Even if you want to use GCC, you may want to buy CodeWarrior just to get the sample apps. Keep in mind, the price of the software isn't the only cost. Your time is valuable too, so I wouldn't recommend making the decision based on price alone unless you just can't afford CodeWarrior.

If you're going to buy CodeWarrior, you can find it for considerably less than list price at several distributors.

Advantage: GCC

Availability

This article concentrates on Windows 95/NT development systems. CodeWarrior is also available for the Macintosh, and GCC is also available for Un*x systems.

You can find out more about CodeWarrior by checking out Metrowerks' home page. You can purchase CodeWarrior from several distributors. CodeWarrior is a commercial product that's delivered on CD only. If you buy it from Metrowerks, it's delivered overnight. No matter where you buy it, you get one year of free technical support and two free upgrades.

You can download all of GCC from several places on the net. The download is pretty big (15MB) so do it at night.

Ease of Setup

CodeWarrior is a little easier to set up and get going, as long as you don't get lost in some irrelevant documentation they point you to. You can pretty much just put in the CD, do the installation and launch right into the tutorial.

GCC is a little harder to set up. You run the installation program but once everything is installed you have more things to do before you get productive. GCC also has setup problems on Windows NT machines, and on all machines you need to set up TCP/IP if you haven't already done so.

Neither system's setup problems are earth shattering, and I don't think you should make this a major issue.

Advantage: CodeWarrior (slight)

Tutorial

Both packages come with a tutorial. You can download both tutorials from the net. The tutorial that comes with GCC is better at explaining the overall layout of a Palm program, and also contains quite a bit of Palm reference information. You should download this tutorial and read it first no matter which package you go with.

The tutorial that comes with CodeWarrior is much longer and covers a lot more ground. It works all the way through creation of Memo Pad. You can also get this tutorial with GCC, but it isn't all that useful since most of it concerns making resources with CodeWarrior's Constructor, and you don't get the source with it. You'll get this with either package.

Advantage: CodeWarrior

Documentation

The Palm Computing Palm API documentation is included with both packages. Some of the documents are slanted towards CodeWarrior since that is the officially sanctioned Palm Computing package. For example, all of the tutorial is CodeWarrior specific and quite a bit of the information about resources in general are CodeWarrior specific. If you go with GCC, you will need to translate some of this information into appropriate terms for GCC.

Neither system comes with printed documentation, but you can buy printed versions from online book sellers.

Advantage: CodeWarrior

Sample Code

Here's where CodeWarrior really shines. It includes the source code for all of the applications in the Palm ROM. By the license agreement, "The software development kit provides a royalty-free license that permits you to use any or all of the source code from the examples in your application." This means you can take the source, modify it or take fragments out of it and do anything you like with it except sell or publish the original source code. This can save you a lot of work, and it's also a great way to see how to do things that aren't covered clearly in the documentation.

GCC comes with only a minimal sample that demonstrates all the control types available. (Note: all this source belongs to Palm Computing. If enough people nag them at devsupp@palm.com they may release it).

Advantage: CodeWarrior

Quick Start

CodeWarrior comes with an unsupported program called EasySrc that takes the .h files generated by Constructor, or any other header files that follow their naming convention and generates a C program skeleton to handle all the UI elements found in the resources. This is pretty cool, as it can save you lots of time when creating a new application.

GCC doesn't have anything like this, or even any complete sample programs so it's much harder to get started with a new application. However, I expect more sample programs to become available as time goes by.

Advantage: CodeWarrior

Reliability

Both systems have suffered from some reliability problems in the past, with CodeWarrior showing many more problems than GCC. CodeWarrior's was just about unusable for the first few releases, and it still occasionally crashes and loses all your changes. However, the latest release is reasonably good and it's definitely improving.

In many ways, GCC is inherently more reliable. All of GCC's files are either plain ASCII text files, or support files such as bitmaps that are maintained by outside tools. CodeWarrior's resource files are stored in a proprietary binary format that is not easy to modify with other tools. Therefore, if you have a problem with CodeWarrior, you don't have any way to work around it.

I don't think either system has enough reliability problems now to recommend against it. Just make frequent backups and either system will work fine for you.

Advantage: GCC

Floating Point Support

Both libraries support single or double precision floating point support, and it can be linked into your program or loaded as a shared library.

Advantage: Neither

C++ Support

CodeWarrior doesn't have any support for C++ at the present time, but plans full C++ support in DR4 which is due in January.

GCC has limited support for C++. It includes better type checking for assignments and function arguments which can catch a lot of nasty programming errors before they get you, but it's support for object oriented programming (classes) isn't working correctly.

Advantage: Neither

Conduit Support

CodeWarrior includes the Conduit SDK. Unfortunately, this SDK requires you to use Microsoft Visual C++ 4.1 to write a conduit for Windows so you'll need yet another compiler to do this. Metrowerks is working on support for conduits on it's platform. It will probably be available early next year.

GCC doesn't include the Conduit SDK, so if you develop with GCC and want to make a conduit you have to buy the SDK from 3Com ($99).

Advantage: CodeWarrior

Expandability

Both systems have good expansion capabilities but they go about it differently.

All of the source for GCC is freely available to anyone. If you want to make some kind of code generator, or a resource file preprocessor, or support for another language, you write a program that reads and writes ordinary ASCII files. For example, let's say you want to write a program that reads through a resource file, looks at all the resources and then generates a skeleton C program to go along with it. With GCC, this would be a relatively simple AWK or Perl script (I'll probably write one). There are all kinds of things like this you can do easily with the text based files in GCC.

CodeWarrior uses a proprietary file format for pretty much everything, but they give you an API with all the documentation you should need to interact with the CodeWarrior environment. If you want to make a change to a CodeWarrior project, automate the environment or work with an external editor, you write a program that talks to their IDE and instructs it to do what you want.

For most users this won't make any difference. It's just something to think about.

Advantage: Neither

Conclusion

As you can see, it's kind of a close call. Both systems are usable, and neither system has a clear cut advantage.

  • If you plan to be a serious Palm programmer, I think you should get CodeWarrior, even if you think you might like GCC better. The sample source that comes with CodeWarrior and the rights to use them are worth the price alone. You'll probably eventually need to make a conduit so you'll need that anyway. I also think with the tutorial and other factors, CodeWarrior is easier to get started with. CodeWarrior has a 30 day money back guarantee so you're not risking anything but time. Also, if you want to become an ìofficialî Palm developer, you'll need to purchase CodeWarrior.
  • If you're a hobbyist or part time programmer, you can definitely use GCC without paying anything. You just need to expect more time for learning curve because there isn't much sample source code available to you yet. This doesn't mean a serious programmer can't use GCC, many of the best apps available were done with GCC. It's just harder to get going without the sample code.

Support

Metrowerks has a staff of technical support personnel available to registered users, as well as a person whose job is to patrol the newsgroups, AOL, and Compuserve to answer questions. In general, I've seen pretty quick replies to questions on the newsgroups.

GCC is supported by volunteers and other GCC users. They generally watch the newsgroups and answer questions pretty well. Being volunteers that presumably have a life, they can't always answer questions immediately, but they do a pretty good job in my opinion.

Advantage: CodeWarrior

More Information

The Palm Programming FAQ lists several other sources of information. In particular, I recommend looking at the private news server news.falch.net, which has several Palm programming groups, including one dedicated to CodeWarrior and one dedicated to GCC.

Acknowledgments

Several people helped with this article, primarily pointing out things that I didn't know and generally reviewing it. D. Jeff Dionne is one of the GCC developers. Eric Cloninger is the product manager for Palm CodeWarrior. Howie Hirsch and Kerem Kirkpinar are other developers that gave me a sanity check.

Copyright © 1997 by Wade Hatler. All rights reserved.