Michael Cook’s Place

Bits of Genius in a Sea of Mediocrity

Michael Cook’s Place Random Header Image

WebOS Programming Needs Work

November 26th, 2009 · No Comments

In the last few days I’ve read a good chunk of the documentation on Palm’s WebOS, and started making a little program. While the documentation is technically thorough, it’s poorly laid out and the example leaves something to be desired.

You can find everything at Palm’s developer site. I downloaded what I thought I needed, then signed up for a developer account. I did this because it seemed that I would need to in order to activate the SDK or download an extra part, but it turned out I didn’t. I don’t know if this is a remnant from before the SDK was open to everyone, but it was annoying and the start of a trend.

I followed the tutorial to make a little “Hello world” program. After that I started following the next part of the tutorial in which you make a button that counts the number of times it is tapped. This is where I ran into big problems.

If you follow the example, you end up with files with names like “First-assistant.js”, but all the screenshots show the names in all lower case. I figured this was a mistake and renamed all my files (and the class) to start with a lower case letter. This was a mistake. The class seems to NEED to start with a capital. That’s a good practice, but it’s not quite what the screenshots showed.

The problem seems to be the Prototype framework. You are expected to be familiar with it, Java script, the command line, and HTML. The tutorial gives no basic information at all. To update the count on the tutorial application, it uses Element.update(String). What exactly does that update? No one knows, if they only read the tutorial. You have to go Google the Element class in prototype to find out the update method replaces the HTML contained in the element. The tutorial just assumes you know that. You’ll use lines like “this.controller.getThing().set(this.myMethod.bind(this))”, but there isn’t even a sentence explaining why you have to use .bind(this), the only documentation is that the line associates a function with Thing on the controller.

And what is the controller? Why it’s an app controller. Or is it a scene controller? Or a state controller? WebOS has all three, but the tutorial doesn’t explain any of this, you’ll have to look it up on your own. (PS: it’s a stage controller).

As a tutorial, it’s not newbie familiar at all. It’s like giving someone a C program that uses pointers and plays music, with a few lines of comments, and saying “use this to learn sound generation”. The reader is forced to muck about and make nearly random changes until the figure out what is going on, or find a better way to learn. As someone who had never touched Prototype, this was rather annoying and made the learning curve much steeper than it needed to be. A few extra sentences (especially pointing where to look for more information) would have been a real help..

So I eventually figured out what went wrong. How do you do that? You have to connect to the emulator (or a real phone) over a socket with the full program name (com.mycompany.myprogram) to get the error messages. This is explained on the debugging page. There is one link to it on the tutorial page (nearly: “If it doesn’t work, you’ll need to debug it.”). Once you connect, it’s up to you to figure out what the messages mean. They are actually quite helpful, but it could have been explained better. The debug function in Eclipse doesn’t seem to do anything different from the run function.

The emulator and it’s connection to Eclipse was a source of frustration for me. It’s made using VirtualBox and works well technically. But every time I booted it (and every time it did something) VirtualBox would pop up a modal sheet informing me of something until I started to check the “don’t show again” checkboxes. It’s also quite unclear how to do many things in the emulator, and finding the right page on Palm’s site to learn the 6 or 7 magic keys is very difficult. On WebOS you do a swipe up from the gesture area to go back to the launcher from an open program. But on the emulator, there is no gesture area for me to use with my mouse. There is no little ball button to light up (should I make my program do that). You just have to find out to press Esc. There is no help in VirtualBox about this, because it’s OS specific.

Loading and launching programs (as well as creating new ones) is done with a set of command line tools. They work well, but they don’t have man pages. The only help (short of somewhere on Palm’s site) is to run the command without arguments. This prints out some help text, that doesn’t match the format of any other help text from any normal set of command line programs. It’s not DOS style, it’s not Linux/UNIX style. It’s sort of DOS like, with a bunch of examples on the end.

Now you can choose to ignore that, and use Eclipse, but that didn’t work for me. I could create projects and such just fine, but the run button didn’t work to launch the program in the (already open) emulator. Eclipse said there was no way to run the program. I had installed the Palm tools (that’s how it knew how to make the project), but it didn’t work. I had to dig through preferences to find out that the action pressing Run triggered for a WebOS project didn’t get set for some reason. As soon as I set it to “WebOS” (as opposed to “Java”, etc.), it worked. How would someone new to Eclipse know to do that?

I’ve got a little program working that queries the GPS. The documentation on the calls to get GPS information tells you exactly how to use the service (which call to make, what to pass). The problem is that how to use services in general (specifically, how stuff gets back to callbacks) is documented on another page that isn’t exactly easy to find. It makes a ton of sense (you get single object of JSON data), but you have to go look that up first.

Developing for WebOS so far has been… something of a challenge. Palm’s documentation is clearly for experienced developers.

Tags: Programming · Reviews