Scratch is a programming language designed for beginners.
Scratch is block-based: instead of typing in code, you drag blocks around. Since the block shapes only fit fit together in certain ways, syntax errors are impossible. This makes it beginner-friendly.
I’m working on tosh, a new editor for Scratch projects.
tosh is text-based: you type code using a text-based syntax which is compiled into Scratch projects; thus defeating the whole point of Scratch.
So, why am I making tosh?
Scratch is cool
Scratch is a unique programming environment. It is:
Tangible. I don’t mean you can touch it. But the basic metaphor of a “stage” with movable “sprites” is easy to grasp, and surprisingly powerful.
2D graphics is built-in. No other language does this in quite the same way.
Immediate. You can click any block or script to evaluate it. This lets you see its effect, like in a command-line interpreter.
But in the same pane, you can snap together blocks to make larger scripts, and then execute those. There’s no disconnect between the program and the environment in which it runs, and certainly no compilation step. (Which allows for nice features like storing variable values inside the project. They’re not reset when the program starts, unless you do so explicitly.)
Scratch even allows you to change parameters, and entire scripts, while they’re running.
Social. There’s a web-based project player, and a large community of people who view, comment on, and remix projects.
Some people deride Scratch due to its limitations. Lists aren’t first-class; subroutines can’t return values; and until recently subroutines weren’t supported at all. The lack of features like these makes advanced projects more difficult.
My friend Connor-from-the-internet wrote about how making things is more important than programming. He said:
…I’ve noticed a pattern that seems to apply to a lot of people:
join Scratch => create projects => discover text-based programming => quit Scratch because of “real programming”
[…] Generally, a “real” programming language is text-based (C, Python, etc.) and apparently qualifies as real because it’s used by well-known developers for something.
Obviously I disagree with disqualifying Scratch as a real programming language.
I emphatically agree with the latter: Scratch is a wonderful language, useful for real projects.
Scratch may be limited, but I find its constraints interesting! Many things which are easy in traditional languages are hard to do in Scratch, so you have to think up alternative solutions which you wouldn’t discover otherwise. The challenge is rewarding, as evidenced by professional software engineers who make Scratch projects as a hobby.
I can’t understate just how easy it makes graphics. My friend Dan is envious of how quickly I can use it to prototype games and physics toys.
Most importantly, Scratch is fun. It’s immediate and simple, which is refreshing compared to most modern programming environments. (The amount of incidental complexity we programmers put up with is astounding! But that’s a story for another time…)
Text is quick
Scratch is not just a unique interface; it is also a unique programming language. The language itself is interesting and useful, even after removing the blocks.
Admittedly text loses some of the benefits above, like immediacy and overall beginner-friendliess. But we can make up for these in speed. It’s self-evident that typing is quicker than drag-and-dropping blocks from the palette. And it avoids the pain of editing long scripts in Scratch, whose editor slows down on sizeable projects.
tosh won’t have live editing, because it’s hard. But I’m planning to embed phosphorus into the editor, which should at least avoid an awkward compilation step.
Block names will be harder to discover. But I can mitigate this by implementing autocomplete, and by targeting people who are already familiar with Scratch’s command set.
And text allows operations like find/replace, which blocks can’t.
Scratch is a good language, but its block-based interface is awkward for advanced projects.
tosh is for people who are good at Scratch, and want to make projects faster.
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.
I don’t agree with the idea that Scratch isn’t “real programming”, but I hope tosh will appeal to people who do.