Dash to Code widgets for your iPhone

15 10 2007

I was shocked that Apple didn’t do this right at the launch of the iPhone. Now, I’m still predicting they will do it, and soon:

When Leopard is released, its free developer software will include a copy of DashCode that will allow you to write widgets for your iPhone.

Most people know that widgets on Macintosh OSX are small applications that can be brought up on screen with a keystroke and dismissed with a click. They are lightweight applications, written mostly in the JavaScript language. There are hundreds, perhaps thousands, of these widgets available, written by Apple, Apple developers, and just plain folk. Compared with a traditional Mac application, widgets are much easier to write. Since they use JavaScript, many people who develop Web sites already know almost everything necessary to write a widget.

It’s not very hard to develop a widget by hand with nothing more than a text editor and some GIF graphics, but Apple made writing widgets even easier when it made the DashCode application available to its developer community. DashCode is an integrated development environment for creating widgets. With it, you can place your graphics and user interface controls, write code, give it a quick test run, set breakpoints, examine variables, and so on. It includes a library of controls and snippets of code you can use in your widgets. It’s a slick, easy way to develop widgets.

Widgets on an iPhone might be a very good idea. Apple wants to make sure that its phone remains stable. They don’t want buggy or malicious third party applications to overwrite important code or data on other critical parts of the phone. They don’t want a crashing app to crash the entire phone. And they don’t want apps to get access to parts of the phone they deem off limits – It doesn’t want to see apps that unlock the phone to make it able to work with other carriers, for example.

Widgets run in a “sandbox” that they can’t, in theory, break out of. They can have limited persistent storage, be required to use a fixed API for access to system services, and so on. And they are small, light, and almost all the internals necessary to handle widgets are already in the phone.

You already have widgets in your iPhone – sort of. The Stocks and Weather applications on your phone, though not internally implemented as widgets (I think) look exactly like the corresponding widgets on the Macintosh itself. And if you peek at the Mac, you can get an idea of the many, many kinds of things you can do with widgets. On the iPhone they will be able to access the Net, make a call, bring up a Web page, or bring up a map – JavaScript can do these things already. With a bit of work by Apple, they could be given access to contacts and perhaps control playing of tunes.

Why, oh why didn’t Apple give developers the ability to make third party applications from the start. I believe they DID intend to – in the form of widgets and DashCode. I believe they wanted, on day one or soon thereafter, to allow people to use DashCode to make widgets, let iTunes sync them into the phone, and have them appear as icons right on the home screen of the phone.

So why didn’t they do it? Because of security? Politics? Contractual constraints? Nah, it’s just that Leopard was delayed. I believe they have this all set up – a new DashCode with modifications to make iPhone widgets, that runs on, and requires, Leopard. When Leopard and the iPhone were being developed, they were going to come out at almost the same time. But when development resources got tight at Apple, they decided to get the phone out first and save Leopard for later. This pushed back DashCode for iPhone as well. And ever since, Apple has been taking flak on having no development system.

Widgets aren’t applications, they have many limits, and developers will complain that they can’t do everything or make the most efficient use of CPU resources, but you can make a heck of a lot of stuff with widgets.

That’s my guess on what’s happening. You are going to see, when Leopard arrives, a way to make widgets for the iPhone using DashCode. So get ready now, developers! Start making developing widgets now that do the things you want to have on the iPhone. I’m betting you will be able to get them into the phone very, very soon!