8
Learnable Programming: Blocks and Beyond David Bau MIT CSAIL Cambridge, MA USA [email protected] Jeff Gray Dept. of Computer Science University of Alabama Tuscaloosa, AL USA [email protected] Caitlin Kelleher Dept. of Computer Science Washington University St. Louis, MO USA [email protected] Josh Sheldon MIT CSAIL Cambridge, MA USA [email protected] Franklyn Turbak Computer Science Dept. Wellesley College Wellesley, MA, USA [email protected] ABSTRACT Blocks-based programming has become the lingua franca for introductory coding. Studies have found that experience with blocks-based programming can help beginners learn more traditional text-based languages. We explore how blocks environments improve learnability for novices by 1) favoring recognition over recall, 2) reducing cognitive load, and 3) preventing errors. Increased usability of blocks program- ming has led to widespread adoption within introductory programming contexts across a range of ages. Ongoing work explores further reducing barriers to programming, support- ing novice programmers in expanding their programming skills, and transitioning to textual programming. New blocks frameworks are making it easier to access a variety of APIs through blocks environments, opening the doors to a greater diversity of programming domains and supporting greater experimentation for novices and professionals alike. Keywords Blocks-based programming interfaces; Computing education 1. INTRODUCTION A global push to broaden participation in computer science has led to an explosion of interest in blocks-based program- ming. Visual blocks are used by more than a dozen pro- gramming tools (see the Sidebar below). Millions of students receive their first exposure to programming via these tools in courses and activities like Code.org’s Hour of Code. Blocks allow beginners to compose programs without struggling with the frustrations of syntax (Figure 1). There is increasing interest in developing and studying blocks languages. At VL/HCC 2015, a small workshop Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]. To appear in Communications of the ACM, June 2017, pp. 72-80. c 2017 ACM Figure 1: Snap! is an example of a blocks-based programming environment. Users drag blocks from a palette of programming elements (left) into a workspace (center), where blocks can be assembled into programs. Snap! also provides an output win- dow (top-right) and a sprite picker (bottom-right). session called Blocks and Beyond 1 ballooned to a large event, with 51 submissions and 36 presenters. Researchers shared work in new blocks languages, interface innovations, domain- specific applications of blocks, and ways to make blocks languages more effective and accessible for diverse coders. This article explores how blocks impact the learnability of programming. We begin by reviewing studies on the effectiveness of blocks languages. Then we discuss the key features of blocks languages and how they relate to learning. Finally, we look at applications of blocks in new domains and discuss tools for creating your own blocks language. 2. DO BLOCKS LANGUAGES WORK? Watching beginners create their first programs with blocks can be simultaneously inspiring and unsettling. Empowered by blocks, novices will rapidly build complex, often delightful creations. But just as quickly, they fill their screen with clumsy and intricate code [22]. A seasoned programmer inspecting a beginner’s disordered assembly might worry that snapping together colorful blocks has nothing to do with “real code.” But what is “real code,” and why learn it? 1 http://cs.wellesley.edu/blocks-and-beyond arXiv:1705.09413v1 [cs.PL] 26 May 2017

Learnable Programming: Blocks and Beyond · 3.2 Chunking Information with Blocks Programming languages present a high cognitive load to a student who is learning a new syntax. For

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Learnable Programming: Blocks and Beyond · 3.2 Chunking Information with Blocks Programming languages present a high cognitive load to a student who is learning a new syntax. For

Learnable Programming: Blocks and Beyond

David BauMIT CSAIL

Cambridge, MA [email protected]

Jeff GrayDept. of Computer Science

University of AlabamaTuscaloosa, AL [email protected]

Caitlin KelleherDept. of Computer Science

Washington UniversitySt. Louis, MO USA

[email protected] Sheldon

MIT CSAILCambridge, MA USA

[email protected]

Franklyn TurbakComputer Science Dept.

Wellesley CollegeWellesley, MA, USA

[email protected]

ABSTRACTBlocks-based programming has become the lingua franca forintroductory coding. Studies have found that experience withblocks-based programming can help beginners learn moretraditional text-based languages. We explore how blocksenvironments improve learnability for novices by 1) favoringrecognition over recall, 2) reducing cognitive load, and 3)preventing errors. Increased usability of blocks program-ming has led to widespread adoption within introductoryprogramming contexts across a range of ages. Ongoing workexplores further reducing barriers to programming, support-ing novice programmers in expanding their programmingskills, and transitioning to textual programming. New blocksframeworks are making it easier to access a variety of APIsthrough blocks environments, opening the doors to a greaterdiversity of programming domains and supporting greaterexperimentation for novices and professionals alike.

KeywordsBlocks-based programming interfaces; Computing education

1. INTRODUCTIONA global push to broaden participation in computer science

has led to an explosion of interest in blocks-based program-ming. Visual blocks are used by more than a dozen pro-gramming tools (see the Sidebar below). Millions of studentsreceive their first exposure to programming via these tools incourses and activities like Code.org’s Hour of Code. Blocksallow beginners to compose programs without strugglingwith the frustrations of syntax (Figure 1).

There is increasing interest in developing and studyingblocks languages. At VL/HCC 2015, a small workshop

