Scratch is a much loved visual programming application, created by the Lifelong Kindergarten Group of MIT Media Lab and often used for providing a first introduction to coding. For good reason it’s one of the six coding tools displayed in the programming menu of the Raspberry Pi. There’s a common impression that visual languages are just for beginners, and have to be replaced by textual languages for ‘proper’ programming.
‘there is a limited benefit [of Scratch] in a college level education.’ 1
You may have heard that there are two versions of MIT’s Scratch, version 1 (as made available on the Pi), and version 2 (which is not).
So, thinking about the question ‘How do you write a new programming tool, such as Scratch?’—the answer is; you write it in a programming tool/language you have already. In MIT’s case, the have already was called Squeak Smalltalk—which has an influential pedigree in computing education. This was the basis of version 1.
Smalltalk is famous as the programming language which had/has an integrated development environment which blows other IDEs out of the water. (Smalltalk is still a great language to learn Object-oriented programming alongside; say with Squeak, or its sister environment Pharo Smalltalk, and a book such as Pharo by example). But, beware, it may spoil you for many of its successors ahem, Java.
Anyway, following on the success of the original Scratch, for version 2, MIT re-implemented it in ActionScript on Adobe’s Flash. This was an understandable decision, given the (at the time) popularity and reach of Flash, and included new features, such as the ability to define your own blocks. It has enabled a large creative community to be built, but Flash not having availability or suitable performance on many current systems such as iOS, Raspberry Pi may start to limit it.
The Scratch-alike explosion
Meanwhile, others have been looking at the Scratch approach, and adapting its ‘gentle start’ design to their own needs, for example Google’s Blockly, and Microsoft’s Block editor for their Touch Develop tool.
Scratch is also being extended to control hardware, for example ScratchGPIO on the Pi.
One distinctive adopter of Scratch’s philosophy is the Snap! project. This comprehensively demolishes the ‘only for beginners’ label.
Brian Harvey is a veteran computing educator. He’s had great influence with things like the series of books Computer Science Logo Style (which nearly 30 years on, are rewarding and challenging reading) and the simply great Simply Scheme.
Kids get caught up in the excitement of programming, in the same way that other kids (or maybe the same ones) get caught up in acting, in sports, in journalism (provided the paper isn’t run by teachers), or in ham radio.2
The main feature which distinguishes Snap! from Scratch is its aim is to give all data first-class status. That is, you can put it into a variable, give it as an input to a procedure, return it as the result of a procedure. This turns out to be a big deal, which greatly expands the range of problems Snap! can be used in.
In the example, there’s the block definition for 5-er, a procedure which is obsessed with the number 5. The input to 5-er is shown as func λ which says that what gets passed in is a procedure. The body of 5-er calls whatever procedure that happens to be, with the number 5. So passing in the procedure 10 + gives the result 15. And you can guess what calling 5-er with square does.
Snap!’s design means it can extend itself with features like object-orientation, and programming structures like binary trees and linked lists.
Beauty and Joy
The family of Scratch is very active, growing fast and is going to continue in its role of kindling ‘learning fun’ in computing.