Thursday, March 05, 2009

Portable Forth Learning Environment

I dusted off my ancient HP 200LX palmtop in the hopes of using it to do some hands on learning of Forth while on my latest trip. I figured with 40+ hours of flying, there had to be some time to spend coding? The experiment turned out to be pretty successful - I've learned quite a bit about Forth, embedded programming, alternate approaches to problem solving, got a new use out of some old hardware, and most importantly, passed the time in various lines and flights much faster.

I was reminded at what an amazing device the 200LX is. The keyboard is remarkably usable. And, the device really is a DOS based computer - so anything that runs on DOS can run on it. And it was great to travel with - a couple double AA batteries lasted the entire trip. Something my cell phone and laptop can't begin to compete with.

Here's what the device looks like - I'm using my G1 as reference:

What makes this experiment successful isn't just the 200LX hardware. There's also the Forth implementation. I went with HP-Pygmy Forth, a version of Forth customized for the 200LX, and I wasn't disappointed. What beautiful software this is.

It's small enough to run comfortably on the palmtop, yet serious enough to do sophisticated Forth programming with. It's also completely self contained - the software provides it's own editor to write code in, as well as a really easy way to view the source code of itself. There's even extensions available for working with graphics on the device. I really can't say enough good things about how impressive HP-Pygmy is.

I had big plans for developing some significant code in Forth - I was thinking about writing my own Sudoku game. However, I never got close to implementing it. Though, I did learn a number of peripheral lessons and wrapped my head around embedded systems and Forth.

I really enjoyed being able to work on a programming problem while standing in a lengthy customs or ticket line. There's something pleasantly active about programming that reading a magazine or book can't compete with.

This, of course, has me wondering if I could replicate this sort of environment on my T-mobile G1 phone, so I wouldn't have to carry around two devices. Seems simple enough, but I'm not sure. The whole self contained nature of HP-Pygmy, including an editor, compiler, assembler and source code, is something I haven't seen in a Java based Forth. On the other hand, a Java based Forth should allow me easy access to Java classes and method calls, which means that developing software that actually does interesting stuff on the G1 seems quite possible.

Regardless, it sure is a wonderful feeling to grasp new concepts - and if there's one thing to be said about Forth, it has many new concepts.


  1. Anonymous10:25 AM

    I think that if you jailbreak your G1, you can run PFE, gForth, bigForth, etc., on it. Won't help with calling into Java though.

  2. Anonymous1:26 PM

    Maybe Misty Beach Forth would work on the phone?


  3. Anonymous2:28 PM


    nice Article. I often use VolksForth ( on an old Atari Portfolio as a portable Forth Environment. I have also used VolksForth on Frodo (C=64 Emulator) on an Symbian Phone in the past. Forth works best on bare hardware, running Forth on top of the JVM is not an easy task (despite some similarities between a Forth VM and the JVM). Is there QEmu for the G1? Or use JPC (PC Emulator written in Java).

  4. Thanks for the great suggestions all!

    Mistybeach seems like the easiest solution, as it's Java.

    On the other hand, I think Carsten is on to something - as Forth does best when it's close to the hardware.


    I'll definitely have to look into the jailbreak solution. Though, I'm not sure I'm ready to go that far with my cell phone which I'd prefer to keep functional :-).

    Lots to think about...


  5. Anonymous6:16 PM

    Hi Ben

    I'd like to get my hands on a cheap (possibly oldish) PDA where I could do some programming Forth and/or Scheme would be neat.. any ideas ?
    I mean the Zaurus would be good but they are pricey...

  6. Re: picking up a cheap PDA

    You know, that's a great question - I'm not sure where you can get these inexpensively.

    Perhaps eBay is the answer?