expression-level code, it hides syntactic structure and allows traditional text
editing, providing high-density display
and lower viscosity. Visible tree structure and drag-and-drop manipulation
are used for higher-level code such as
control flow and class declarations.
Bidirectional Mode Switching. Some
blocks environments provide a bidirectional transformation between a
traditional text language and a blocks
representation of that language. These
include Pencil Code (CoffeeScript)
(Figure 7), Code.org’s App Labb (
21 and Tiled
13 Alice and Blockly provide non-editable views of text code.
The hypothesis that motivates the design of dual-mode tools is that users may
benefit from the learnability of blocks in
one mode, while they learn syntax and get
the efficiency of text in the other mode.
This goal requires the views be linked.
For text to be safe for users who may want
to return blocks, it must be possible to
switch between modes.
In dual-mode editors, the text code
is the primary representation of the
program, and blocks are a projected
user interface view derived by parsing. This approach allows the editor to
fully represent text information such
as spacing, but it also means the editor must allow syntax errors that would
not have been possible in blocks.
Error-recovery heuristics convert simple text syntax errors to special error
blocks, but complex errors can prevent
Comparing approaches. There is a
trade-off between the two approaches
to unifying blocks and text. While the
dual-mode editors provide direct support for learning traditional text syntax
introduced in text mode. Visualization research on multiple coordinated
views suggests the benefits of providing more than one view need to be balanced against the cognitive overhead
imposed by switching between views.
Single mode structure editors have
the advantage of a conceptual model
free of syntax errors, because the primary object being edited is the abstract syntax tree. However, to main-
Figure 7. Pencil Code provides bidirectional switching between blocks and text. Mode
switching allows users to learn with blocks and edit quickly with text.
Figure 8. Blocks programming in MadeUp. 3D printing is an area of rapid innovation, and
blocks make it possible to use new 3D modeling languages without a steep learning curve.
Figure 9. The SPARQL playground is a blocks-based query execution tool that provides
blocks for constructing queries of RDF data. Query results (bottom) are also provided as
blocks, and they can be dragged to build into other queries.