Skip to content

Why Build Your Own Blocks?

2010 August 19
by Hélène Martin

The Scratch interface.

Scratch provides a drag-and-drop environment for experimenting with programming and building sophisticated interactive artifacts.  Programming constructs are represented as blocks that can be dragged onto a scripts area to control the behavior of particular objects on the “stage.”  Scratch provides all the common constructs from imperative languages — definite loops, indefinite loops, conditionals, variables, etc.  It also provides a nice model for concurrency and message passing which are traditionally considered advanced topics partly because of prohibitively complex syntax but of course also because getting it just right is truly difficult.  Lots of niceties are included like ways of accessing mouse and keyboard events or producing sounds.

A big complaint about Scratch has been the absence of means of abstraction: message passing is the best way to get something subroutine-like and the world objects are independent instances with no way of capturing commonality.  In other words, there are no functions and there are no classes.

This lack of means of abstraction is a mixed blessing.  On one hand, if we consider one of the major concerns of computer science to be managing complexity, then the Scratch model really fails to provide exposure to a huge chunk of the field.  On the other, what we have now is an environment in which children and adults who retain a sense of childlike wonder truly can be expected to discover and create entirely on their own.  There are no hidden menus and nothing that really behaves any way other than what would be expected. That, to me, is very exciting, because it allows me to get my rambunctious 9th graders problem solving right away.

Now, thanks to Smalltalk programmer extraordinaire Jens Mönig and the vision of Brian Harvey from Berkeley, there does exist a version of Scratch with means of abstraction and it’s called BYOB.  I don’t know whether this is a measure of the excitement for the project or just of how much the WWW is still run by computer scientists but it currently comes out as result 6 for the search term ‘BYOB’ on Google, before songs and allusions to tasty beverages.  There also exist a pretty nice Scratch wiki page and a manual.

(I should note that lots of people will point to Alice as an example of a drag-and-drop programming interface that has always included abstraction through classes and methods.  I think there’s a lot in Alice that detracts from the problem solving experience including 3D reasoning, too much focus on animation details and lots and lots of bugs.  I’m also not a fan of teaching OOP early.  Basically, I don’t like it so I won’t say any more about it, but it’s worth checking out.  Similarly, Squeak is Scratch’s more powerful but less intuitive parent.  There are also several other Scratch spinoffs that offer some of the same functionality and more.)

BYOB brings higher-order functions, nested lists, recursion, type checking, nested sprites, a basic OOP model and other goodies to the Scratch world.  Clearly, BYOB is an extremely powerful tool that gives a better sense of what computing can achieve.  That said, I don’t think I’m going to use it for teaching.

I’m very excited about abstraction.  I find it thrilling to think that a bunch of ever-richer abstraction layers have gotten us from bursts of electrical current to Facebook and self-checkout machines at grocery stores.  I want to share that excitement and that sense of infinite possibilities with my students as much as possible.  I’m also a pragmatist (or is it a defeatist?) — I understand that many of my students have never been taught to think abstractly and are very limited in that domain.

What I think is fantastic about Scratch is that it provides a context in which programming is concrete.  We can focus on expressing ideas precisely and ordering their substeps which students in my intro class also often have very little experience with.  The results are immediate: a cat draws a square, the background flashes, etc.  That’s a skill set that will be useful to students no matter what they end up doing with their lives.  Sure, they don’t immediately dive into the big ideas of computer science, but they make significant steps in that direction.  I find it exciting when they discover limitations of Scratch and complain about them (“Ms. Maaartin, why can’t I just make lots and lots of cats from one blueprint?!”) because I find it a nice segue to more traditional programming languages.  BYOB ups the ceiling on what can be expressed but I feel that once one has a deep enough understanding to want things like anonymous functions and have a true need for them, a drag and drop interface gets in the way more than anything.

Creating an input to a custom block.

I found the interface for creating a custom block pleasantly straight-forward — someone has clearly spent a lot of time thinking about how to make a really quite complex idea relatively easy to work with graphically.

