# Scratch (Language)

## Summary


Scratch is a visual block-based programming language designed for children aged 8-16. Children can create games, animations and stories in a fun-filled manner while also learning to reason and think creatively. Scratch is also an online community where creators can share their projects and be inspired by other projects. 

Scratch is available in more than 150 countries in more than 60 languages. It's usage is license free. Scratch itself is open sourced. It's developed and overseen by the Scratch Foundation. 

Scratch has been called "the YouTube of interactive media." Scratch has inspired other visual programming languages such as ScratchJr for ages 5-7, Snap!, mBlock, Stencyl and MIT App Inventor.

## Discussion

### Given dozens of programming languages, why do I need Scratch?

Many popular programming languages are text-based. Programmers have to type the program code. They need to learn and remember the language syntax. For beginners, making syntax errors is a common problem. A text-based interface is less accessible and less fun for children.

On the contrary, Scratch is designed for children aged 8-16. It can be taught at schools for students across all disciplines, including math, computer science, language arts, and social studies. This is important for today's economy where learning to code is part of computer literacy. 

Because Scratch is visual, it's less intimating than text-based programming languages. Programs in Scratch are created by drag-and-drop actions on colourful blocks. The use of shapes and colours act as visual cues to help programmers create, edit or understand Scratch programs more easily. In fact, shapes fit together like a jigsaw puzzle. It's designers claim that, 

> Scratch is more tinkerable, more meaningful, and more social than other programming environments.

Research has shown that Scratch enables students grasp computational thinking concepts such as parallelism, synchronization, flow control, user interactivity, data representation, abstraction and problem decomposition. 


### What types of projects can I create with Scratch?

The main or popular project types in Scratch are: 

    + **Games**: Games are the most common type, giving their creators large fan following. Even classics such as Pacman and Mario have been recreated in Scratch.
    + **Animations**: Using costume changes and movements, animations can be easily created.
    + **Music**: MIDI sound bank allows programmers to play up to 128 instruments. Volume and tempo can be adjusted. It's also possible to import a song and play it.
    + **Art**: Interactive art is one of the purposes for which Scratch was designed. More recently, non-interactive art is becoming common though less programming may be involved in creating them.
    + **Stories**: Not very common since many can be considered as animations. Stories could be adventures or feature many costumes and backdrops.
    + **Simulations**: Not that common but high quality projects involving physics, weather, gravity and 3D simulations have been created. Operating systems and engines are two common themes.Other types include tutorials, advertisements, sprite packs, slideshows, petitions, 100% pen, interviews, etc. 


### What are some essential Scratch programming terms?

From a complete glossary for Scratch, we highlight a few essential terms:  

    + **Stage**: Area where the project is displayed when active.
    + **Backdrop**: Background of the stage.
    + **Block**: Programming command that can be dragged and dropped into the code area.
    + **Code Area**: Area where scripts are edited.
    + **Script**: A stack of blocks make up a script. Determines how a sprite interacts with other sprites and the backdrop.
    + **Sprite**: Character or object on the stage that performs actions controlled by one or more scripts.
    + **Clone**: A copy of a sprite.
    + **Costume**: Appearance of a sprite. Often subtle variations of a sprite can be used to create animations.
    + **Bubble**: A speech bubble or a thought bubble signifies what a sprite is speaking or thinking.
    + **Scrolling**: Action of sliding a sprite across the stage.
    + **Broadcast**: A message sent through the Scratch program. Allows sprites to communicate with one another.
    + **Event**: Key press or mouse button clicks are example events. Can be used to trigger scripts.
    + **Studio**: A place to group and organize multiple projects.
    + **Pen**: Allows us to draw on the stage.

### What's the anatomy of the Scratch IDE?

The main areas of the IDE include the Stage, the Block Palette and the Code Area. The Stage is where the currently selected sprite appears. When the program runs, the results are displayed in the Stage. Stage can be maximized to full screen. 

Just below the Stage is the list of sprites that one can choose. When a sprite is selected, the scripts associated with it appear in the Code Area. These scripts can be created or edited by drag-and-drop actions of blocks from the Block Palette. 

The Costumes tab allow programmers to change the look of a sprite and thereby create visual effects and animations. The Sounds tab enables attaching sounds and music to the sprite. 


