Tuesday, September 17, 2013

Why Scratch?

As indicated in the previous blog, I am developing a suite of software dealing with retirement income scenarios using the Scratch programming language. Those who know something about Scratch may consider this a strange choice. Here I'll try to show why I consider it well suited for this project.

I have been writing computer programs for over fifty years. My PhD dissertation included (in addition to an early version of the Capital Asset Pricing Model) the description of an algorithm for solving a special class of portfolio optimization problems and a program for implementing it. Since then I have written programs in a variety of languages. I published the first commercial book on the BASIC language and wrote an interpretive compiler to implement it when I was at the University of Washington. For my own research I now use Matlab, a scientific programming language. For years I used the standard Matlab constructs but now rely on the more recently added object-oriented capabilities. I love to program – there is much gratification when a program does what you intended it to do -- more than enough to offset the frustration when it doesn't.

I also feel very strongly that everyone should be exposed to programming as part of the curriculum in Junior High School and/or High School. The benefits are many. Students can learn to think logically, divide complex tasks into a series of sub-tasks, test ideas rigorously, and explore aspects of mathematics, statistics and many other fields by doing experiments. They can also gain a deeper understanding of the ways in which computers, tablets, phones, televisions, movies and many things we encounter in our daily lives do what they do. Most people now spend hours every day interacting with technology but in an important sense they are interacting with programs. One hears “the computer did such and so” but it would be more accurate to say that a program made the computer do it.

Most important, as the Scratch team emphasizes, one can experiment and be creative when writing programs – far more so than when using programs written by others.

Unfortunately, programming is included in the required public curriculum in only a minority of public schools in most countries. There are groups trying to fill this need – see, for example,Computer Clubhouse, Coder Dojo, and Code.org. But far more is needed.

Since I had never taught pre-college students, I thought it would be a good idea to understand more about the benefits and challenges associated with including programming in the curriculum. I began by researching languages that would be suitable for doing so. I very shortly narrowed my list to one – the Scratch Programming Language developed at the Massachusetts Institute of Technology (MIT) ( scratch.mit.edu)– for reasons that I'll give shortly. I spent some time learning the rudiments of the language and then volunteered to teach it to a small group of middle school students in a summer program sponsored by the Community Partnership for Youth in Seaside California, near my home in Carmel. I had a great time, as did the students. We wrote programs to create designs using geometric figures, to administer arithmetic tests, to run a horse race and to allow people to play pong. The students learned key aspects of logical thinking, how to break tasks into key components, and some applied mathematics. They also gained a better understanding of how much of the world of technology works. I learned as much from them as they did from me. Most importantly, it was great fun for us all.

More than ever, I am convinced that the school curriculum needs to include programming. And that the best language, at least for the first course, is Scratch.

Scratch was developed and is supported by the Lifetime Kindergarten research group at the MIT Media Lab. Work began in 2003 and the first version was launched publicly in 2007. At present there are over one million members of the Scratch Community and over three million projects have been posted on the Scratch web site.

Here is a description of the choice of the name from a 2009 article by the members of the team ( Scratch: Programming for All).

“The name 'Scratch' itself highlights the idea of tinkering, as it comes from the scratching technique used by hip-hop disc jockeys, who tinker with music by spinning vinyl records back and forth with their hands, mixing music clips together in creative ways. In Scratch Programming, the activity is similar, mixing graphics, animations, photos, music, and sound.”

The most recent version, Scratch 2.0, became public in May, 2013. It allows users to write, edit and run programs using only a browser. Programs may also be downloaded to the user's computer. A downloadable version of the language editor and processor is also available (in a beta version as I write this).

Anyone may join the Scratch community, create programs, and, if desired, make them available on the Scratch website. Any program made public by its author may be used by anyone. It is also possible to “look inside” to see a public program's code. Anyone may adapt such a program for other uses, subject only to the terms of a Creative Commons attribution and sharing license. As indicated earlier, users are encouraged to “remix” existing programs in order to create new capabilities (with attribution, of course) .

There are no charges. The Lifetime Kindergarten group has received support from the likes of the National Science Foundation, the Intel and Microsoft Foundations, the MacArthur Foundation, Google and many others. Your support is also welcome but not required.

It should not be surprising that an undertaking of this importance and quality comes from MIT. A legendary pioneer in the use of computers by people of all ages was Seymour Paper, who developed the Logo programming language. Indeed, Mitchel Resnick, the head of the Lifetime Kindergarten research group, recently published a description of the genesis of Scratch under the title Reviving Papert's Dream.

This is not the place for a detailed description of Scratch. Resnik's recent paper is an excellent introduction, as is the formerly cited 2009 paper by the entire Scratch team. Here I'll give just a flavor of why it is different from most conventional programming languages.

First, there are no error messages because it is very difficult, if not impossible to make a syntactic error. The grammar is based on a set of graphical programming blocks and items that are “snapped together” to create a program. And the items have shapes and colors that indicate their nature. If a something doesn't fit in a location, it can't be used in that manner. This avoids myriad errors, at the relatively small cost of requiring more grabbing, moving and assembling than required in most programming languages.

Scratch has many attributes of a modern object-oriented programming language. Objects (called sprites) can have local variables and methods. Sprites communicate by broadcasting and receiving messages, which allows for more modular programming and event-driven execution. As indicated earlier, there are features that facilitate animation, graphic user input, graphic output, sound, inclusion of photos, external material and much more. If desired, programs can even be written to process input and output from some external devices.

All these features make Scratch ideal for its intended purpose. The 2009 paper states: “The core audience on the site is between the ages of eight and 16 (peaking at 12), though a sizeable group of adults participates as well.” The students that I taught were between 11 and 13 and I can attest to the suitability of Scratch for that demographic. But next year I will be five times as old as the upper limit of the range for the core audience. Is Scratch right for me and for my work on retirement income? I think so.

As I have learned more about Scratch and used it for complex projects, I have realized that the underlying structure is truly brilliant. The structure has been carefully crafted to allow great generality but with consistent and highly logical underpinnings. To be sure, there are limitations, but one can get around most of them or adapt as needed. At present I have not stressed the system by attempting very large simulations with sizable intermediate data, but early experiments indicate that Scratch can accomplish rather complex tasks quite efficiently.

So, here is my plan. I will start with an overall structure that allows me to add features as items on a menu. The first release will have only one such feature (a “longevity graph”). Subsequent releases will add other features, all related in some manner to the forecasting and analysis of retirement income scenarios. I invite you to try the programs. Together we will see how far this undertaking can go.

3 comments:

  1. Hi William, scratch is a great technology donated to the world at large from MIT, thanks MIT. I learned about it taking the online Harvard CS 50 class and was truly amazed at the functionality ability to quickly create and execute some ideas.

    I look forward to seeing what you can do in regards to the retirement income conundrum.

    Jeff Lippe s

    ReplyDelete
  2. It was with great interest that I read the topic shift from personal finance to teaching children about programming. My wife and I started a coding club with our middle school son last year. We used codecademy since it's all web based and did not require any software installation on school PCs. This year, as he enters high school, we are starting up there while keeping the middle school going. There is a significant need for this, as you describe.

    ReplyDelete
  3. Thank You For Posting And Sharing With Us.It Is Very Useful For Me Keep It Up.
    Online Financial Planning.

    ReplyDelete