Scratch performance – feel the speed!
The Scratch programming language, developed at MIT, has become the cornerstone of computing education at the primary level. Running the Scratch environment well was an early goal for Raspberry Pi. Since early 2013 we’ve been working with Tim Rowledge, Smalltalk hacker extraordinaire. Tim has been beavering away, improving the Scratch codebase and porting it to newer versions of the Squeak virtual machine. Ben Avison chipped in with ARM-optimised versions of Squeak’s graphics operations, and of course we did our bit by releasing two new generations of the Raspberry Pi hardware.
We thought you’d enjoy these two videos. The first shows Andrew Oliver’s Scratch implementation of Pacman running on an Intel Core i5 laptop with “standard” Scratch 1.4. (Yes, that Andrew Oliver. Thanks Andrew!) The second shows the same code running on a Raspberry Pi 3 with Tim’s optimised Scratch. The Raspberry Pi version is roughly twice as fast.
This is a great example of the sort of attention-to-detail work that we like to focus on, and that can make the difference between a mediocre user experience and the desktop-equivalent experience that we aspire to for Raspberry Pi 3. We think it’s as important to work as hard on improving and incrementing software as it is to do the same with the hardware it runs on. We’ve done similar work with Kodi and Epiphany, and you can expect a lot more of this from us over the next couple of years.
29 comments
karan
Great job guys.Keep it up.
alex eames
Looks great. Well done. It’s not often that this kind of work ever gets done to squeeze every last drop of performance out of the hardware. It’s nice to see it happening. :)
Niall Saunders
@Alex Eames:
“It’s not often that this kind of work ever gets done to squeeze every last drop of performance out of the hardware”
You’re right there – brings back memories of Elite on the Beeb, along with the standard question asked at the time, “how the h3ll did they do that?” !!
ric96
damn
jonathanschaffer
you running mac?
Winkleink
If you want to see the change in performance just from Raspberry Pi optimisation I did a video of Scratch running on a model A (256MB) with no acceleration.
Using the oldest Raspbian and most recent Raspbian images available st the time of recording.
Tim Rowledge and the team have done an amazing job.
Then you add the extra power of the Pi3 and the difference is even greater.
Same £30 gets fat more capability.
https://youtu.be/ThALBRLY9Rs
Toby
Next step: scratch 2.0
Liz Upton
Actually, we’re not going that route. The fact that it’s Flash-based is a bit of a gating problem – and you’ll find that the functionality like GPIO integration in NuScratch actually makes it rather more powerful than Scratch 2.0 can be.
Toby
You (could) re-write the source code of flash, optimising it for the pi.
tai viinikka
“You (could) re-write the source code of flash, optimising it for the pi.”
Or … flash could die a well-deserved death and get out of the road, to be replaced by something more secure, more open, faster, and with less spaghetti. I bet lots of people think this is a good idea!
tim Rowledge
I pretty much agree with your sentiments about Flash.
Updating Scratch to 2.0 compatibility (file formats, a few new blocks, clone sprites) is certainly much easier within Squeak. Apart from anything else it’s a lot faster than Flash.
hiccup01
Have you ever tried Whiskers? It’s NoMod’s attempt to turn scratch 1.4 into 2.0 by adding 2.0’s features to scratch 1.4. That way GPIO functionality and other features could be kept while satisfying the community’s wants to be able to open and create .sb2s (Scratch 2.0’s file format). I’m sure NoMod would like some help with his project. https://scratch.mit.edu/discuss/topic/157672/
CT
Any plans to add Bluetooth messaging support to Pi SCRATCH? Or is the best way to go about adding new features SCRATCH is to create a python library and pass messages back and forth with the python code translating to the api?
tim Rowledge
First thing – add a message about this to the Scratch forum so it doesn’t get lost to notice.
Second thing – in that message, please explain what Bt messaging is in this context; I’ve never heard of it, so you may need to be patient in your explanations!
Paul Sutton
Any plans to optimise software such as Scratch4arduino which also runs on the Pi, ?
http://s4a.cat/
This runs nicely on the Pi, which is handy for introducing people to Arduino coding, just needs a sketch on the Arduino that acts as a bridge between the scratch environment and the hardware.
tim Rowledge
I’d love to. S4A has been in my sights for ages along with Enchanting, a robotics driving Scratch, and of course BYOB/Snap. If you can persuade enough people it’s important to the future of Pi related education I imagine it might get added to my Do This Soon list.
Toby
http://vps34736.ovh.net/S4A/S4A15_RP.deb Try visiting this link…. It will work on the raspi.
Andrew
Very cool!! Does your version support the PicoBoard and WeDo on the PI3?
tim Rowledge
Poco oars (or more precisely the SparkFun Scratchboard) issue ported and works well in the lab. Wait, what? ‘Poco oars’? Damn You Autocockup! I think you get the picture.
WeDo may work; I’ve never had acces to any to try and don’t seem to have heard from anyone either way. The plugin is in there, so if you have any of the hardware please let me know – in the forum! – how it goes.
Nothing is different on the Pi3 except it’s a bit faster.
Igor Ganapolsky
Wait, so Scratch is worthwhile learning now? More worthwhile than Java and Python? I’m curious, what benefits will be guaranteed to me if I use Scratch over these traditional languages on the PI…
Steve Richards
I would say if you are somewhere between the age of 4 and 12 its certainly worthwhile.
Similarly, if you are an adult who has no programming background whatsoever and want to learn it’s ideal.
I wouldn’t use it to write an Operating System though.
tim Rowledge
I wouldn’t use Scratch to write an OS either; but the language underneath it, Smalltalk? Why yes, as it happens I have done just that in the past. Sadly it was very proprietary.
Igor, I’m fairly sure that no language guarantees you anything much. And Smalltalk has been around a lot longer than ‘traditional’ languages such as Java and Python.
Peter Einig
I am 65 and have learnt to code using SCRATCH. Gaming is not for me but have always liked robots so Pi BUG was developed. A three wheeled robot using GPIO’s and SCRATCH, controlled via Bluetooth or wifi. An early intro to robotics before moving on to say PYTHON but makes use of STEM for the educationalists. Photos on Facebook at Cotswold Jam.
mobluse
As said before Scratch is mostly for beginning programmers, but Scratch has an active community on http://scratch.mit.edu/ so you probably get more feedback about your programs there than on e.g. https://GitHub.com/ or http://appinventor.mit.edu/.
Bob LeSuer
FWIW I just piloted a “made *WITH* scratch instrumentation” activity in my (college-level) chemistry course. Students in my class have zero programming background yet I want them to be able to create a computer interface that controls a student-made instrument and displays the results. Scratch came in very handy (especially the ability to control GPIO pins) in that the programs were very easy for students to create, and use to build their instruments. Ultimately, Scratch on the Raspberry Pi allowed me to incorporate physical computing and programming constructs into a Chemistry class without sacrificing a significant amount of class time on off-topic content like programming-language syntax.
tim Rowledge
Bob please try to give us more on this! A small post in the Scratch forum (the local one rather than the MIT one) would be great, pictures welcome etc.
Bob LeSuer
Done: https://www.raspberrypi.org/forums/viewtopic.php?f=77&t=145662
Looking forward to people’s comments.
Ben
Having used scratch a little bit, I cannot see why people wouldn’t want to use it for quite a lot of the programming performed on the Raspberry Pi’s.
It’s easy to pick up, works and of course the visual nature helps a lot there. No need to learn the intricacies of python or whatever you need to do to convert python2 code to python3. Sometimes life to short for that sort of thing when you can quickly pick up scratch and get it done.
Having used another visual setup way back when in the form of LabView, it very similar in the way it works from my point of view and that was used to run large machinery and laser control systems and simple loops and maths…
stephen
that was very helpful thx