### Which are the different shapes and categories of blocks in Scratch?

Blocks come in different shapes and categories. Each category comes in a different colour. 

**Block shape** represents a certain context of usage. For example, Hat Blocks occur at the start of a script whereas Cap Blocks occur at the end of a script. Their unique shapes mean that they can't be mistakenly used elsewhere within the script. Stack Blocks perform the main actions. Boolean Blocks return true or false. Reporter Blocks report fixed numbers, strings or variables. C Blocks (also called Wrap Blocks) wrap other blocks and are of Control category. Some C Blocks are capped at the bottom. 

**Block category** represents a certain type of functionality. Categories include Motion Blocks, Looks Blocks, Sound Blocks, Events Blocks, Control Blocks, Sensing Blocks, Operators Blocks, Variables Blocks, My Blocks, and Extensions. 

With My Blocks, programmers can define a custom script and call it with inputs from other scripts. Use of My Blocks reduces overall project size. 


### How do I get started with programming in Scratch?

Create an account on Scratch website and start creating projects online. Perhaps the easiest way to work with Scratch is to create and edit projects via a web browser. No installation is required.

Those who wish to work offline (without Internet connection), can download Scratch. Installations are available for Windows, macOS, ChromeOS and Android (tablets only). Scratch projects created from these installed apps can't be directly shared with the online community. You can however export a project, and then upload and share online. 

Official documentation is on the Scratch Wiki. 

You can explore Scratch projects shared by others. Participate in the Scratch discussion forum. The Scratch Ed channel on YouTube has many videos of tutorials, examples, events and workshops.

Two useful books for beginners are Scratch 3 Programming Playground by Al Sweigart and Scratch Programming in Easy Steps by Sean McManus. The latter book doesn't cover Scratch 3.0 but its examples are available online. 

Advanced programmers who wish to contribute to Scratch's open source codebase can find the code on GitHub.

## Milestones

1970

The idea of using programming as a skill and a learning tool probably begins with Seymour Papert in the 1970s. He creates the **LOGO** programming language. Language commands control movements of a digital robot. This helps children grasp geometry. A pen is used to draw shapes on the screen. LOGO and its turtle graphics are subsequently widely adopted in UK schools. 

2003

Mitch Resnick and John Maeda of MIT, and Yasmin Kafai of UCLA propose the idea of Scratch to National Science Foundation (NSF). Resnick is part of Lifelong Kindergarten Group of MIT Media Labs. With an NSF grant, they create **Scratch 0.1** by October. This version doesn't have a Block Palette and blocks are more square shaped. 

Jan  
2004

First **Scratch website** goes live. Elsewhere, it's reported that Scratch website was publicly launched in May 2007. 

Jan  
2007

**Scratch 1.0** is released. It's also the first version released to public. The Scratch layout in this version resembles closely with a version from January 2005. Thus, we may state that the application has reached good level of maturity. 

Jul  
2009

**Scratch 1.4** is released. Earlier versions include v1.1 (May 2007), v1.2 (Dec 2007), and v1.3 (Sep 2008). 

May  
2013

**Scratch 2.0** is released. It gets a new user interface. Among its new features are procedures, cloning, cloud data, vector graphics, show/hide lists, and sound editor. The offline editor of this version continues to be available even in April 2021. 

2015

Since Scratch 2.0 was based on Flash, and Flash is no longer preferred on the web, Google proposes a partnership with MIT Media Lab to redesign Scratch. By 2015, many other visual programming languages (Code.org, App Inventor, MakeCode) are already using a JavaScript library called **Blockly**. Scratch adopts Blockly. The redesigned UI and blocks are released as part of Scratch 3.0 (Jan 2019). 

Jan  
2019

**Scratch 3.0** is released. Scratch 2.0 projects are compatible with the new version. Usability of the app is improved. Pen Blocks and Music Blocks are moved to Extensions. Stage is on the right, unlike Scratch 2.0 that had it on the left. 

Apr  
2021

Scratch community has close to 75 million shared projects, 70 million registered users, 448 million comments, and 29 million studios. In March, the site received 613 million pageviews and 29 million unique visitors. In TIOBE Index, Scratch ranks at position 22 in terms of popular programming languages. In April 2020, it was within the top 20.