Skip to content
March 3, 2012 / Ben Chun

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!]


Leave a Comment
  1. Jens Mönig / Mar 4 2012 8:42 am

    Hi Ben,
    thanks for your thoughts on BYOB. I just wanted to let you know that BYOB (and also Snap, BYOB’s successor) actually has the REPORT primitive that you want, and you can use it in exactly the way which you describe here, i.e. as an alternative to the default report field in the block editor. In the next version of BYOB – which will be named Snap 4.0 – we will remove the report field and only offer the REPORT block.

  2. Ben Chun / Mar 4 2012 9:10 am

    Well would you look at that… thanks Jens! I never noticed REPORT in the Control palette, but there it is. What do you think about offering a special palette in the block editor with a REPORT that corresponds to either general reporter or (boolean) predicate return value? Is there any other context (outside of the block editor) where REPORT can be meaningfully used?

    • Jens Mönig / Mar 4 2012 10:46 am

      We need REPORT outside the block editor in lambda expressions (when answering a value from within a THE SCRIPT block), which lets us teach dispatch-procedure style OOP (closurized temporary variable turning into objects), and – that’s new in Snap 4.0 – first-class continuations (call/cc).

      I like your suggestion about offering a REPORT block with the corresponding slot shape in a special palette inside the block editor, and I’ll think about it. In fact, the first version of the block editor already had such a palette, but it was mainly for temporary variables before we invented the SCRIPT VARIABLES block. Since then we’ve been glad to be able to simplify the block editor by eliminating the special palette from it.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: