4 ms·
Snap! is not simply all the usability and functionality of Logo, but also all the functionality and power of Scheme! Without any of the dumbing down of Scratch
by DonHopkins 5y ago
Snap! is not simply all the usability and functionality of Logo, but also all the functionality and power of Scheme! Without any of the dumbing down of Scratch or Logo. Visual block programming. Turtle Graphics. Sprites. Lexical scoping. Lambda. Closures. Call/cc. Plus JavaScript integration and web stuff. With extensions for networking, AI, machine learning, speech synthesis and recognition, graph theory, robotics, Lego, Arduino, 3d graphics, 3d design, 3d fabrication, and 3d printing, embroidery, etc. ;)
https://dl.acm.org/doi/pdf/10.1145/3386329 https://dl.acm.org/doi/pdf/10.1145/3386329
History of Logo. Proc. ACM Program. Lang., Vol. 4, No. HOPL, Article 79. Publication date: June 2020.
6.2 Brian Harvey’s Personal Narrative on Snap!: Scheme Disguised as Scratch (pp. 49-50)
In 2009, the University of California, Berkeley, was one of several universities developing a new
kind of introductory computer science course, meant for non-CS majors, to include aspects of
the social implications of computing along with the programming content. Scratch wasn’t quite
expressive enough to support such a course (it lacked the ability to write recursive functions), so
Prof. Daniel Garcia and I thought "What’s the smallest change we could make to Scratch to make it
usable in our course?" After 20 years teaching Structure and Interpretation of Computer Programs
[Abelson et al. 1984], the best computer science text ever written, I knew that the answer to "what’s
the smallest change" is generally "add lambda." I joined forces with German programmer Jens
Mönig, who had developed BYOB (Build Your Own Blocks), an extension to Scratch with custom
(user-defined) blocks, including reporters and predicates. At that time we were hoping to convince
the Scratch Team to adopt our ideas, so we took "smallest change" very seriously. BYOB 3.0 [Harvey
and Mönig 2010], with first class procedures and first class lists, added only eight blocks to Scratch’s
palette. (The code is almost all Jens’s. My contribution was part of the user interface design, plus
teaching Jens about lambda.) Version 3.1 added first class sprites with Object Logo-style inheritance.
The Berkeley course, The Beauty and Joy of Computing (BJC) [Garcia et al. 2012], is also used by
hundreds of high schools, especially since the College Board endorsed it as a curriculum for their
new AP CS Principles exam. Unfortunately, some teachers have no sense of humor, and so BYOB
version 4.0, a complete rewrite in JavaScript, was renamed Snap! [Harvey 2019]. [18]
Since Scratch seemed to be positioned as the successor to Logo, it was a goal for Snap! to restore
the features from Logo that are missing in Scratch. The most important missing feature, the ability
to define functions (and therefore to use recursive functions), is at the core of the new language.
(Scratch introduced user-definable command blocks in version 2.0, but still doesn’t support user defined reporters.) Scratch had also replaced the structured text (word and sentence) functions with
a flat text string data type. We wanted to be backward compatible with Scratch, so we implemented
words and sentences as a library, defining first, last, butfirst, and so on. (Since block languages
allow multi-word procedure names, and you don’t have to type the long name in order to use the
procedure, the library names are, e.g., all but first letter of.)
Lists are first class and can be arbitrarily deep in sublists. The usual higher order functions
on lists are provided; the graphical representation of lambda is built into the blocks representing
higher order functions, and so beginning users can use higher order functions in simple cases
without thinking hard about function-as-data at all, but the full power of lambda is available to
more advanced programmers. It took us three tries to get the lambda design right, but we’re very
proud of its pedagogic benefits.
Another of our goals for Snap! is to be a complete version of Scheme; it was largely as a way
of planting that flag that we added call with current continuation, not taught in BJC (nor
even in SICP) but used to implement tools such as catch and throw as library procedures written
in Snap! itself. As of this writing, macros are only half-implemented; users can define procedures
whose inputs are unevaluated (more precisely, thunked, since procedures are first class), but cannot
yet inject code into the caller’s environment.
Snap! is lexically scoped, not least to allow the use of closures as objects, but a planned extension
is "hybrid scope": variable names follow lexical scope, but instead of giving an error message when
no binding is found in the lexical environment, the evaluator will instead look in the dynamic
environment. So name capture is impossible, since the global environment is examined before the
dynamic environment. (Only if a mistyped name matches another name can the user get the wrong
variable rather than an error message. But mistyping can’t really happen in a block language.) This,
too, is an effort to be a Logo as well as a Scheme.
Since Snap! is free software (AGPL), it has served as the starting point for at least a dozen significant extensions, including BeetleBlocks [Koschitz and Rosenbaum 2012; Rosenbaum et al. 2011]
for 3-D graphics and 3-D printing; TurtleStitch [Mayr-Stalder and Aschauer 2016] for controlling
sewing machines to do embroidery; Edgy [Bird et al. 2013] for studying graph theory; NetsBlox
[Ledeczi and Broll 2016] for access to online data APIs and collaborative editing of projects; and
others. The ability to write new Snap! blocks in Javascript, from the Snap! editor, has allowed
many other user-level extension libraries, including support for robots and other hardware. Snap!
features such as first class procedures help authors develop these extensions, even if the users of
an extension don’t see that.
[18] For non-Anglophones, "BYOB" is used in party invitations as an abbreviation for "bring your own booze."