Permission to make digital or hard copies of all or part of this work for personal orclassroom use is granted without fee provided that copies are not made or distributedfor profit or commercial advantage and that copies bear this notice and the full citationon the first page. Copyrights for components of this work owned by others than ACMmust be honored. Abstracting with credit is permitted. To copy otherwise, or republish,to post on servers or to redistribute to lists, requires prior specific permission and/or afee. Request permissions from [email protected].

To appear in Communications of the ACM, June 2017, pp. 72-80.

c©2017 ACM

Figure 1: Snap! is an example of a blocks-basedprogramming environment. Users drag blocks froma palette of programming elements (left) into aworkspace (center), where blocks can be assembledinto programs. Snap! also provides an output win-dow (top-right) and a sprite picker (bottom-right).

session called Blocks and Beyond1 ballooned to a large event,with 51 submissions and 36 presenters. Researchers sharedwork in new blocks languages, interface innovations, domain-specific applications of blocks, and ways to make blockslanguages more effective and accessible for diverse coders.

This article explores how blocks impact the learnabilityof programming. We begin by reviewing studies on theeffectiveness of blocks languages. Then we discuss the keyfeatures of blocks languages and how they relate to learning.Finally, we look at applications of blocks in new domainsand discuss tools for creating your own blocks language.

2. DO BLOCKS LANGUAGES WORK?Watching beginners create their first programs with blocks

can be simultaneously inspiring and unsettling. Empoweredby blocks, novices will rapidly build complex, often delightfulcreations. But just as quickly, they fill their screen withclumsy and intricate code [22]. A seasoned programmerinspecting a beginner’s disordered assembly might worrythat snapping together colorful blocks has nothing to do with“real code.” But what is “real code,” and why learn it?

1http://cs.wellesley.edu/blocks-and-beyond

arX

iv:1

705.

0941

3v1

[cs

.PL

] 2

6 M

ay 2

017

Page 2: Learnable Programming: Blocks and Beyond · 3.2 Chunking Information with Blocks Programming languages present a high cognitive load to a student who is learning a new syntax. For

2.1 What is “Real Code?”The purpose of a blocks-based tool is to make programming

easy to learn. But programming education can have twodistinct endpoints:

1. Development of expertise in professional programming.

2. Ability to accomplish other goals by creating programs.

The two objectives are not necessarily the same. Thedesigners of Scratch note that for users“who see programmingas a medium for expression, not a path toward a career,Scratch is sufficient for their needs” [28]. The GP blocksenvironment is being designed to enable“casual programmers”to create ever more sophisticated programs, while removinglimits that would force them to switch away from blocks [24].

Before discussing the learning effects of blocks-based pro-gramming, we begin with a caution that it would be short-sighted to assume that tomorrow’s programmers will programwith the same languages and systems as today’s. Each gen-eration of programmers shifts the culture of coding, and thedefinition of “real code” will continue to evolve.

However, core learning questions remain. For students whocontinue with the study of traditional programming, we canask if a blocks-based introduction to programming is helpfulor not. This question has been directly tested in classrooms.

2.2 Measuring Learning TransferResearch indicates that learning a blocks language can

improve later learning of a traditional textual language. In astudy of 10th graders learning C# or Java [1], those who hadtaken a Scratch course in 9th grade learned more quickly, un-derstood loops better, and were more engaged and confidentthan their peers who had not. However, in the final test, asignificant difference was seen in only one of three cognitivedimensions. In a study at two colleges [25], students withlittle or no previous programming experience and weak mathpreparation completed a CS0 programing class using Alicebefore beginning a Java CS1 course. Starting with Alice im-proved student grades (GPA of 3.0 versus 1.2 for non-Alicestudents) and the percentage of students taking further CScourses (88% compared to 47%).

The question of whether such effects are simply due togiving students more preparation in an extra class has beentested by creating courses that combine a blocks-based intro-duction with a transition to a traditional language. Reportsfrom courses using Scratch before Java or C indicate improvedstudent engagement and understanding of some concepts [19,39]. In one study focused on learning transfer [8], an intro-ductory Java course at CMU was modified to begin withAlice. Students in this class that used both languages aver-aged 10% or more better performance on every section ofthe same Java final exam, including expression evaluation,control structures, arrays, and working with class definitions.

That result is remarkable because one might assume thatspending more time programming with blocks meant lesstime to learn Java. The study used a version of Alice that gen-erated Java code from Alice blocks, and a mediated transferpedagogy that made explicit connections between program-ming concepts in Alice and Java.

Other studies of CS1 courses that switch from blocks to textwithout these features have identified potential challengesto learning with blocks [10, 27]. Switching from a blockslanguage to text can involve both a change in syntax and

semantics, and Shapiro and Ahrens propose teaching thetransitions separately, teaching syntax before generalizingsemantics [32]. Additional research is needed to identify thecircumstances under which blocks are effective.

Today, many introductory computer science courses usea blocks-before-text approach. In Harvard’s CS50, studentsmove from Scratch to C; Berkeley’s CS10 progresses fromSnap! to Python; Project Lead The Way’s Computer SciencePrinciples (CSP) course uses both Scratch and App Inventorbefore moving on to Python; and Code.org’s CSP App Labcourse moves from Droplet blocks to JavaScript.

3. WHY BLOCKS ARE LEARNABLEIn 2004, Ko, Myers and Aung [15] identified six learning

