New Scratch review

By Russell Barnes. Posted

Tucked inside Raspbian Jessie is a revamped version of Scratch full of new features. Lucy Hattersley takes it for a spin

Scratch is one of the best ways to introduce young people into the joys of coding.

Developed by MIT, specifically to help young people learn to code, Scratch is a visual editor with characters (known as Sprites) and blocks that react to, and control, the sprites. The blocks click together in much the same way that code is written, and clicking the blocks together creates programs.

The Raspberry Pi foundation's aim to build tiny and affordable computers for kids gels pretty nicely with Scratch's aim to help young people learn to code, so it's no surprise to see Scratch form part of the stock Raspbian operating system.

What you may not have noticed, is that the recent Raspbian Jessie update contained a revamped version of Scratch packing some great new features.

The new version of Scratch is based upon the same edition of Scratch (version 1.4) but it now runs much faster (up to 10 times as fast in some instances) and has native support for the GPIO pins. Let's handle the speed boost first.

The need for Speed

While Scratch is developed by MIT, it's brought to the Raspberry Pi thanks to the hard work of a developer called Tim Rowledge (rowledge.org), and it's from his endeavours that we should thank for Scratch's souped-up engine.

Scratch was originally developed in a language called Smalltalk, and it runs inside a Squeak virtual machine (VM). Tim has spent time a lot of his time ensuring that Squeak runs on various ARM-based systems like the Raspberry Pi (mostly because he's a RISC OS fan). Tim says he spent time "rewriting some of the more egregiously ugly code, improve algorithms, tweak VM configurations and so on."

While direct speed comparisons depend on a lot of factors, a version of Pac-Man created in Scratch by Andrew Oliver is now running at a playable 30fps (up from 16fps on the Raspberry Pi model B and a mere 1 fps on the original Pi).

This faster speed isn't just a nicety. The way Scratch gets kids coding is by recreating games, and game-like environments. The improved Scratch performance prevents young people from hitting a performance limitation and switching off.

Using Pins

If the speed boost wasn't enough, Scratch now incorporates GPIOServer so you can directly access the pins on your Raspberry Pi.

It's been referred as a "first pass" at GPIO implementation, and it's a bit clunky. Scratch has no GPIO blocks. Instead, you use the Broadcast block to set up pins, monitor input and set them on or off. It follows the BCM standard, so you add a Broadcast block and enter config17out to set pin 17 to output, and then gpio17on and gpio17off to turn the pin on and off.

For input, you use config17in and then combine an If control block with an Operator and Sensing block to to get a block that says: If GPIO 17 sensor value = 0/1. When you add GPIO pins they appear in the sensor blocks

We would like an easier implementation for young coders to understand, but the good news is that there are lots of examples included with the installation, and tutorials are being developed (or rewritten) on the Raspberry Pi website. So, you won't be short of assistance in getting to grips with it.

 The GPIO additions are a great way to open up Scratch

Teaching with GPIO

There is something truly joyous about combining Scratch with GPIO. It breaks the barrier between Scratch visual programming and physical hardware. You can create LED traffic lights that respond to sprites of cars; or build a joystick from switches to control on-screen characters. These are software and hardware projects that will inspire kids to get started.

As a bonus, many Hats are supported. We rather like the idea of hooking up Scratch characters to Pibrella, PiGlow and SenseHAT devices.

Send in the clones

If there is one slight wobble, it's that this is still Scratch 1.4, rather than the newer Scratch 2.0. This is because MIT moved over to Adobe Flash for Scratch 2.0, and the offline app installs using Adobe Air. So we're stuck with the older version of Scratch until either Adobe starts to support ARM devices with Adobe Air, or MIT either rewrites Scratch in a different language.

This isn't a big deal for the most part, but Scratch 2.0 does include a feature called cloning (via the Create Clone Of block), which is very close to the object-orientated process of instantiation and inheritance. This is something we'd love to see in Scratch on the Raspberry Pi, but we'll take GPIO access over it any day.

Last Word

4/5

The new version of Scratch breaks the barrier between hardware and software and creates an ever more fun learning environment. And the speed boost makes more exciting programs playable. It's a shame development is revving on version 1.4, but don't let that spoil things. This is a fantastic update.

From The MagPi store

Subscribe

Subscribe to the newsletter

Get every issue delivered directly to your inbox and keep up to date with the latest news, offers, events, and more.