What I’ve done here: or, yet another way to blog from your Palm.
I thought I’ld take a few minutes to talk about just what it is that’s allowing me to write an entry while I’m walking down the street on my way to the gym. (And on my way home from the gym, and on the subway to work the next day, because while I’m connected, I’m not necessarily fast at either Graffiti or writing weblog entries.)
As I’m sure you know, I’m a computer programmer by trade, and so when I run into a problem, I tend to want to write a program to fix it for me. A long time ago I got a PalmPilot Professional, partially so that I could keep track of my projects and assignments, and partially because I could write programs for it in C. Then, someone wrote a C compiler that ran on the Palm. I was so excited that I could finally write code on the subway! Until the first program I wrote crashed my Palm. I quickly realized that C was just too hard a language for writing Palm programs. (It’s not so bad if you’re working on a desktop, and have an IDE, and an emulator to test on, but for on-Palm development, it really sucks.) I also played around with an implementation of Forth for the Palm, but I couldn’t get enough of a library of utility words built up to do anything useful with it. Later, I learned a language called Python, which was far easier to write programs in, both due to being an easier language syntactically, and due to the wealth of useful libraries it comes with. After a while, someone ported Python to the Palm, and so I played around with that, but I found it, too, was lacking the libraries I needed for it to be useful to me. Finally, someone posted on the Python tutor list about a program called Plua, which was an implementation of Lua for the Palm. There are a lot of things I don’t like about Lua the language, but when creating a screen for a Palm app is as simple as:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
pclear() ptitle( "PalmBlosxom" ) pmenu( {"P:Server Prefs"} ) m32=pcheckbox("pEdit32") ptab() name = pfield( 1, 24, 24, catName) pnl() pl = plist( 10, 31.5, lst ) pnl() ptab() i = pbutton( "Reload" ) ptab() d = pbutton( "Details" ) ptab() q = pbutton( "Quit" ) |
I’ll put up with a lot of ugliness in the language.
Of course, I made it sound like a much smoother progression than it actually was. I took side trips into Basic, Smalltalk, Perl, Scheme, Java, Intercal, Visual Basic, and Ruby, but none of those were serious contenders for on-Palm programming, and Java is the only one I still use these days. But I remember enough of them to be the person to ask when someone at the office needs to debug a program written in one of them.
Where was I? Oh, yeah, Plua. Plua makes it really easy for me to create programs for my Palm, and so makes it far more likely that I’ll actually complete whatever random project it is that requires a Palm program to be written. In this case, it was a way for me to write weblog entries in the standard Palm MemoPad application (or, more accurately, in pEdit, a replacement which handles memos of up to 32kb, as opposed to Palm’s 4kb size restriction). Since I was leveraging the standard MemoPad, my application was turning out to be much simpler than a full-fledged weblogging application, but it was still taking me a long time to write it in C++, partially because I needed (or more accurately wanted) to write a generic framework for use in other applications I might write, and partially because I don’t have a lot of spare time for programming. Switching to Plua let me write the application in a day or two, and I can easily change things around in it, or add features, without going through the hassle of a compliation and hotsync.
The hardest piece to get working was the conduit. Since my Palm doesn’t have a WiFi connection, it’s a bit of a pain to use programs which depend on network connections. Conduits, on the other hand, get run every time I hotsync, which is usually once or twice per day. I had been planning on writing the conduit in C++, which was going to be quite a pain for me, since I didn’t know of any libraries that could handle ftp over secure sockets. Fortunately, Rick Price asked me whether it would be possible to write a conduit in Python. "Sure", I said, and then started thinking about how you would do it. You could either wrap the C API up into a Python library, which would take a lot of work, or you could use Python’s COM support to talk to the COM API. I figured that would probably be an easier way to go, and since I had some free time, I started experimenting. It turns out that it was a little harder than I had anticipated, but it still wasn’t too bad, and I think I’ve finished the worst of it. The Secure-FTP library was easy to find, and after some firewall config on my home machine works quite well.