Stored State

The State-of-Being State

State can be such a strange word. In computer-speak, it corresponds roughly to everything about the computer at a given moment—everything that is in memory, what programs are executing and what instruction they are currently processing, signals to and from input and output devices, and so on.

In this course, “state” encapsulates attributes—a description of what the computer is doing at any given moment.

Input and Storage

Up to this point, we have created programs that deal with the following computer functions:

  • Input
  • Storage
  • Processing (We instructed the computer to make calculations, such as adjusting location and orientation, or count beats per minute for synthetic drum beats.)
  • Output (Our focus has been primarily centered on output—observable behaviors generated by the computer such as animation, sound, and text.)

To be fair, our programs have used input and storage to some degree. For example, clicking the green flag in Scratch is a form of input. We interact with this control to signal the computer to begin the program.

Our use of storage to this point is more abstract. Consider the what the computer needs to “remember” in order to execute the program.

First, it needs to “remember” the program—what are its instructions? Second, there are attributes about the environment it needs to “remember” in order to function properly. These attributes are called state. An example of state in our previous programs is the location of Scratch the Cat. In order for the program to move [10] steps, it needs to “remember” where Scratch the Cat is actually located. However, these instances of input and storage are not ones we explicitly control. During our next few activities, we will focus on customized input and storage.


The sprite occupies a point (x,y) on the stage corresponding to the x- and y- axes below. How is a sprite’s state related to its position on a coordinate grid? How are position and state different?