App Inventor, Scratch and Simple Programming

Last week I was discussing Android applications and concluded by mentioning Google's new and, as yet, un-released programming tool for the Android operating system called App Inventor for Android (which implies that Google may also have plans for App Inventor on other operating systems).

The potential of App Inventor is huge. The concept is to simplify programming by using a visual block assembly metaphor that allows users to link blocks of functions together to create a program. The intention is to make building a program as easy as possible, even for non-programmers.App Inventor will provide all of the basic building blocks of software as well as blocks that can access hardware supported by the Android operating system, such as the Bluetooth, GPS, accelerometer and compass subsystems. By encapsulating these feature in blocks with easy-to-understand inputs and outputs that can be visually connected it should be possible to build pretty sophisticated applications. I write "should" because, to date, App Inventor isn't actually available.

If you want to see what the App Inventor platform might be like when it is released you'll have to look at a project that forms one of the conceptual foundations of the system -- the Scratch Programming language developed by the Lifelong Kindergarten research group at the MIT Media Lab.

Scratch is a "sprite" based system. In this case sprites are objects that have as attributes one or more visual images called "costumes", one or more sound samples, and one or more scripts.

In a Scratch application sprites are placed on the "stage" (which is a sprite in its own right). Sprite scripts that are constructed to recognize the event can be executed by clicking on the green "start" flag in the border of the stage panel and or by other events such as a mouse over or mouse down on the sprite itself.

The Scratch integrated development environment 

Scratch applications are developed with the Scratch integrated development environment (IDE), which is divided into three vertical sections.

Scratch IDE

Click to see: Scratch IDE

In the right-hand section of the IDE window is the stage panel and below that is the sprite browser panel. Selecting a sprite in the sprite browser changes the contents of the center section, the Sprite editor. The left section is the language block browser which groups blocks by function:

* "Motion" are blocks that change the location of sprites and "Looks" are commands that alter graphical attributes of sprites.

* "Sound" blocks play the audio samples that are attributes of sprites.

* "Pen" blocks enable a sprite to draw lines or stamp patterns on the stage.

* "Control" blocks provide a hook for capturing the start flag event so a sprite can start and also provide functions for stopping the script or all scripts, broadcasting and detecting messages sent within the Scratch system, and language constructs such as looping, if/then/else, and wait clauses.

* "Sensing" blocks detect mouse location, mouse down, distances to other sprites, loudness of the audio input device and timer functions.

* "Operators" are blocks that cover mathematical and logical operations on variables and strings.

* "Variables" declare variables (but not their types -- types are inferred by use), set their scope (accessible system wide or to just the current sprite) and delete them, and also include some blocks for sprite state attributes such as the logical variable "being moved" and integer variable "speed" (note that only strings, integers, and logical values are supported).

Scratch can also interact with the real world through the use of a Picoboard and the Lego WeDo system.

The potential of the Scratch programming metaphor is huge and it appears to have a fairly enthusiastic educational audience judging by the activity in the Scratch forums.

StarLogo TNG running a fish and plankton simulation

To get an idea of how the Scratch metaphor can be adapted to handle much more complex programming problems, check out StarLogo TNG (yep, that does stand for "The Next Generation") which is, like Scratch, based on an older programming system called Logo Blocks.

StarLogo TNG

Click to see: StarLogo TNG

StarLogo TNG is orders of magnitude more sophisticated than Scratch and the sample programs such as "Epidemic" and "Fish and Plankton" are amazing, yet the underlying logic is much more easily understood than it would be if written in a traditional programming language.

Exactly what App Inventor will look like and how it will function isn't yet known, but expect it be somewhere between Scratch and StarLogo TNG.

So, what will App Inventor do for Android-based systems? At the very least it will make programming a sophisticated device something that is accessible to whole groups of people who would normally not think of tackling even a simple programming task on such a platform.

At best, App Inventor will spark a torrent of creativity and, when we finally see Android-based pad-style computers, the result of simple programming with a compelling platform could be astounding.

Apple's got to be watching this initiative by Google very closely because App Inventor could redefine how the market, particularly consumers, thinks about computers and software.

Gibbs hacks in Ventura, Calif. Your metaphor to gearhead@gibbs.com.

Join the Network World communities on Facebook and LinkedIn to comment on topics that are top of mind.

Copyright © 2010 IDG Communications, Inc.

SD-WAN buyers guide: Key questions to ask vendors (and yourself)