Phosphor - Updates

I've updated the Phosphor interface again. There are a few additions that make things a little easier to use:

The object inventory support is currently very primitive, and will eventually be replaced with a server based storage system. Storage of some objects currently just freeze Safari, since it is incapable of breaking some types of circular references. But overall, it is suitable for storing very simple data structures for later use.

A Book on Programming

For the past year, I've been working on a book on programming. The intended audience is the 'self-taught' and non-programmer markets. Rather than writing a book for computer scientists, I'm writing a book for all those who would like to use their computer as a tool. My hope is that by breaking down some of the walls that prevent "ordinary" people from learning to do basic programming tasks, it will make computers more useful and less intimidating.

A large part of the problem with modern computing is the belief that it requires expert knowledge to do anything useful. As with much of our society over-specialization has created the seemingly insurmountable complexity in the system, that novices often are overwhelmed the appearance of irreducible complexity. And while these appearances serve the experts well, the reality is that many people can learn to do basic computing tasks for themselves. Excel and Word macros are a primary example of how ordinary people can learn to program and automate basic tasks, much to the dismay of professional programmers.

The Phosphor project is part of this effort to provide "ordinary" users with a tool that would allow them to do useful web programming after learning a minimal amount of Javascript. Being able to embed movies, images, or sounds in an application, and tie them to events can be a powerful tool, especially compared to tools like PowerPoint. Similarly, I've demonstrated to a few professors in non-technical fields of study, how they can use Phosphor and some very simple code to produce dynamic graphs from various data sets they already have. The idea of being able to write ones own tools by adding a few lines of code to an existing object is a very compelling to non-programmers. The trick to it is keeping the vocabulary sufficiently small, and removing unnecessary barriers to entry.

Barriers to Entry

If you look at a typical web programming environment there are a number of barriers to entry:

Attempting to teach a novice programmer to write code for existing browser technology is consequently an exercise in futility. These hurdles exist because they make life easier for professional developers, who already have a large amount of time and energy invested in the status quo. But assuming your audience has no prior experience or any vested interest, these "features" only become a hinderance to learning the environment.

The Phosphor API

The Phosphor programming environment attempts to simulate a computing environment, and does not attempt to be a "web programming" toolkit. It has a small number of objects, which build upon each other like Lego bricks, that define a simple state machine for 2D graphics programming. It also effectively hides the browser's interface to resources, allowing the programmer to focus on simply supplying URLs, and not have to worry about connection state. The core objects of the system are as follows:


The Box is conceptually a container in 2D (or eventually 3D) space, and provides a uniform interface to positioning and scaling objects


The Widget forms the basis for all scriptable elements, and provides the interface for objects which receive event notifications.


The Display is a widget that handles the scrolling and background drawing for the interface.


The Screen is a 2D vector graphics state machine based on the HTML5 canvas, it has a very basic 2D api for drawing lines, arcs, rectangles, rounded frames, text, and images.


The Event is a message object that is dispatched to widgets for both user driven and autonomous system events. The methods associated with each event type are:
  • down
  • up
  • move
  • pressed
  • tick
  • draw
  • scroll


The Device is the base for all objects which can dispatch events. It forms the basis of Keyboard,Mouse, and App


The Keyboard device handles dispatching pressed events and keeping track of modifier key states


The Mouse device handles dispatching up,down,move, and scroll events


The App device handles dispatching tick and draw events, and maintaining the delay between frames


The Resource object forms the basis for loading of all HTML resources, images, sounds and movies


The Sound resource controls the playing and pausing of audio resources


The Image widget handles the display of image resources


The Movie widget handles the display, playing, and pausing of HTML video resources. It currently displays in an overlay div.