barriers encountered by non-programmers in programmingtasks. Three of these — selection, use, and coordination —reflect the difficulty of simply assembling a program.

We believe the learnability of blocks languages arises fromhow they address the usability challenges underlying thesethree learning barriers:

1. Learning a programming vocabulary is hard. Blockssimplify this problem because picking a block from apalette is far easier than remembering a word: blocksrely on recognition instead of recall.

2. Code is hard to use because it presents a high cognitiveload for new programmers. Blocks reduce the cogni-tive load by chunking code into a smaller number ofmeaningful elements.

3. Assembling code is error-prone. Blocks help users as-semble code without basic errors by providing con-strained direct manipulation of structure (e.g., twoincompatible concepts do not have connecting parts).

3.1 Recognition versus RecallProgramming with a simple language or library typically

involves a vocabulary of about 100-200 words. For example,HTML has 100 tags and 100 attributes, and SQL has about200 keywords; Scratch is similar, with 130 blocks. Recalling100-200 concepts can overwhelm a newcomer.

Unlike text languages, blocks languages are intimately tiedto their programming environments, and nearly all blockenvironments have adopted a few interface conventions thataddress key usability problems. One such convention is tack-ling vocabulary by organizing blocks in functionally relatedpalettes on the screen.

Palettes differ from autocomplete menus in professionalcode editors because they persist instead of disappearing andthey organize concepts by topic instead of by name. Thisdesign simplifies discovery and exploration. Figure 2a showsthe Sound palette in Scratch. It is an instructive referenceshowing all 13 methods for audio in that environment.

Similar organization is seen in larger blocks environments.To help manage the complexity of creating mobile apps, AppInventor provides a dynamic set of blocks, with additionalblocks available in programs that have interactions with morecomponents (Figure 2b). Yet, the basic idiom is the same asScratch: explorable palettes organized by function.

Remembering the order, type, and valid values of operandsis also daunting for newcomers. Many systems address thisby supplying blocks with default operand values, drop-down

Page 3: Learnable Programming: Blocks and Beyond · 3.2 Chunking Information with Blocks Programming languages present a high cognitive load to a student who is learning a new syntax. For

(a) Scratch (b) App Inventor

Figure 2: The sound palette in Scratch and a voicesynthesis palette in App Inventor. Palettes simplifythe selection of programming elements by exploitingthe ease of recognition over recall. Palettes organizeconcepts by topic, not name, and they remain openwhen used, allowing the user to discover and tinkerwith blocks based on their function.

menus and specialized editors to specify operands, and extrawords to indicate operand meanings (Figure 3a).

3.2 Chunking Information with BlocksProgramming languages present a high cognitive load to a

student who is learning a new syntax. For example, considerthe for loop in JavaScript syntax:

for (var i = 0; i < 50; i++) { · · · }

This dense notation is a barrier to beginners. In the wordsof one student, JavaScript “is really confusing to understandwith all the parentheses and brackets and all of that” [38].

To understand the difficulty, consider that this code con-tains five words (for var i i i), ten pieces of punctuation(( = ; < ; + + ) { } ), and two numbers (0 and 50), atotal of seventeen units of information. Studies of humancognitive capacity have established that people have a work-ing memory of about seven chunks of information [23]. Tryingto understand this line of code as seventeen separate itemsmay overwhelm the working memory of a new programmer.

Experienced JavaScript programmers have no problemunderstanding the line of code above because they havelearned to interpret the code in larger chunks. Because a for

loop follows a very common pattern, it can be read in just twochunks: first, the typical for loop that uses the conventionallooping pattern (i starting at 0 and incrementing by 1);second, the particular choice of 50 as the upper limit. Figure4 illustrates different ways of chunking the code.

Blocks help reduce cognitive load by showing new program-mers how to read larger chunks. In the Code.org ComputerScience Principles course, blocks for JavaScript for loops aredrawn just as an expert would see the code: as two chunks

(a) Scratch

playNoteFor(60, 0.5)

(b) Python

Figure 3: Blocks show structure visually instead ofusing punctuation. They can aid learnability usingplain language, default values, and value pickers.

Figure 4: Three ways of reading a for loop in chunks.A naive reading of code (top) interprets the codeas 17 chunks, but an expert reading of code (mid-dle) interprets the most common form of loop asa single chunk, with a second chunk for the looplimit 50. An alternative (bottom) reading interpretsthree clauses as chunks. Code.org uses the middlerendering when introducing loops to high-school stu-dents for the first time, and switches to the bottomrendering when students are familiar with for loops.

with a single block with a single socket for the loop upperbound. Complexity can also be reduced by nesting chunkswithin chunks. For example, Code.org reveals finer-grainedfor structure in more advanced portions of the same course,as illustrated at the bottom of Figure 4.

The use of blocks to chunk code aids readability even forsimple commands, because blocks can forgo the punctuationthat text code uses to denote structure and use explanatorywords instead. For example, as illustrated in Figure 3b, asimple call in Python requires reading delimiters and knowingargument order, whereas the equivalent block in Scratch readsnaturally, using plain words to explain its behavior.

By organizing code as visible chunks, blocks help newprogrammers concentrate on what the code means ratherthan the notation that is used to write it.

3.3 Direct Manipulation of Visible StructureThe visual form of blocks alleviates the burden of assem-

