wikiwand.com

Scratch (programming language) - Wikiwand

  • ️Sat Oct 11 2003

Scratch is a high-level, block-based visual programming language and website aimed primarily at children as an educational tool, with a target audience of ages 8 to 16.[9][10] Users on the site can create projects on the website using a block-like interface. Scratch was conceived and designed through collaborative National Science Foundation grants awarded to Mitchel Resnick and Yasmin Kafai.[11] Scratch is developed by the MIT Media Lab and has been translated into 70+ languages, being used in most parts of the world. Scratch is taught and used in after-school centers, schools, and colleges, as well as other public knowledge institutions. As of 15 February 2023, community statistics on the language's official website show more than 123 million projects shared by over 103 million users, and more than 95 million monthly website visits.[12] Overall, more than 1,150,000,000 projects have been created in total, with the site reaching its 1,000,000,000th project on April 12th, 2024.

Quick Facts Paradigm, Developer ...

Scratch
Scratch logo

Logo used since 16 October 2015

Scratch 3.0 editor

ParadigmEvent-driven, block-based programming language
DeveloperScratch Foundation
First appeared
  • 11 October 2003; 21 years ago (prototype Scratch 0.1)[1]
  • 15 May 2007; 17 years ago (Scratch 1.0)[2]
  • 9 May 2013; 11 years ago (Scratch 2.0)
  • 2 January 2019; 6 years ago (Scratch 3.0)
Stable release
  • Scratch 3.0 (online editor) / 2 January 2019; 6 years ago
  • Scratch 3.29.1 (offline editor) / 27 February 2022; 3 years ago
Implementation languageSqueak (Scratch 1.x)
ActionScript (Scratch 2.0)[3]
HTML5, JavaScript (Scratch 3.0)[3][4]
OSMicrosoft Windows, macOS, Linux (via renderer), HTML5 (via web browser), iOS, iPadOS, and Android.
License

    GNU Affero General Public License (Scratch 3.0)[5]

    Filename extensions.sb, .sprite (Scratch 1.x)
    .sb2, .sprite2 (Scratch 2.0)
    .sb3, .sprite3 (Scratch 3.0)
    Websitescratch.mit.edu
    Influenced by
    Logo, Smalltalk, HyperCard, StarLogo, AgentSheets, AgentCubes, Etoys
    Influenced
    Catrobat,[6] ScratchJr,[7] Snap!,[8] mBlock, Turtlestitch

    Close

    Scratch takes its name from a technique used by disk jockeys called "scratching", where vinyl records are clipped together and manipulated on a turntable to produce different sound effects and music. Like scratching, the website lets users mix together different media (including graphics, sound, and other programs) in creative ways by creating and "remixing" projects, like video games, animations, music, and simulations.[13]

    User interface

    A program to change the background and make a sprite speak

    The Scratch interface is divided into three main sections: a stage area, block palette, and a coding area to place and arrange the blocks into scripts that can be run by pressing the green flag or clicking on the code itself. Users may also create their own code blocks, which will appear in the "My Blocks" section.

    The stage area features the results (e.g., animations, turtle graphics, either in a small or normal size, with a full-screen option also available) and all sprites' thumbnails being listed in the bottom area. The stage uses x and y coordinates, with 0,0 being the stage center.[14]

    With a sprite selected at the bottom of the staging area, blocks of code can be applied by dragging them from the block palette into the coding area. The Costumes tab allows users to change the look of the sprite with a vector and bitmap editor in order to create various effects, including animation.[14] The Sounds tab allows attaching sounds and music to a sprite.[15]

    When creating sprites and also backgrounds, users can draw their own sprites manually,[14] choose a sprite from the library, or upload an image.[15]

    The table below shows the categories of the programming blocks:

    More information Category, Notes ...

    Block categories in Scratch
    Category Notes
    Motion Movements of sprites, like angles and directions.
    Looks Controls the visuals of the sprite.
    Sound Plays audio files and effects.
    Events Event handlers and broadcasters.
    Control Conditionals, loops, and cloning.
    Sensing Sprites can interact with other sprites, the mouse pointer, and the backdrop.
    Operators Mathematical operators, conjunctions, and comparisons .
    Variables Blocks to access and set variables. Cloud variables are synced across all running versions of the project.
    Lists Blocks to access and interact with lists.
    My Blocks User-defined functions, accessible as blocks. They can have inputs and have the option to run without a screen refresh.
    Extensions Extra categories (e.g. Pen, Music) of blocks that can be added to a project at any time.

    Close

    Offline editing

    One of the 4 different scripts for the getting started built-in tutorial.
    Four different scripts for the getting started built-in tutorial.

    An offline "Desktop Editor" for Scratch 3.0 is available for Microsoft Windows 10 and above in the Microsoft Store, Apple's macOS, ChromeOS, and Android;[16] this allows the creation and playing of Scratch programs offline. The offline editor can also be downloaded in previous versions, such as Scratch 2.0 and Scratch 1.4 (an archive of older versions is found here).

    Extensions

    In Scratch, extensions add extra blocks and features that can be used in projects. In Scratch 2.0, the extensions were all hardware-based and Pen was a normal category. Software-based extensions were added in Scratch 3.0, such as text-to-speech voices, along with some new hardware-based extensions like the micro:bit. The extensions are listed below.

    An example of the Scratch 3 Extensions Page.

    Physical

    • LEGO Mindstorms EV3 – Control motors and receive sensor data from the Lego Mindstorms EV3
    • Makey Makey – Use Makey Makey to control projects
    • LEGO Education WeDo 2.0 – control motors and receive sensor data from the Lego WeDo
    • micro:bit – Use of a micro:bit to control projects
    • LEGO BOOST – Bring robotic creations to life
    • Go Direct Force & Acceleration – Sense pull, push, motion, and spin

    Digital

    Many of the digital extensions in Scratch 3.0 used to be regular block categories that were moved to the extensions section to reduce clutter. These include:

    • Music – Play digital instruments (drums, trumpets, violins, pianos, and more). Previously part of the Sound category.
    • Pen – Draw on the Stage with a variety of thicknesses and color. Previously a normal block category.
    • Video Sensing – Detect motion with the camera. Previously in the Sensing category.

    New digital extensions have also been added in collaborations with commercial companies. These include:

    • Text to Speech – Converts words in a text into voice output, especially having an option for languages (variety of voices, supplied by Amazon)
    • Translate – Uses Google Translate to translate text from one language into a variety of other languages, including Arabic, Chinese, Dutch, English, French, Greek, Norwegian, and Japanese
    • Makey Makey – Options for better key pressing and press multiple keys in order. You can grab a join block if you want more control on the extension.

    A paper published in 2019 by NYU argues and illustrates, for coding music with Scratch, "that the music and sound blocks as currently implemented in Scratch may limit and frustrate meaningful music-making for children, the core user base for Scratch."[17]

    Scratch Lab

    The Scratch Lab[18] displays experiments from the Scratch Team, intended to explore whether new features may be added to the full website in the future. Experimental features currently under development include:

    • Video Sprites – Fill sprites with live video.
    • Face Sensing – Make animated costumes and games that interact with your face.
    • Animated Text – Bring words to life with colors, fonts, and animations.
    Thumb
    A Scratch programming workshop

    Scratch is used in many different settings: schools, museums, libraries, community centers, and homes.[19][20][21] Scratch is designed primarily for users aged 8–16, but it is used by all ages and has a sizeable adult user base as of 2009.[10][22] This wide outreach has created many surrounding communities, both physical and digital.[12] In April 2020, the Tiobe ranking of the world's programming languages included Scratch in the top 20. According to Tiobe, there are 50 million projects written in Scratch, and every month one million new projects are added.[23]

    Educational users

    Scratch is used as the introductory language because the creation of interesting programs is relatively easy, and skills learned can be applied to other programming languages such as Python and Java.

    Scratch is not exclusively for creating games. With the provided visuals, programmers can create animations, text, stories, music, art, and more. There are already many programs that students can use to learn topics in math, history, and even photography. Scratch allows teachers to create conceptual and visual lessons and science lab assignments with animations that help visualize difficult concepts. Within the social sciences, instructors can create quizzes, games, and tutorials with interactive elements. Using Scratch allows young people to understand the logic of programming and how to creatively build and collaborate.[24]

    Scratch is taught to more than 800 schools and 70 colleges of the DAV organization in India and across the world.[25][26]

    In higher education, Scratch is used in the first week of Harvard University's CS50 introductory computer science course.[27][28]

    Thumb
    "Jumper", an example of a game created with Scratch 2.0
    Thumb
    "Shadow", an example of a game created with Scratch 3.0

    Users of Scratch are called "Scratchers". Scratchers have the capability to share their projects and receive feedback. Projects can be uploaded directly from the development environment to the Scratch website and any member of the community can view and download the full source code to study or to remix into new projects.[29][30] Scratchers can also create project studios, comment, favorite, and "love" others' projects, follow other members to see their projects and activity, and share ideas. Projects range from games and animations to practical tools. Additionally, to encourage the creation and sharing amongst users, the website frequently establishes "Scratch Design Studio" challenges.[31]

    The MIT Scratch Team works to ensure that this community maintains a friendly and respectful environment for all people.[32][33]

    Educators have their own online community called ScratchEd, developed and supported by the Harvard Graduate School of Education. In this community, Scratch educators share stories, exchange resources, and ask questions.[34]

    Scratch Studios

    Scratchers can upload their projects to studios where fellow scratchers can upload their project for others to see and for other Scratchers to view, comment and remix their project. A studio usually consists of different projects made by Scratchers. Some Scratch studios are created by Scratchers to put all their projects into one library.

    Scratch Wiki

    The Scratch Wiki is a support resource for Scratch and information about its website, history, and phenomena surrounding it. Although supported by the Scratch Team (the developers of Scratch), it is primarily written by Scratch users (Scratchers) and is hosted independently of the main Scratch website.[35] There are other wikis in languages besides English available on the Scratch Wiki base domain.

    Roles

    Roles are displayed as a label under a user's username on profile pages and on forum posts. To prevent vandalism, new accounts have the "New Scratcher" role, as opposed by the usual "Scratcher" role. Some restrictions are imposed onto New Scratcher accounts, including the inability to use cloud data and a minimum 30 second cooldown period between posting comments.[36] After a period of time of interacting and creating projects, an account will be eligible to gain the Scratcher role.[37]

    Official moderators and developers of Scratch are labeled as part of the "Scratch Team" and usually have an asterisk at the end of their username.[38] The site also has special types of accounts for Students and Educators to use Scratch in the classroom.[39]

    Censorship

    In August 2020, GreatFire announced that the Chinese government had blocked access to the Scratch website. At the time, it was estimated that more than three million people in China were using it.[40][citation needed] The outlet cited the fact that Macau, Hong Kong and Taiwan were listed as countries on the website.[40][41]

    The source code for the project editor in all three major versions, as well as a majority of the current website, is hosted publicly on GitHub across various repositores.[42] Scratch 3.0 is JavaScript-based, 2.0 is programmed in ActionScript,[4] and the 1.x versions were based on Squeak, which itself is based on Smalltalk-80.[43]

    2.0 had an experimental JavaScript-based interpreter that was being developed in parallel with the ActionScript version.[44]

    In 3.0, Scratch blocks are implemented using Blockly, a JavaScript library developed by Google for creating block-based visual programming languages.[45][46]

    On 13 May 2014, a year after the release of Scratch 2.0, it was announced by a developer on the Scratch Forums that 2.0 would become open source.[47]

    Scratch Educators can gather in person at Scratch Educator Meetups. At these gatherings, Scratch Educators learn from each other and share ideas and strategies that support computational creativity.[48]

    An annual "Scratch Week", formerly known as "Scratch Day", is declared in May each year. Community members are encouraged to host an event on or around this day, large or small, that celebrates Scratch. These events are held worldwide, and a listing can be found on the Scratch Day website. Scratch Week is a series focusing on Scratch activities on the Scratch website.[49]

    Every April Fools' Day, the Scratch Team will play pranks on users and add Easter eggs, one example being that all event blocks in projects turn into cat versions of the same blocks.

    In the early 2000s, the MIT Media Lab's Lifelong Kindergarten group (LLK) was developing visual programming languages targeted towards children.[50] In 2003, Mitchel Resnick, Yasmin Kafai, and John Maeda were awarded a National Science Foundation grant for the development of a new programming environment for children to express themselves with code.[11] The LLK, led by Mitchel Resnick, in partnership with Yasmin Kafai's team at UCLA worked closely with Computer Clubhouses in Boston and Los Angeles to develop Scratch, grounding its design in the practices and social dynamics of these after-school youth centers.[11] It started as a basic programming language, with no labeled categories and no green flag.[51] Similar to AgentSheets[52] Scratch employed concepts of Tactile Programming later known as blocks-based programming. Scratch was made with the intention to teach kids to program.[51]

    The philosophy of Scratch encourages the sharing, reuse, and combination of code, as indicated by the team slogan, "Imagine, Program, Share".[53] Users can make their own projects, or they may choose to "remix" someone else's project. Projects created and remixed with Scratch are licensed under the Creative Commons Attribution-Share Alike License.[54] Scratch automatically gives credit to the user who created the original project and program in the top part of the project page.[21]

    Scratch was developed based on ongoing interaction with youth and staff at Computer Clubhouses. The use of Scratch at Computer Clubhouses served as a model for other after-school centers demonstrating how informal learning settings can support the development of technological fluency.[55]

    Scratch 2.0 was released on 9 May 2013.[14] The update changed the look of the site and included both an online project editor and an offline editor.[56] Custom blocks could now be defined within projects, along with several other improvements.[57] The Scratch 2.0 Offline editor could be downloaded for Windows, Mac, and Linux directly from Scratch's website, although support for Linux was later dropped. The unofficial mobile version had to be downloaded from the Scratch forums.[58][59]

    Thumb
    The Scratch website's homepage

    Scratch 3.0 was first announced by the Scratch Team in 2016. Several public alpha versions were released between then and January 2018, after which the pre-beta "Preview" versions were released.[60] A beta version of Scratch 3.0 was released on 1 August 2018.[61] for use on most browsers; with the notable exception of Internet Explorer.[62]

    Scratch 3.0, the first 3.x release version, was released on 2 January 2019.[63] On 28 June 2023,[64] the header and links on the Scratch Website changed from blue to purple, and new optional high-contrast block colors were introduced, to make the site easier for colorblind people to read and use.[65]

    On March 11, 2019, Scratch separated from MIT Media Lab.[66]

    In Scratch 1.4, an *.sb file was the file format used to store projects.[67]

    An *.sb file is divided into four sections:

    • "header", this 10-byte header contains the ASCII string "ScratchV02" in versions higher than Scratch 1.2, and "ScratchV01" in Scratch 1.2 and below
    • "infoSize", encodes the length of the project's infoObjects. A 4-byte long, 32-bit, big-Endian integer.
    • "infoObjects", a dictionary-format data section. It contains: "thumbnail", a thumbnail of the project's stage; "author", the username of the project's creator; "comment", the Project Notes; "history", the save and upload log; "scratch-version", the version of Scratch used to save the file;
    • "contents", an object table with the Stage as the root.[68] All objects in the program are stored here as references.[69]

    Scratch 2.0 uses the *.sb2 file format. These are essentially zip files containing a .json file as well as the contents of the Scratch project including sounds (stored as .wav) and images (stored as .png).[70] Each filetype, excluding the project.json, is stored as a number, starting at 0 and counting up with each additional file. The image file labeled "0.png" is always a 480x360 white image, but "0.wav" will still be the earliest non-deleted file.

    The ScratchX experimental version of Scratch used the .sbx file format.[71]

    Scratch 3.0 uses the *.sb3 format, which is very similar to *.sb2, one difference being the sound.[how?][72]

    Although the main Scratch website now runs only the current version (Scratch 3.0), the offline editors for Scratch 2.0 (and the earlier Scratch 1.4) are still available for download[73] and can be used to create and run games locally.[74] It is still possible to upload projects from the Scratch 2.0 launcher, which are immediately converted into Scratch 3.0 when uploaded to the main site.[75] There is also an offline version of Scratch 3.0.

    Technology

    The editor of Scratch 1.4 and below was written in Squeak, while its online project viewer was written in Java, and a player written in Adobe Flash was later added.[43][76] Scratch 2.0 relied on Adobe Flash for the online version, and Adobe AIR for the offline editor. These have fallen out of favor, and Adobe dropped support for them at the end of 2020.[77][78]

    Interface

    Thumb
    A script that lets the sprite say Hello, World! then stops the script in Scratch 2.0

    In Scratch 2.0, the stage area is on the left side, with the programming blocks palette in the middle, and the coding area on the right. Extensions are in the "More Blocks" section of the palette.[22]

    The web version of Scratch 2.0 introduced project autosaving.[79]:23

    The blocks palette in Scratch 2.0 is made of discrete sections that are not scrollable from one to the next; the table below shows the different sections:

    More information Category, Notes ...

    Interface sections in Scratch
    Category Notes
    Motion Moves and changes the position of sprites
    Events Event handlers
    Looks Controls the visuals of the sprite
    Control Conditionals and loops
    Sound Audio files, sequences, and music
    Sensing Sprite interaction
    Pen Draw on the canvas
    Operators Mathematical operators
    Data Variables, arrays and lists
    More Blocks Functions, return value is always void

    Close

    Scratch 2.0 introduced the backpack, which can be used to transfer scripts, sprites, costumes, and sounds between projects.[79]:14–15

    1.4 sounds

    Scratch 2.0 changed how sounds were imported, so many Scratch 1.4 sounds stopped working. (The project file was changed from *.sb to *.sb2).

    Scratch uses event-driven programming with multiple active objects called sprites.[14] Sprites can be drawn, as vector or bitmap graphics, from scratch in a simple editor that is part of Scratch, or can be imported from external sources. Scratch 3.0 only supports one-dimensional arrays, known as "lists", and floating-point scalars and strings are supported but with limited string manipulation ability. There is a strong contrast between the powerful multimedia functions and multi-threaded programming style and the rather limited scope of the Scratch programming language.

    Scratch 2.0 features

    Scratch 2.0 does not treat procedures as first class structures and has limited file I/O options with Scratch 2.0 Extension Protocol, an experimental extension feature that allows interaction between Scratch 2.0 and other programs.[80] The Extension protocol allows interfacing with hardware boards such as Lego Mindstorms[81] or Arduino.[82] Scratch 2.0 also has the following features:

    • Smart block switching
    • Two-column category menu
    • Reverse order of project controls
    • Display stage on left side
    • Square block inputs
    • Compact editor
    • Collapsing sprite properties
    • Scratch 2.0 themes

    Snap! (Build Your Own Blocks)

    A more advanced visual programming language inspired by Scratch is Snap!, featuring first class procedures (their mathematical foundations are also called lambda calculus), first-class lists (including lists of lists), and first-class truly object-oriented sprites with prototyping inheritance, and nestable sprites, which are not part of Scratch.[83] Snap! (previously "BYOB") was developed by Jens Mönig[84][85] with documentation provided by Brian Harvey[86][87] from University of California, Berkeley and has been used to teach "The Beauty and Joy of Computing" introductory course in CS for non-CS-major students.[88] Both of them were members of the Scratch Team before designing "Snap!".[89][22]

    ScratchJr

    In July 2014, ScratchJr was released for iPad, and in 2016, ScratchJr for Android. Although heavily inspired by Scratch and co-led by Mitch Resnick, it is nonetheless a complete rewrite designed for younger children—targeting ages 5 through 7.[90]

    Due to the open source nature of Scratch, numerous forks and browser extensions have been created by the community that aim to improve or modify the user experience. ScratchTools and Scratch Addons are some examples of open-sourced browser extensions that add many upgrades and new features to the Scratch website and editor.[91][92]

    TurboWarp is a fork of the Scratch 3.0 editor that compiles Scratch into JavaScript code when a project is run, resulting in projects' general preformances boosting significantly.[93] In addition, there are many technical settings and the same addons as Scratch Addons provided.[94] TurboWarp can also export projects to standalone HTML5, Bundle (macOS) and EXE files.[95]

    Users can also create their own extensions for Scratch 3.0 using JavaScript.[96] Although the intention for Scratch 3.0 was to allow unofficial JavaScript extensions to be developed by users, it was abandoned due to moderation risks. As a result, the official site doesn't allow JavaScript extensions to be added, but several modifications of Scratch do.

    Before 2.0, a number of Scratch forks[97][better source needed] were created using the source code of Scratch 1.4. These programs usually only included a few extra blocks not present in Scratch.[98][better source needed]