Text-based Scratch using tosh

Today I had a first look at the public beta of tosh, a text-based version of Scratch created by Tim Radvan that I’ve been excited to try out for a while. Although tosh does have an offline app for mac, it’s also available online (and doesn’t use Flash! 🎉). Here’s my first attempt at writing a tosh program:

Screen Shot 2016-04-10 at 11.13.39.png

The tosh syntax is (almost) identical to Scratch, and coding in tosh felt very familiar from the start. There were, however, times when I didn’t know the exact tosh syntax. For example, what is the syntax for a ‘turn’ block? I also couldn’t remember whether it’s ‘goto’ or ‘go to’. The tosh IDE includes some really useful features, including syntax highlighting (the text is colour-coded using the Scratch category colours) and tabbed autocomplete. It was the latter that really helped me get used to writing text-based Scratch very quickly:

The compatibility with Scratch means that existing Scratch resources (including Code Club’s Scratch projects) can be completed using tosh. This means that there’s already a huge amount of tosh learning resources available, and there will be minimal effort required to create new resources for this new text-based language! The familiarity of the tosh syntax will also be a huge benefit to teachers, giving initial confidence when moving to text-based languages for the first time.

In fact, it’s even possible to import and export project files between Scratch and tosh (both use the same .sb2 file extension).

tosh is in beta, and obviously there are a couple of improvements to be made. There’s no colour picker, so coding ‘touching colour’ blocks is quite difficult if using images with non-basic colours. The ‘join’ block syntax also doesn’t look very intuitive in text format (i.e. ‘say join join “hello” name “!”‘ would look much more natural if the ‘say’ block just had multiple input parameters). However, this is a very small price to pay for compatibility with Scratch itself, and this hurdle can be overcome by thinking “how would this look in Scratch?”.

tosh will be invaluable in helping children as they progress from block-based to graphical programming. Children will be writing code in a language that is already familiar to them, albeit using a different input method. They will already understand the concept of the stage, sprites, and how to make sprites do what they want them to.

As Tim puts it on his blog:

I also hope that tosh might let beginners transition to text-based coding: as their creations become larger and more difficult to work with inside Scratch, they can edit them using tosh. They can learn about syntax errors, and how unforgivingly precise computers are, entirely separate from the concern of learning a new programming paradigm.

Children could start by recreating some of their existing Scratch projects in tosh, or even opening a Scratch file in tosh and making small amendments to their code. Not only is the syntax familiar to children, it’s also easy to write. Parentheses are kept to a minimum, the ‘end’ keyword means there are no difficult-to-type characters to delimit code, and the autocomplete feature minimises the amount of typing further.

The tosh environment allows children to write text-based programs that have an exciting graphical output, whist hiding the associated boilerplate code. This has been one of the criticisms of using Python with Pygame as an introduction to text-based programming.

tosh looks like a great way to introduce children to text-based programming, and I’m looking forward to using it in my Code Club.