bling syntactically correct units by typing one character at atime. But there are other advantages of directly manipulatingprogram fragments that have visual constraints.

One benefit is that the blocks can help prevent errors bymaking the grammar of a program visible. Blocks can be seenas a form of syntax-directed editing with constrained directmanipulation. In 1981, creators of an early structured-editingtool noted, “Programs are not text; they are hierarchical com-positions of computational structures and should be edited,executed, and debugged in an environment that consistentlyacknowledges and reinforces this viewpoint” [35].

Block shapes help beginners understand which grammat-ical phrases (expresssions vs. commands vs. declarations)

Page 4: Learnable Programming: Blocks and Beyond · 3.2 Chunking Information with Blocks Programming languages present a high cognitive load to a student who is learning a new syntax. For

Figure 5: Block shapes show and enforce rules ofcomposition. Scratch commands compose vertically,and expressions fit into holes. Here, a Boolean ex-pression (diamond shape) is being dropped into amatching hole for a loop test condition.

are legal in what contexts. In Scratch, commands connectvertically with nubs and notches, whereas expressions aresmooth shapes that fit into smooth holes. Constraints ondrag-and-drop prevent the two types from being confused(Figure 5). Students report that the puzzle shapes are helpfulfor assembling programs [38].

Visualization of types by shape can be applied to richertype systems: OpenBlocks provides 14 connector shapes torepresent different types [29], and researchers have createdexperimental block languages with dynamically generatedshapes to represent compositional type systems [18, 36].

Directly manipulable blocks also encourage bottom-uptinkering with program pieces in ways not directly supportedby raw text. Blocks programmers experiment with blocksby connecting them to build islands of code fragments onthe programming surface that are isolated from the mainprogram [22, 38]. In blocks environments supporting liveness[20], these fragments can be executed by pointing and clicking,providing a key benefit of interpreted text-based languageswithout a read-eval-print loop console separate from theeditor. The program gradually grows as it is augmented bydropping in these fragments when they behave as desired.

3.4 Learnability Beyond BlocksBlocks aid in the construction of code, but blocks alone

are not enough to make a programming language learnable.Users new to a language face additional learning challenges:

• They must wrestle with practical aspects like installinglanguage tools, saving/loading programs, etc.;

• They must learn the vocabulary of the language andunderstand the concepts denoted by its words;

• They need to understand runtime semantics such asflow of control and changes in state over time;

• They eventually need to learn common patterns of use,moving beyond isolated concepts.

Each of these learning hurdles can be helped or hindered bythe programming environment, and each of these problemsis an area of active research and development.

3.4.1 Programming OnlineTo simplify installation, programming tools are moving on-

line. When a programming environment is in a web browser,a new programmer is just a few clicks away from creating afirst program. A cloud-based programming tool can provide

a complete and consistent programming environment withfewer potential problems.

Although blocks programming environments for beginnershave long been offered online, text-based programming envi-ronments are also becoming available online. With tools suchas Cloud 9, CodeAnywhere, and CodeEnvy, programmers ofall levels can benefit from working online.

3.4.2 Words, Concepts, and AbstractionsThe names chosen for language constructs can have an im-

pact on learnability. Empirical studies by Stefik and Seibert[34] have found that common keywords like for or operatorssuch as != serve as hard-to-learn jargon, and are not as easilylearnable as familiar words such as repeat or unequal. Theyfound that the syntax of languages such as Java and Perl areno more learnable than a synthetic programming languagewith randomly-selected punctuation used for keywords.

Even more important for learnability are the abstractionschosen by language designers to allow users to build sim-ple programs with compelling behavior. For example, thedesigners of Alice worked with users to develop intuitiveabstractions for controlling 3D animations. During theirdesign process, the Alice team eliminated jargon such astransformation matrices and substituted more intuitive con-cepts like object-relative motions. These new abstractionsmade it easier for users to specify 3D animations [7].

Designing languages and libraries focused on learnabilitybased on empirical evidence is a major area for future work.

3.4.3 Runtime UnderstandingThe dynamic state of a program can be made more under-

standable by making its state visible. For example, Code.orghighlights the individual block that is actively running so thecorrespondence between code and action can be seen. Snap!provides widgets for every variable to show the current state.

Even with highly visible state, understanding actions inthe past or future can be difficult. Liveness [20] is oneapproach to addressing this problem. A live system aims tomake actions concrete by applying them immediately to thecurrent state. For example, in App Inventor, Scratch, andSnap!, many edits to a running block program take effectimmediately, without the need to restart the program.

Another approach for making the evolution of state under-standable is to allow the programmer to travel in time byinspecting, advancing or rewinding the timeline of a program.The concept of omniscient debugging was first described inthe early 1970s as a capability to trace backward in timethrough execution history to identify the location of the faultthat caused a later observed failure [40]. TRAKLA2 [26],UUhistle [33] and Online Python Tutor [12] provide thiscapability for Java and Python.

3.4.4 Examples and ReuseThe activity of programming has changed with the avail-

ability of large repositories containing examples of sharedcode. Programmers of all levels report finding and adaptingexamples as a core programming activity [6, 9]. In response,professional programming and end-user programming en-vironments are beginning to incorporate example support[5, 31]. Novices, too, want to learn via examples, but maystruggle to do so [30]

