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)
2
(Figure 7), Code.org’s App Labb (
JavaScript), BlockEditor (Java),
21 and Tiled
Grace (Grace).
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
mode switching.
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
such as JavaScript or Java, they also impose the cognitive overhead of working with syntax errors that can only be
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.
37
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-
b https://code.org/educate/applab
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.