A couple of weeks ago, I was browsing the Windows Phone 7 (WP7) Marketplace looking for a new game to play on my phone, and I stumbled upon the insanely neat TouchDevelop from Microsoft Research. TouchDevelop is a full-blown IDE for WP7 that allows you to create and share WP7 applications outside of the normal App Hub process. Eager to try something interesting (hey, it might be more interesting than Angry Birds while sitting on hold waiting for tech support to pick up), I gave TouchDevelop a shot.
What is really unique about TouchDevelop is how Microsoft Research adapted the IDE needs to a small, touch screen device like a phone; minimal typing is needed. For example, in a traditional development environment, I might declare a method with a line such as this (yes, I'm using a Fibonacci sequence generator example):
private long fib(int x)
In TouchDevelop, I create a function with a "+" button in the menu at the bottom of the screen while looking at my functions list. A default name is picked, and a code stub is made. By highlighting the line with the function stub, and clicking the Edit menu item, I am given a panorama allowing me to edit small parts of the definition. The "props" page lets me set the name and check a box to make the function private. A swipe to the right gets me to the "params" tab to edit parameters. The "+" button adds a parameter (which also gets a default name), and a drop down box lets me select the type. There is text under type to explain what it is, which is a nice feature. Another swipe to the right for the "returns" tab (you have multiple items in "returns").
From there, you add lines of code. There is a very unique UI here. You see what looks like traditional code (Figure A), but you have to select a line and choose an "Edit" command to access it. From there, you have a tiled expression editor, which suggests things that can be done based on what is in scope and what is not. If you have an obvious bug (like an assignment without a variable being assigned to), there is a "Tap here to fix" button that will try to fix it. Lines that are no good are highlighted in yellow.
A simple action
The code is difficult to categorize. It is strictly imperative -- you cannot even define your own types (unless I'm missing something). The built-in types are quite extensive, covering much of the phone's functionality (including maps, GPS data, music, etc.). The code follows a unique, right-to-left processing model. If you look at my controlling code for the application (Figure B), you'll see what I mean. The options of what you can do are clearly typed, since different functions are only available in certain circumstances.
My Fibonacci calculating action
Something else that is neat is that, in the view of the action, things like strings get truncated for space considerations, but they are fully expanded in the expression editor. In addition to actions, you can define global variables, which are automatically persisted across sessions. There is an event model that captures basic events like a phone shake or orientation change. Also of note is that you can run any given action in an "app" to start things off.
IO is very simple. Again, there are global variables that persist for long-term storage. Outside of that, you can draw to a canvas for games or graphics; otherwise, you can "post to wall," which is a lot like a Facebook wall. Instead of the traditional text view where new items appear at the bottom, new items appear at the top, and you can post any data type to the wall, like songs (to be played), pictures for display, maps, etc.
While there are some extraordinarily cool demos available (like "Missile Command" clone), TouchDevelop is not for serious applications. You really don't want to be doing much on a tiny screen, even if the UI makes it as easy as possible. So what good is it? Well, to be honest, I love TouchDevelop!
First, it makes simple application development really easy. Why make an entire app and go through the App Hub system (or use up one of your 10 direct deployments per device) on what amounts to a simple script? Secondly, it is a great introduction to basic development; it really has the feel that classic BASIC or Logo did when I was growing up, a sort of "playground" language that delivers an immediate payoff -- well, not quite as immediate as a REPL system, but with minimal effort to see what's happening.
With a simplified set of libraries, a syntax that makes it obvious what is happening, and a selection of types and functions that handles all of the heavy lifting, letting you concentrate on tying things together, TouchDevelop delivers fun to the world of software development. An intangible benefit is that working with TouchDevelop lends itself to working while waiting in a doctor's office and similar "time killer" situations.
While I'm not going to be using TouchDevelop for any major app development any time soon, it is a winner in terms of fun, and I hope that Microsoft Research ports it to Windows 8 as well, since I think it would be awesome on a tablet.
Justin James is the Lead Architect for Conigent.