“The Beauty and Joy of Computing” (BJC) is a new mooc that started just a few weeks ago. Dan Garcia has been teaching it at UC Berkeley for awhile, and now it’s available on edX.
Discover the big ideas and thinking practices in computer science plus learn how to code using one of the friendliest programming languages, Snap! (based on Scratch).
We’ve been working on this course for more than two years, with the help of a grant from edX, and more than fifty outstanding undergraduates at UC Berkeley.
I enrolled early on, forgot about it (happens sometimes!), watched the live “office hours” session last week which piqued my interest again, and finally got caught up as the course heads into its fourth week. If you’re interested, read more about BJC or just enroll in it. A few dedicated evenings and you’ll be all caught up.
BJC relies heavily on a visual tool called Snap! for learning basic programming principles. If you’re familiar with MIT’s Scratch, this is Berkeley’s extended version, geared more towards adults. If you’re not, then it’s easy enough to pick up. The course starts with really basic scripts.
I like to have a goal or purpose when I start a mooc, to keep me focused. With BJC, it’s mostly to get familiar with Snap!, which I had my to-do list anyway. I want to see if it really is a good tool for introducing basic programming principles.
It’s pretty early on still, but already Dan’s encouraging a lot of good practices, like pair programming and collaborative development… skills you’ll use as a developer. The Snap! exercises are well thought out and challenging.
My First Snap! Script
Okay, this wasn’t my first script, but that sounds catchier than “my eighth (ninth?) script, but the first one that did anything remotely interesting”.
Like any new tool, Snap! is mildly frustrating to use at first. For someone who already programs, it feels odd to have a jigsaw puzzle piece representation of every bit of code, and to have to drag them into the scripting area instead of just typing. But once you get used to it, it’s pretty easy to read and modify. Drag ‘n drop, drag ‘n drop…
Here’s a relatively simple script, for drawing the patterned circles shown below. Those two orange blocks at the top of the script represent input values that you can change to affect the output of the entire script.
Can you tell what it’s doing?
You can view and modify the full script here. Play with it; your changes won’t affect my original script.
(You may have to press the two arrowed resize button to close the output and see the script. Then click on the first orange block to watch the script run.)
It moves the pen to the middle of the “stage”… that’s the part of the screen in the upper-right where you see the output of the script. Then it moves to the right and down a bit, and draws a square. Finally, it resets to the middle again, rotates slightly, and draws another square. Enough overlapping squares, and it creates some pretty neat designs.
- By increasing LengthOfSide, it increases the overall diameter of the resulting shape.
- By decreasing Density, it increases the number of squares that are drawn. (well, that just seems backwards…)
Here are the results with a few different inputs:
Snap! seems pretty solid so far. It’ll catch error conditions and display helpful error messages. You can save scripts locally or on their servers, share them with others, and export them to XML.
Exporting to XML
There doesn’t seem to be an obvious reason to export a script to XML, since you can store it in the cloud to access it from multiple places, and make it public to share it, like I did above.
I assume the XML rendering is, though, how the BJC team is able to offer a “Get Feedback” button in the Snap! editor window. That button’s not visible normally, but somehow they’re doing it from within the course, even though they just appear to be loading the editor in an iframe.
So what’s the feedback button do? It checks your script for correct content, the number and type of blocks, and runs sample data through your script to test the output. It’s not always 100% accurate, but it’s an interesting start.
Here’s a (very) short script to draw a square, and the associated XML output below.
There’s quite a bit of info in here, including the image of the sprite that we’re moving and turning (a small black arrow), data about the stage on which the sprite moves and turns, and finally the script we created in between the
<scripts> </scripts>tags near the bottom.
From that, it’s pretty easy to see that the sprite should move “forward” 50, then “turn” 90, which is something we can use to verify the script is doing what it’s supposed to do, a la the feedback button.
<project name="sample export" app="Snap! 4.0, http://snap.berkeley.edu" version="1"> <notes></notes> <thumbnail>data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAB4CAYAAAB1ovlvAAADfklEQVR4Xu3XvU0rYRCG0c+IAJMg8WNBHQhqgATKoAJ6QOSuB+qgCByByBbZwc3sO4FfTcDZeDQjzj7YMJumaRoeAk0CMwE2yTu7ERCgEFoFBNjK77gANdAqIMBWfscFqIFWAQG28jsuQA20Cgiwld9xAWqgVUCArfyOC1ADrQICbOV3XIAaaBUQYCu/4wLUQKuAAFv5HRegBloFBNjK77gANdAqIMBWfscFqIFWAQG28jsuQA20Cgiwld9xAWqgVUCArfyOC1ADrQICbOV3XIAaaBUQYCu/4wLUQKuAAFv5HRegBloFBNjK77gANdAqIMBWfscFqIFWAQG28jsuQA20Cgiwld9xAWqgVUCArfyOC1ADrQICbOV3XIAaaBUQYCu/4wLUQKuAAFv5HRegBloFBNjK77gANdAqIMBWfscFqIFWAQG28jsuwC0NfH19jfl8Pg4ODlQSFBDgFtynp6cxTdO4ubkZj4+PY7FYBF/D310twC3v/uPjYzw/P28+AVer1Tg5ORl3d3ebIM/OzsbV1dU4Ojr6u+Xs6ScX4A7I9/f38fLysvkqXj/rT8Sfn59xcXExjo+Px+Hh4Vgul3t6FX9zjQB3vPe3t7fx+vr675NOgPv/JRHgf76CZ7PZ+Pz8HKenp+P+/n5cX1+P8/PzcXl56St4Dz0KcMc/Iev4bm9vx8PDwyY6z/4FBLjF9Pv7e/O33zpCT05AgDlbmwsCAiwgGckJCDBna3NBQIAFJCM5AQHmbG0uCAiwgGQkJyDAnK3NBQEBFpCM5AQEmLO1uSAgwAKSkZyAAHO2NhcEBFhAMpITEGDO1uaCgAALSEZyAgLM2dpcEBBgAclITkCAOVubCwICLCAZyQkIMGdrc0FAgAUkIzkBAeZsbS4ICLCAZCQnIMCcrc0FAQEWkIzkBASYs7W5ICDAApKRnIAAc7Y2FwQEWEAykhMQYM7W5oKAAAtIRnICAszZ2lwQEGAByUhOQIA5W5sLAgIsIBnJCQgwZ2tzQUCABSQjOQEB5mxtLggIsIBkJCcgwJytzQUBARaQjOQEBJiztbkgIMACkpGcgABztjYXBARYQDKSExBgztbmgoAAC0hGcgICzNnaXBAQYAHJSE5AgDlbmwsCAiwgGckJCDBna3NBQIAFJCM5AQHmbG0uCAiwgGQkJyDAnK3NBQEBFpCM5AR+AWwFF7eG8YBkAAAAAElFTkSuQmCC</thumbnail> <stage name="Stage" width="480" height="360" costume="0" tempo="60" threadsafe="false" lines="round" codify="false" scheduled="false" id="1"> <pentrails>data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAeAAAAFoCAYAAACPNyggAAAOhUlEQVR4Xu3VwQkAAAjEMN1/abewn7jAQRC64wgQIECAAIF3gX1fNEiAAAECBAiMAHsCAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQIHLFxAWmhEwHPAAAAAElFTkSuQmCC</pentrails> <costumes> <list id="2"></list> </costumes> <sounds> <list id="3"></list> </sounds> <variables></variables> <blocks></blocks> <scripts></scripts> <sprites> <sprite name="Sprite" idx="1" x="0" y="0" heading="90" scale="1" rotation="1" draggable="true" costume="0" color="80,80,80" pen="tip" id="8"> <costumes> <list id="9"></list> </costumes> <sounds> <list id="10"></list> </sounds> <variables></variables> <blocks></blocks> <scripts> <script x="57" y="51"> <block s="down"></block> <block s="forward"> <l>50</l> </block> <block s="turn"> <l>90</l> </block> </script> </scripts> </sprite> </sprites> </stage> <hidden></hidden> <headers></headers> <code></code> <blocks></blocks> <variables></variables> </project>
The course is being presented in four parts, and Dan and his team are very active in it, at least for this first go-around.
Here’s the full list. If you sign up, let me know what you think of it!
- The Beauty and Joy of Computing (CS Principles), Part 1 (now)
- The Beauty and Joy of Computing (CS Principles), Part 2 (Oct 26)
- The Beauty and Joy of Computing (CS Principles), Part 3 (Jan 4, 2016)
- The Beauty and Joy of Computing (CS Principles), Part 4 (Mar 7, 2016)
Like what you just read? Share it with your friends!







