Scratch and BYOB Report
I hear that Scratch 2.0 will include procedures, a capability that has only been available in BYOB until now. This is great news, because functional abstraction is one of the most fundamental concepts in programming. In my high school classes, I always find that I need to switch from Scratch to BYOB at some point so that students can create more complex programs without getting tangled in a million stacks of blocks that all broadcast messages to each other and rely on global variables.
It pains me to lose the sharing and community aspects of Scratch when we switch. But BYOB does a great job with adding power, making blocks themselves first class and offering the ability to create “command”, “predicate”, and “reporter” blocks. These three categories correspond with functions that return nothing, return a boolean, or return some other value. Because this “return type” determines the shape of the block, which in turn determines where that block can be used, it’s an important choice.
I hope the Scratch team includes all three of these. Commands alone will leave us needing to use global variables for outputs even if inputs are passed in as parameters. This means we can’t fully teach the value of encapsulation and abstraction — knowledge about the larger programmatic context will always seep in to our otherwise isolated function definitions.
There is an interface challenge, however. In BYOB, when you create a reporter, the return value is specified at the bottom of the dialog, in an awkward little box that isn’t a part of the program flow.
Early returns would be nice. For example, I’d love to be able to write this implementation of linear search:
But that means having a “report” command that only has a meaning/use inside reporter blocks. And then for predicates (that is, boolean returns) do we have a restricted version? This seems to invite confusion. Here’s my proposed solution:
A reporter block palette, only available within the block editor, containing a report command with the correctly-shaped parameter (depending if we’re creating a reporter or a predicate). I’m not sure if this idea has already been proposed or discussed, but I wanted to throw it into the mix. Perhaps the “script variable” block could live there as well, to encourage the idea that local variables are local.
[Update: I just talked to Mitch Resnick here at DML and found out that Scratch 2.0 will implement commands using a special cap, not blocks in an editor dialog. And they will not implement reporters or predicates. So I think my user interface idea is actually a suggestion for improving the interface in BYOB/Snap!]