Snap! (programming language)
Snap! is a free block-based educational graphical programming language and online community. Snap allows students to explore, create, and remix interactive animations, games, stories, and more, while learning about mathematical and computational ideas. While inspired by Scratch, Snap! has many advanced features. The Snap! editor, and programs created in it, are web applications that run in the browser without requiring installation. It is built on top of Morphic.js, a Morphic GUI, written by Jens Mönig as 'middle layer' between Snap! itself and 'bare' JavaScript.
User interface
In Snap!, the screen is organized in three resizable columns containing five regions: the block group selector, the blocks palette, the main area, and the stage area with the sprite selector showing sprite thumbnails below it.In the interactively resizable stage area are shown the graphical results of the scripts running in the script area and/or interactively double-clicked individual blocks in any palette. Individual blocks can be dragged from the palette onto the scripts area to be associated with the selected sprite.
Snap!'s blocks are divided into eight groups: Motion, Looks, Sound, Pen, Control, Sensing, Operators, and Variables. The layout of these groups in the block group selector is shown in the table below.
The central area can show scripts, costumes/backdrops, or sounds associated with the selected sprite. What that area shows depends on the selected tab.
Features
The most important features that Snap! offers, but Scratch does not, include:- Expressions using anonymous functions, represented by a block inside a gray ring, having one or more empty slot/argument that are filled by a "higher order function".
- Lists that are first class
- First class sprites
- "Hyperblocks": functions whose natural domain is scalars, extended to accept lists as inputs and apply the underlying function to the scalars in the list or a sublist
- Nestable sprites
- Codification of Snap! programs to text languages such as Python, JavaScript, C, etc.
- Metaprogramming, reflection, and macros
Mascot
Special-purpose blocks (libraries)
Extended sets of blocks can be found in Snap! libraries, such as the 'streams' library that enables one to make the complete, infinite Fibonacci sequence, for example, using the special blocks from the library.Many other libraries are available, such as the 'list utilities' library, the 'words, sentences' library, the 'iterations' library, the 'animation' library, the 'frequency distribution' library, the 'audio computation' library, the 'bar charts' library, the 'world map' library, the 'colors and crayons' library, the 'strings and multi-line input' library, the 'parallelization' library, etc. for other special purposes.
Limitations
While the software itself has little restraints, it does have some limitations.These include:
- No native cloud variables
- 10 megabyte file cap for uploading
- The Javascript block is opt-in, and can only be run in the editor.
History
License
The source code of Snap! is GNU Affero General Public License licensed and is hosted on GitHub. The earlier, desktop-based 3.x version's code is available under a license that allows modification for only non-commercial uses and can be downloaded from the UC Berkeley website or CNET's download.com and TechTracker download page.Platforms
Snap! runs on the major web-browsers on Windows, iOS, MacOS and Linux devices.Supported web-browsers such as
- Firefox
- Chrome
- Opera GX
- Microsoft Edge
- Safari
Implementation
All things visible in Snap! are morphs themselves, i.e. all buttons, sliders, dialog boxes, menus, entry fields, text rendering, blinking cursors etc. are created with morphic.js rather than using HTML DOM elements. Snap! caches the shapes of sprites so the sprite doesn't have to be re-drawn onto a new Canvas element every time the mouse moves over its bounding box. It does not cache blocks, however. Instead it manages the insides of C-shaped blocks through the morphic "holes" mechanism.
All user interaction is triggered by events, which are passed on from the root element "the world" to its submorphs. Dropping a morph causes it to become embedded in a new 'owner' morph. In Morphic the preferred way to run an animation is to register it with the World by adding it to the World's animation queue. The World steps each registered animation once per display cycle independently of the Morphic stepping mechanism.