Blocks-based languages like Scratch and Looking Glass useonline sharing and remixing programs to provide example

Page 5: Learnable Programming: Blocks and Beyond · 3.2 Chunking Information with Blocks Programming languages present a high cognitive load to a student who is learning a new syntax. For

Figure 6: Greenfoot’s Stride editor combines text-style editing for expression-level details with drag-and-drop blocks for higher-level program structure.

access. But there is a tradeoff between the simplicity of reuseand the robustness of reused code. For example, Scratchsimplifies sharing of code examples for novices by providinga “backpack” for collecting program snippets and assets thatcan be shared and dragged into a new project. However, thebackpack does not necessarily guarantee that the code willrun correctly in a new project.

In contrast, Looking Glass uses a more complex process forreuse in which users select the beginning and end of behaviorthey want to use. Coupled with execution history informa-tion, this can ensure that the selected code will functionwithin the context of a new program. A Play & Explorefeature allows users to connect program output to the lineor lines of code that caused it, helping users to understandand begin to modify reused code.

4. SCALING BLOCKS CODEWhy don’t professionals program with block interfaces?

One reason is that direct manipulation has efficiency dis-advantages when making small edits. When creating anexpression such as (a/2 + b/2) in blocks, the programmermust find and drag blocks for each of the three arithmeticoperators, and then fill in holes with variables and numbers.Similarly, when rearranging an expression from (a/2+b/2) to(a+b)/2, the expression tree needs to be pulled apart and puttogether again, requiring more gestures and more forethoughtthan making the edits in text. HCI researchers observed thatvisual programming languages can have a higher viscositythan text code because they make small changes harder [11].

Beyond viscosity, blocks environments can have severalother usability disadvantages compared to textual program-ming languages:

• Low density: blocks take more space on the screen thanequivalent text code.

• Search and navigation: it can be challenging to findand navigate to the relevant part of a blocks programin a 2D workspace, only part of which may be visible.

• Source control: collaboration and version control sys-tems are difficult to use without a text representation.

The newest generation of blocks programming tools includefeatures that are designed to resolve the tension between

Figure 7: Pencil Code provides bidirectional switch-ing between blocks and text. Mode switching allowsusers to learn with blocks and edit quickly with text.

usability advantages of text versus blocks. There are two ap-proaches: text-style entry and bidirectional mode switching.

4.1 Text-Style Entry of BlocksSome new blocks environments, such as Greenfoot’s frame-

based Stride editor [16] and GP [24], are designed to be usedby programmers to create large programs, so efficient editingis an important design goal.

Both Stride and GP improve efficiency by providing text-based editing shortcuts within a blocks-oriented interface.To allow users to circumvent the step of finding a blockon the palette, these systems let programmers enter blocksthrough an in-line autocomplete mechanism. Blocks can stillbe chosen from a palette, but a knowledgeable programmercan insert them by typing.

The Stride editor also introduces a hybrid approach toediting code, differentiating between low-level and high-levelstructure (Figure 6). For expression-level code, it hides syn-tactic structure and allows traditional text editing, providinghigh-density display and lower viscosity. Visible tree struc-ture and drag-and-drop manipulation are used for higher-levelcode such as control flow and class declarations.

4.2 Bidirectional Mode SwitchingSome blocks environments provide a bidirectional transfor-

mation between a traditional text language and a blocks rep-resentation of that language. These include Pencil Code (Cof-fee Script) [2] (Figure 7), Code.org’s App Lab2 (JavaScript),BlockEditor (Java) [21], and Tiled Grace (Grace) [13]. Aliceand Blockly provide non-editable views of text code.

The hypothesis that motivates the design of dual-modetools is that users may benefit from the learnability of blocksin one mode, while they learn syntax and get the efficiencyof text in the other mode. This goal requires that the viewsbe linked. For text to be safe for users who may want toreturn to blocks, it must be possible to return to blocks.

In dual-mode editors, the text code is the primary repre-sentation of the program, and blocks are a projected userinterface view derived by parsing. This approach allows theeditor to fully represent text information such as spacing,but it also means that the editor must allow syntax errorsthat would not have been possible in blocks. Error-recoveryheuristics convert simple text syntax errors to special errorblocks, but complex errors can prevent mode switching.

4.3 Comparing ApproachesThere is a tradeoff between the two approaches to unifying

blocks and text. While the dual-mode editors provide directsupport for learning traditional text syntax such as JavaScript

2https://code.org/educate/applab

Page 6: Learnable Programming: Blocks and Beyond · 3.2 Chunking Information with Blocks Programming languages present a high cognitive load to a student who is learning a new syntax. For

Figure 8: Blocks programming in MadeUp. 3Dprinting is an area of rapid innovation, and blocksmake it possible to use new 3D modeling languageswithout a steep learning curve.

or Java, they also impose the cognitive overhead of workingwith syntax errors that that can only be introduced in textmode. Visualization research on multiple coordinated viewssuggests that the benefits of providing more than one viewneed to be balanced against the cognitive overhead imposedby switching between views [37].

Single mode structured editors have the advantage of aconceptual model free of syntax errors, because the primaryobject being edited is the abstract syntax tree. However, tomaintain consistency, many kinds of textual edits must beprevented, and other edits may require special tree editingcommands. These constraints raise editing viscosity, andthey may present additional cognitive barriers.

Interfaces that effectively bridge the gap between blocksand text are an active area of research.

5. APPLYING BLOCKS: TWO EXAMPLESLet us take a look at experimental blocks languages in two

specific domains that are unfamiliar to most programmers.

5.1 Programming 3D PrintersTraditionally, 3D printing models are drawn interactively

by direct manipulation using CAD software. Writing customcode to create a model is a powerful alternative approach,but coding for 3D fabrication has traditionally been theprovince of a few expert programmers. Now, the falling costand rising availability of 3D printers has made it possible fornon-specialists to write their own custom 3D modeling code.

Two recently developed languages bring programming for3D printing to novice users: BeetleBlocks [17] and Madeup[14]. Although the two systems have different languages,there are several commonalities: both are web-based inter-faces with a live 3D rendering of the shape being created, andboth provide a blocks language to simplify learning. Beetle-Blocks follows the principles of turtle graphics: a beetlemoves a “pen” that can be turned on and off, and 3D shapescan be created out of iterated strokes. MadeUp (Figure 8)takes a more abstract approach, allowing users to trace outboth paths and parametric surfaces. Special functions canrotate or extrude the paths to create solids.

The two languages offer different levels of power and ab-straction. Which language is the right one to use? This

from http://dbpedia.org/sparql

where

order by ↓ ▾ & limit to first 5 rows

↪ obj ▾

dbpedia : Paul_McCartney

dbpedia : George_Harrison

dbpedia : John_Lennon

dbpedia : Ringo_Starr

obj ▾━┫ ┣━▶dbo : formerBandMember

is a

&

dbr : The_Beatles

Figure 9: The SPARQL Playground is a blocks-based query execution tool that provides blocks forconstructing queries of RDF data. Query results(bottom) are also provided as blocks, and they canbe dragged to build into other queries.

domain is an excellent example of the advantage of the learn-ability of blocks. Both blocks languages have a very shallowlearning curve, and it is easy to try both.

5.2 Querying the Semantic WebAnother domain where learnability is essential is in query-

ing large datasets. Consider the problem of querying Re-source Description Framework (RDF) data from the seman-tic web. SPARQL is the standard language for queryingRDF; it includes several constructs for working with RDFtriples that distinguish it from other query languages such asSQL. However, potential users of SPARQL face two hurdles:First, programmers must learn the vocabulary and syntaxof SPARQL, with its specialized operators and constructs.Second, querying RDF requires not just knowledge of thelanguage, but also knowledge of instance and schema data.

To address both problems, Paolo Bottoni and Miguel Ce-riani have created a blocks language they call the SPARQLPlayground [4]. Rather than helping users learn about se-quential programs, their blocks language helps users select,filter, and join data using SPARQL primitives.

The SPARQL playground is interesting for a second rea-son: all query results in the playground are also returned asdraggable blocks (Figure 9). This feature allows users to saveinstance data on the programming workspace to be incorpo-rated into new queries. With the SPARQL playground, it iseasy to begin with general queries to explore the types of dataavailable, then use these discoveries to make refinements.

6. MAKING NEW BLOCKS LANGUAGESIt is now possible to create your own domain-specific blocks

environment using a blocks-based language toolkit. Blocks-language authors should be aware of at least three toolkits:Blockly3, Droplet [3], and OpenBlocks [29].

The original blocks metalanguage is MIT OpenBlocks.Created in 2007 by Ricarose Roque as the basis of StarLogoTNG, it allows a large degree of geometric customization.OpenBlocks has also been used in App Inventor Classic andBlockEditor. One drawback of OpenBlocks is that it requiresusers to download and install the Java JDK.

3https://developers.google.com/blockly

Page 7: Learnable Programming: Blocks and Beyond · 3.2 Chunking Information with Blocks Programming languages present a high cognitive load to a student who is learning a new syntax. For

The challenge of installation is addressed by Blockly, anHTML-based block language toolkit by Neil Fraser of Google.Blockly is currently the most popular blocks language toolkit:it is the tool behind App Inventor, the SPARQL playground,and MadeUp, as well as the Code.org Hour of Code puzzles.Future versions of Scratch will also use Blockly.

Droplet is the newest of the blocks language creation toolk-its, developed by Anthony Bau for use in Pencil Code, andalso used by Code.org in their App Lab. It is newer and lessmature than OpenBlocks and Blockly, but takes a uniqueapproach that allows seamless bidirectional transformationbetween all blocks and textual code.

7. SUMMARYWhen a programming language is provided as a user inter-

face that welcomes novice users, rather than as a technicaltool only for experienced developers, we arrive at a newpicture of what the programming environment should do:

• Vocabulary should derive from recognition, not recall;

• Cognitive load should be lowered by chunking code;

• Grammar rules and types should be made visible;

• Program chunks should be directly manipulable;

• Low-viscosity editing should also be possible;

• Coding should work without installation of tools;

• Simple concepts should be described with clear wordsand high-level abstractions;

• Runtime state and behavior should be visible;

• Examples should be easy to find and apply.

In short, for a programming tool to be usable by new orcasual programmers, its design must focus on learnability.

Blocks have proven to be effective at solving many of theseproblems. Although programming is still not nearly as widelylearned as it should be, the progress made by blocks languageinterfaces can inspire us all to see that programming can bemade more learnable.

The art of programming is the original human-computerinteraction, and it remains an unsolved usability challenge.We can still do more to make programming available to all.

8. REFERENCES[1] M. Armoni, O. Meerbaum-Salant, and M. Ben-Ari.

From Scratch to “real” programming. Transactions onComputing Education, 14(4), Feb. 2015.

[2] D. Bau, D. A. Bau, M. Dawson, and C. S. Pickens.Pencil Code: Block code for a text world. In 14thInternational Conference on Interaction Design andChildren, pages 445–448, 2015.

[3] D. A. Bau. Droplet, a blocks-based editor for text code.Journal of Computing Sciences in Colleges,30(6):138–144, June 2015.

[4] P. Bottoni and M. Ceriani. Using blocks to get moreblocks: Exploring linked data through integration ofqueries and result sets in block programming. In IEEEBlocks and Beyond Workshop, pages 99–102, Oct. 2015.

[5] J. Brandt, M. Dontcheva, M. Weskamp, and S. R.Klemmer. Example-centric programming: Integratingweb search into the development environment. In ACMSIGCHI Conference on Human Factors in ComputingSystems, CHI ’10, pages 513–522, 2010.

[6] J. Brandt, P. J. Guo, J. Lewenstein, M. Dontcheva, andS. R. Klemmer. Two studies of opportunisticprogramming: Interleaving web foraging, learning, andwriting code. In ACM SIGCHI Conference on HumanFactors in Computing Systems, CHI ’09, pages1589–1598, 2009.

[7] M. Conway, S. Audia, T. Burnette, D. Cosgrove, andK. Christiansen. Alice: Lessons learned from building a3D system for novices. In ACM SIGCHI Conference onHuman Factors in Computing Systems, CHI ’00, pages486–493, 2000.

[8] W. Dann, D. Cosgrove, D. Slater, D. Culyba, andS. Cooper. Mediated transfer: Alice 3 to Java. In 43rdACM Technical Symposium on Computer ScienceEducation, SIGCSE ’12, pages 141–146, 2012.

[9] B. Dorn and M. Guzdial. Graphic designers whoprogram as informal computer science learners. InSecond International Workshop on ComputingEducation Research, ICER ’06, pages 127–134, 2006.

[10] R. Garlick and E. C. Cankaya. Using Alice in CS1: aquantitative experiment. In 15th Annual Conference onInnovation and Technology in Computer ScienceEducation, ITiCSE ’10, pages 165–168, 2010.

[11] T. R. G. Green. Cognitive dimensions of notations. InA. Sutcliffe and L. Macaulay, editors, People andComputers V, pages 443–460. Cambridge UniversityPress, Cambridge, UK, 1989.

[12] P. J. Guo. Online Python tutor: Embeddableweb-based program visualization for CS education. In44th ACM Technical Symposium on Computer ScienceEducation, SIGCSE ’13, pages 579–584, 2013.

[13] M. Homer and J. Noble. Combining tiled and textualviews of code. In 2014 Second IEEE WorkingConference on Software Visualization, VISSOFT ’14,pages 1–10, Sept 2014.

[14] C. Johnson and P. Bui. Blocks in, blocks out: Alanguage for 3D models. In IEEE Blocks and BeyondWorkshop, pages 77–82, Oct. 2015.

[15] A. J. Ko, B. A. Myers, and H. H. Aung. Six learningbarriers in end-user programming systems. In IEEESymposium on Visual Languages and Human CentricComputing, VL/HCC ’04, pages 199–206, 2004.

[16] M. Kolling, N. C. C. Brown, and A. Altadmri.Frame-based editing: Easing the transition from blocksto text-based programming. In 10th Workshop inPrimary and Secondary Computing Education,WiPSCE ’15, Nov. 2015.

[17] D. Koschitz and E. Rosenbaum. Exploring algorithmicgeometry with “Beetle Blocks:” a graphicalprogramming language for generating 3d forms. In 15thInternational Conference on Geometry and Graphics,pages 380–389, Aug. 2012.

[18] S. Lerner, S. R. Foster, and W. G. Griswold.Polymorphic blocks: Formalism-inspired UI forstructured connectors. In 33rd Annual ACMConference on Human Factors in Computing Systems,CHI ’15, pages 3063–3072, 2015.

[19] D. J. Malan and H. H. Leitner. Scratch for buddingcomputer scientists. ACM SIGCSE Bulletin,39(1):223–227, Mar. 2007.

[20] J. H. Maloney and R. B. Smith. Directness and livenessin the morphic user interface construction environment.

Page 8: Learnable Programming: Blocks and Beyond · 3.2 Chunking Information with Blocks Programming languages present a high cognitive load to a student who is learning a new syntax. For

In 8th Annual ACM Symposium on User Interface andSoftware Technology, pages 21–28, 1995.

[21] Y. Matsuzawa, T. Ohata, M. Sugiura, and S. Sakai.Language migration in non-CS introductoryprogramming through mutual language translationenvironment. In 46th ACM Technical Symposium onComputer Science Education, SIGCSE ’15, pages185–190, 2015.

[22] O. Meerbaum-Salant, M. Armoni, and M. Ben-Ari.Habits of programming in Scratch. In 16th AnnualJoint Conference on Innovation and Technology inComputer Science Education, ITiCSE ’11, pages168–172, 2011.