In this example, I chose to create a reporter block named ‘double’ and then hovered my mouse over it to get the option to add an input.  I clicked on the orange ‘+’ on the right and got the dialog box titled ‘?.’  By default, the dark gray advanced options are collapsed and the input is untyped.  When the dark gray box is opened, I can choose a type for the input and control its scope.  Again, lots of power here, but also a lot of need for instruction to get anywhere near being able to use it effectively and deliberately.

I was creating this very simple procedure so I could double the contents of a list.  Map is a custom reporter and it takes a function and a list (in this case an anonymous one) as parameters.  What the heck is a reporter and how is it different from a command?  Maybe my initial confusion shows my lack of education and I haven’t yet dug too deeply into exactly what’s going on, but it looks like a reporter is a first class procedure that returns (“reports”) something and so it’s treated as a value to be used as part of expressions.  That’s in contrast with a command which is directly executed and can’t be used as part of an expression.  What’s interesting is that a difference is made between ‘reporters’ and ‘predicates’ — procedures that return booleans but there’s no differentiation between integer, string or list reporters.  Not sure what the ramifications of that are.

Clearly, there’s an elegance to what’s going on here, but my wrist really hurts from clicking everywhere.  Part of it is that I’m learning as I go, but even doing all this as efficiently as possible requires lots of digging around in menus and clicking and dragging.  Of course, I may be biased because I tend to like tools that let me use the keyboard — command line, Emacs, LaTeX — they may be slower for basic, novice use, but they’re much faster for complex applications by power users.  I guess I kind of see most of programming as a power user type of action.  Scratch managed to provide a limited enough subset of programming that I could see it as a nice novice tool but now BYOB is going into a territory I’m less comfortable with.

BYOB takes a lot from languages like Scheme which are celebrated as teaching languages because their core is small but expressive.  BYOB may still have a small core, but with it comes the need to understand and use lots of different kinds of dialog boxes and menus and radio buttons.  With BYOB, it’s not just a matter of learning the syntax for a define statement, it’s a matter of knowing and understanding all of the clicks and decisions needed to create a procedure.  And there are a lot.

I feel like students who really understand the ramifications of means of abstraction will also understand that typing keywords can often be more efficient than using GUIs.  On the flip side, I suspect that students who just see a lot of pretty colorful icons and are excited to make things move around on the screen will miss the implications of many of the deeper concepts BYOB tries to convey and are likely to get confused and frustrated by all the clicking and menus.  To me, some of the million dollar questions are

  • whether students get more excited about the pretty Scratch animations or by the pretty pictures generated through, say, the Racket “world” Teachpack which lets students create visual programs using function composition in a variant of Scheme,
  • whether the knowledge students acquire through using a drag-and-drop interface like BYOB transfers to more typical languages,
  • which of having to click around a whole bunch and having to memorize syntax and worry about parentheses or white space is less frustrating for novices.

It’s not clear that these can really be separated out and studied in any reasonable way or that anyone would be interested in doing such analysis without devolving into rants about when recursion should be taught but a girl can hope…

I’m curious to see more examples of BYOB used for instruction.  Dan Garcia and Brian Harvey have been using it to revamp Berkeley’s non-majors intro to computer science course and are calling their offering the Beauty and Joy of Computing.  This fall’s class is one of the 5 pilots for the proposed new AP Computer Science: Principles course.  I’ve heard of Josh Paley, great instructor from my former high school, using it with middle schoolers.  What else is out there?  What niche does it fill?

