Why Build Your Own Blocks?
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.
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?