[23] G. A. Miller. The magical number seven, plus or minustwo: some limits on our capacity for processinginformation. Psychological Review, 63(2):81, 1956.

[24] J. Monig, Y. Ohshima, and J. Maloney. Blocks at yourfingertips: Blurring the line between blocks and text inGP. In IEEE Blocks and Beyond Workshop, pages51–53, Oct. 2015.

[25] B. Moskal, D. Lurie, and S. Cooper. Evaluating theeffectiveness of a new instructional approach. ACMSIGCSE Bulletin, 36(1):75–79, 2004.

[26] J. Nikander, A. Korhonen, O. Seppala, V. Karavirta,P. Silvasti, and L. Malmi. Visual algorithm simulationexercise system with automatic assessment: Trakla2.Informatics in Education-An International Journal,3(2):267–288, 2004.

[27] K. Powers, S. Ecott, and L. M. Hirshfield. Through thelooking glass: Teaching CS0 with Alice. ACM SIGCSEBulletin, 39(1):213–217, Mar. 2007.

[28] M. Resnick, J. Maloney, A. Monroy-Hernandez,N. Rusk, E. Eastmond, K. Brennan, A. Millner,E. Rosenbaum, J. Silver, B. Silverman, and Y. B. Kafai.Scratch: programming for all. Communications of theACM, 52(11):60–67, 2009.

[29] R. Roque. Openblocks: An extendable framework forgraphical block programming systems. Master’s thesis,MIT, May 2007.

[30] M. B. Rosson, J. Ballin, and H. Nash. Everydayprogramming: Challenges and opportunities forinformal web development. In 2004 IEEE Symposiumon Visual Languages and Human Centric Computing,VL/HCC’04, pages 123–130, Sept 2004.

[31] N. Sawadsky and G. C. Murphy. Fishtail: From taskcontext to source code examples. In 1st Workshop onDeveloping Tools As Plug-ins, pages 48–51, 2011.

[32] R. B. Shapiro and M. Ahrens. Beyond blocks: Syntaxand semantics. Communications of the ACM,59(5):39–41, 2016.

[33] J. Sorva and T. Sirkia. Context-sensitive guidance inthe UUhistle program visualization system. InProceedings of the 6th Program Visualization Workshop,pages 77–85, 2011.

[34] A. Stefik and S. Siebert. An empirical investigation intoprogramming language syntax. Transactions onComputing Education, 13(4):19:1–19:40, Nov. 2013.

[35] T. Teitelbaum and T. Reps. The Cornell programsynthesizer: A syntax-directed programmingenvironment. Communications of the ACM,24(9):563–573, 1981.

[36] M. Vasek. Representing expressive types in blocksprogramming languages. Undergraduate thesis,Wellesley College, May, 2012.

[37] M. Q. Wang Baldonado, A. Woodruff, andA. Kuchinsky. Guidelines for using multiple views ininformation visualization. In Proceedings of theWorking Conference on Advanced Visual Interfaces,pages 110–119, 2000.

[38] D. Weintrop and U. Wilensky. To block or not to block,that is the question: students’ perceptions ofblocks-based programming. In 14th InternationalConference on Interaction Design and Children, pages199–208, 2015.

[39] U. Wolz, H. H. Leitner, D. J. Malan, and J. Maloney.Starting with Scratch in CS1. ACM SIGCSE Bulletin,41(1):2–3, Mar. 2009.

[40] M. Zelkowitz. Reversible execution. Communications ofthe ACM, 16(9):566, 1973.

APPENDIX: SIDEBARBlocks-Based Educational ToolsOn the web:

• Scratch (https://scratch.mit.edu) - in-browser anima-tion and game creation, with support for extensions

• Code.org (http://code.org) - a variety of tools includingpuzzle programming exercises with tutorial videos

• Snap! (http://snap.berkeley.edu) - enhanced languageinspired by Scratch that includes first class functions

• App Inventor (http://appinventor.mit.edu) - creationof Android apps using in-browser blocks IDE

• Pencil Code (https://pencilcode.net) - creates Coffee-Script web apps, transforming between text and blocks

• StarLogo Nova (http://www.slnova.org) - multi-agentsimulations and games in a 3D rendered world

• Blockly Games (https://blockly-games.appspot.com/) -a set of puzzles to solve with programming blocks

• GameBlox (https://gameblox.org) - game creation thatincludes clonable agents, physics, and more

Downloadable:

• AgentSheets / AgentCubes (http://www.agentsheets.com)- pioneering blocks environments for creating rule-basedgames and simulations

• Alice (http://www.alice.org) - pioneering blocks envi-ronment for creating 3D virtual worlds; support forexporting to Java

• Looking Glass (https://lookingglass.wustl.edu) - 3Danimated story creation; supports independent learning

• Kodu (http://www.kodugamelab.com) - rule-based pro-gramming of games for xBox and PC

On mobile:

• Scratch Jr (http://www.scratchjr.org) - programmingof animated scenes aimed at preliterate children

• Pocket Code (http://www.catrobat.org) - blocks pro-gramming for small form factor of mobile devices

• Tynker (https://www.tynker.com) - polished commer-cial platform for game and animation creation

• Hopscotch (https://www.gethopscotch.com) - creatinggames and animations on iPhone and iPad