11 Responses leave one →
  1. August 23, 2010

    I like Scratch. The kids like to play with Scratch. I do not teach using Scratch for the simple reason there is no way to comment a program. I do assign some simple projects where they can use Scratch but as soon as things get complex I need the comments to figure out what is going on or what they are trying to do. I am more of a Small Basic fan for that reason. SB has some issues but for a beginning CS course I think it is a nice, simple way to go. Kids can still have some fun drawing and making simple games but it has many more traditional aspects of a “professional” language. Of course, if working with third graders, I am going to use Scratch. I am usually smart enough to figure out what they are doing.

    • Hélène Martin permalink*
      August 23, 2010

      You can add comments in Scratch by right clicking in the scripts area and clicking on “Add comment.” I agree that commenting is really helpful and I do ask my students to think a fair bit about it when they do Scratch projects.

  2. August 25, 2010

    Thanks for this thorough and thoughtful review! I appreciate that you’ve taken the time and effort to explore our toy down to the very bottom.

    But I’m afraid I can’t offer an answer to your onthological question (“Why”), other than “Because it’s fun!”. For me “Build Your Own Blocks” is not so much about bigheaded buzzwords like abstraction, recursion, anonymous procedures and extensible data structures. Instead the fun lies in designing custom blocks. Kids often start out by making very simple blocks which they feel are missing in Scratch, the first ones often being SWITCH TO PREVIOUS COSTUME, JUMP n STEPS, or – a little more daring – MOVE n STEPS IN m SECS. I don’t think there is any fundamental debate whether “build your own blocks” is desirable in Scratch at all, it’s really just a matter of making it work and designing friendly GUI. We’ve been discussing this with the MIT Scratch Team and they have announced that the next version of Scratch will let you “build your own blocks”. But it’s not yet clear whether that will include parameter passing and custom reporters (functions), too.

    Other more sophisticated concepts like recursion and first-classness (for HOFs) are allowed to “seep into” this play with custom blocks simply because they exist. We wanted to allow kids to put blocks and scripts into lists and to – say – execute them at random, because it’s fun! If that makes (some of) them realize that a blocks are simply another kind of data, much like numbers and text, then what’s wrong with that? That doesn’t mean that kids cannot play with BYOB without being exposed to scary hard stuff. In fact, we’ve bend over backwards to make these features as unobtrusive as possible. But we also want college students to have fun with Scratch, and support a full semester of introductory curriculum without having to switch programming languages midway.

    One more thing: Your screenshot of Creating an input to a custom block is awesome! You do realize, of course, that this single picture captures just about the maximum of sophistication you can possibly encounter in BYOB. Most custom blocks will be much easier.

    • Hélène Martin permalink*
      August 25, 2010

      I think you actually give the best possible answer for me — “because it’s fun” is something I can get behind 100%, no research needed. I did really have fun poking around with it, and that’s enough for me to believe that students would get a kick out of it. And I agree that the new features are unobtrusive, so I’m excited to see them in the next Scratch release.

      I’ve installed BYOB on my lab machines and though I don’t plan to teach it explicitly, I’ll have some of the students who are more comfortable with the basic Scratch features explore a bit. I’m very curious to see what they’ll be able to do without direct instruction. My guess is that they’ll at least need a brief tutorial, but maybe not; I’ll just have to report back when I get a chance to see.

      I would have liked to just switch to BYOB since all the Scratch features are there plus more but the inability to share to the web is a real problem for me!

      • August 25, 2010

        Oh, that’s nice that you’re offering BYOB to your students! I can’t wait to learn about your experiences in letting them experiment on their own.

        I agree that not being able to share projects on the Scratch website is a big turn-off. We’re actually thinking about implementing a BYOB web-player, but I’m convinced that nothing compares to the “real thing”, i.e. the fantastic Scratch site and the wonderful Scratch online community.

        In the meantime BYOB offers to save a stand-alone “compiled” version of projects, which can be – sort of – shared directly with others.

  3. August 25, 2010

    Thank you for taking an interest in BYOB!

    Yes, of course, if I myself want to write a serious program I do it in Scheme, or maybe Logo if it’s about words and sentences. And I edit in Emacs. (You’ll probably get more of an argument about this from Jens, who has provided with BYOB a drag-and-drop representation of the underlying Smalltalk code called Elements.) Kids who are serious about computer programming will certainly eventually expand their skills to include other languages, just as we all did. (My first language was Fortran, which I haven’t touched in decades.) Many kids already program simultaneously in Scratch and in browser-related languages such as Javascript. A few have learned Smalltalk in order to produce their own modifications of the Scratch source code.

    But even kids with several “grownup” languages under their belts continue to program in Scratch, because of the tremendous appeal of displaying their work to the half-million kids who visit the Scratch web site! This is the only example of “social networking” technology that appeals to me. I’ve never seen the point of collecting 20,000 so-called friends on Facebook, but the Scratch web site is an intellectual community; it’s about something. Why should the members of that community be limited in the tools available to them?

    What we really want is for all of those Scratch kids to have the ideas of BYOB available to them. BYOB is a proof-of-concept demonstration; we’re working hard at convincing the Scratch Team to include our design in their Scratch 2.0 development. The biggest complaint kids make about BYOB is that they can’t share their projects on the Scratch site.

    Probably the Scratch Team were right to start slowly. Once long ago I worked in the corporate Research Department of Atari, where I heard a talk by a leading game designer who made the point that if the complexity of the (then-)current video games had suddenly become available in the early days of Pong and Spacewar, kids would have found them frighteningly complicated — but now, even young kids playing video games for the first time aren’t intimidated by the complexity, because the conventions on how to play such games are part of the common culture, and little kids can always find a big kid to teach them. (Since then, of course, games have become even more complicated than they were back in the 1980s, and what he said is still true.) I think it matters a lot that there’s a half-million-strong community of kids comfortable with Scratch.

    Many kids are already bumping into Scratch’s ceiling without necessarily realizing it. Have you actually downloaded and read some of the amazingly complex and featureful projects that kids are writing? The projects are great, but the Scratch code is unreadable; there are scripts that go on for 300 lines, far more than fit on the screen at once. Kids write in this ugly style because Scratch provides no mechanism for modularity. Much of those long scripts consists of code fragments copied and pasted repeatedly with small modifications. Those chunks should be procedures — custom blocks, as we call them in BYOB.

    I’m afraid that some of your specific complaints come from limited familiarity with Scratch itself. Most notably, reporters are not a new idea in BYOB. If you look at the Scratch palettes you’ll see that blocks come in three shapes: jigsaw-piece (commands), oval (reporters), and hexagonal (predicates). A few sample reporters are X POSITION, Y POSITION, the arithmetic operators +-*/, LOUDNESS, and LENGTH OF. Some sample predicates are TOUCHING?, MOUSE DOWN?, AND, OR, and NOT. You’re right that there’s no deep reason to distinguish procedures that report TRUE or FALSE from procedures that report other values, but the Scratch Team decided that as a pragmatic matter, predicates are used in very different contexts from other reporters — mainly in control blocks like IF or WAIT UNTIL. We followed their lead in this, allowing users to create custom blocks in the same categories that Scratch already provides. (We briefly considered inventing different shapes for, say, blocks that report lists, but quickly rejected that as being too dramatic a change from what Scratch users expect, with very little gain in expressive power. We have really tried very hard to change Scratch as little as possible!)

    By the way, you didn’t have to invent your DOUBLE custom block to carry out the computation you wanted. You could just

    MAP [(2) * ( )] OVER [LIST (2) (3) (5) (10)]

    leaving an empty input slot in the multiplication block to show where the list elements should be inserted. That empty-slot notation is a bit of fallout from my early training as a math teacher. If you show an eight-year-old an equation such as “x+3=10″ and ask “what’s x?” you’re likely to get “huh?” as an answer. But if you replace the x with a big empty square and ask “what number goes in the square to make this true?” they all get it. The empty slot is like the box in the math curriculum. We’re hoping that

    THE [(2) * ( )] BLOCK

    will turn out to be a much more accessible notation than the

    (lambda (num) (* 2 num))

    that represents the same idea in Scheme with an explicit formal parameter. (For more complicated situations in which you need detailed control over which input goes where, BYOB does also allow explicit parameters in lambda expressions.)

    But what strikes me as really unfair in your review is the way you jump the reader directly into the long-form input dialog. We know that that would scare off a beginner! That’s why we were careful to provide a short-form dialog in which you just type a name for the input and click OK (or hit the return key). We anticipate that kids might spend a month or two using only the short dialog before ever clicking the arrow to reveal the long dialog in which they can declare the input’s expected data type.

    More generally, different kids will use BYOB’s features to different extents. I’ve taught BYOB to fourth and fifth graders, and many of them are quite comfortable building non-recursive blocks. So far I’ve only had one fifth grader who ended up truly comfortable with recursion, although several more have had more limited success with it. But high school kids can all handle recursion (not necessarily right away). Not all of them get higher order functions; maybe only college students will use those, although I think when I have a real curriculum in place, the high school kids will do better than they did in my very limited sink-or-swim trial last spring. (I’m a fanatic about higher order functions, the best idea since ice cream. I know that treating program as data requires a real intellectual leap for people of any age, but once you get it, so many formerly hard problems become trivial!)

    When we introduced BYOB3 to the Scratch community last year, about 20 kids just got it instantly — object oriented programming via explicit dispatch procedures, higher order functions, everything! We find that heartening. This semester, students at four high schools will be trying out the new curriculum we’re developing at Berkeley in addition to our own undergraduates. Then we’ll have a much better idea about how learnable this all really is, for the kids who don’t get it instantly without any teaching.

    • Hélène Martin permalink*
      August 25, 2010

      You’re right that the Scratch community adds a really great dimension to the learning process — students want to share their successes and have the opportunity to learn from others from all over. That does add an interesting argument for BYOB I hadn’t quite thought of. With “regular” Scratch, collaboration is painful at best and being able to share true building blocks will definitely add a nice dimension to the community. I’m not surprised that the lack of ability to share (beyond a local network) would be something kids would be frustrated about.

      I agree that it has been a good move by the Scratch community to move slowly and I’ve found that really refreshing. Maybe that’s why I’m a little defensive! But I guess what’s important is that the new complexity not get in the way of what’s there already and I do think BYOB does a nice job of that.

      Thanks for the clarifications regarding commands, reporters and predicates. I had been thinking of things like X POS as values but of course those values need to come from somewhere. What’s interesting is that though I had been using reporters and predicates without any hesitation, I was a little surprised to come across those options and had to think about it for a bit. Luckily, the matching shapes really help, which is part of Scratch’s brilliance, I think.

      I was trying to pack as much interesting stuff into a screenshot as I could… I hope what I ended up with isn’t too misleading. I agree there was no great reason to create a custom block for the map other than I wanted to create a custom block. And I wanted to show the long menu because it’s really neat!

      I’m really looking forward to reading about how things go at Gunn and the other schools. I think whatever happens there will be very insightful.

  4. August 25, 2010

    P.S. Something I forgot to say:

    You say, “I feel that once one has a deep enough understanding to want things like anonymous functions and have a true need for them, a drag and drop interface gets in the way more than anything.”

    I’m not so fond of drag-and-drop myself, but that’s only half of what Scratch offers. The other half is the visual display of data. For example, Scratch makes the idea of lists more concrete by displaying the entire contents of a list on the stage, where it is directly editable. This capability is, I think, hugely important in learning about procedures as data.

    Consider: Scheme has no visible representation for a procedure. There are lambda expressions that, when evaluated, create procedures; but if you try to print the value returned by a lambda expression you see some implementation-dependent gibberish like (in the version of Scheme we use at Berkeley) #[closure arglist=(x) b784feb8].

    By contrast, in BYOB, the result of wrapping a block in THE BLOCK or a script in THE SCRIPT is a picture of something that’s visibly a block or script, with a grey border around it. If you make a list of blocks, you see a Scratch list watcher whose elements are these encapsulated blocks. Any kid, even a fifth grader, looks at that representation and immediately understands what it represents. (Being able to use first class procedures effectively is of course harder.) I don’t yet have the experimental data to back this up, but I’m guessing that this visual display is going to make a huge difference in kids’ ability to understand higher order functions.

    That’s why it’s worthwhile adding these ideas to Scratch instead of just moving kids on to Scheme.

    • Hélène Martin permalink*
      August 25, 2010

      Another excellent point I hadn’t thought about. Visualizations can be powerful tools for grasping abstract concepts and I may be able to use the ones here with students who are struggling with some of the concepts you mention in Scheme.

      Thanks to both you and Jens for the great comments (and system) — great food for thought and now I’m more excited about BYOB!

Trackbacks and Pingbacks

  1. Blog Post: Interesting Links Post 23 August 2010 | IT.beta
  2. Interesting Links Post 23 August 2010

Leave a Reply

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS