Page Discussion View source History

Build Your Own Blocks (Scratch Modification)

From the Scratch Wiki — made by Scratchers, for Scratchers.

Jump to: navigation, search
Build Your Own Blocks (BYOB)
{{{imagewidth}}}px
Version BYOB 3.1.1; Snap 4.0 (developing)
Operating Systems Windows, Macintosh, Linux, Unix
Purpose for creation The ability to build your own blocks; everything first class
Developer(s) Jens, bharvey
Open source? Yes
Programming language Squeak, JavaScript
Released? Yes
Compatible with Scratch 1.3 and 1.4
Official Website http://byob.berkeley.edu/
Forum Topic http://scratch.mit.edu/forums/viewtopic.php?id=34284
The BYOB logo.
Build Your Own Blocks — often referred to by its acronym, BYOB — is a modification of Scratch, made mainly by the users Jens and bharvey. It includes many features that aren't available in Scratch without many large modifications to the source code (see Shift-Click-R for details) — these range from building your own blocks to Mesh. The primary focus for this Scratch modification is first-class data.

Contents

Features

The other BYOB logo.
BYOB contains many features not available in Scratch (without editing the code). The features are that users can:
  • Build their own blocks via drag & drop
  • Host and join Mesh sessions, share sprites over the mesh
  • The "Elements" feature allows you to edit the underlying Smalltalk code in a Scratch-like environment.
  • Nestable sprites
  • True object oriented sprite hierarchy
  • Compiler (makes a project into an .exe/.app (application) file).
  • Scrolling enhancements
  • Undo (Scratch 1.4 only contains "Undelete", which some 1.3 fans find useless)
  • Pause / resume the project
  • Debugger
  • Multi-dimensional lists (lists in lists, or arrays)
  • First class procedures (lambda) and full closures
  • Cloning
  • Atomicity control
  • Type checking

BYOB 3.0 Features

There are 18 new blocks in BYOB 3.0. They are as follows:

Control

[run ()]
Runs the block(s) inserted. When the ► is clicked, the block becomes [run () [with inputs/with input list] ◄►]. With inputs allows users to specify the inputs of a block; With input list sets the inputs to a list.
[launch ()]
Similar to RUN, this runs the script simultaneously with the next. The same thing happens when the ► is pressed.
(call ())
Allows a user to call a variable that is a reporter. Also has the same menu.
[report ()]
For use in custom reporter/boolean blocks, it specifies what to report.
[stop block]
Stops a custom block without reporting anything.
[debug]
(debug ())
An experimental debugger that allows true single-stepping of scripts and examination of local variables. Doesn't do anything in Presentation Mode. More information is available here.

Operators

<true>
Simply reports true.
<false>
Simply reports false.
(ascii code of ())
Reports the ASCII code of a single character. If there are more than one character, it reports Error!
(ascii () as letter)
Reports the character equivalent to an ASCII code.
<is () a |dropdown|?>
With choices of number, text, boolean, list, command, reporter, predicate, object; it reports true if the insert is of the selected type, and false if it is not.
[the script►]
This is a C Block, but a reporter, not a command like most C-shaped blocks. It reports the block(s) inserted. If there is nothing, it reports itself, THE SCRIPT. When the ► is pressed it becomes [the script. Input names:(#1)◄►] #1 is a variable, and more can be created by pressing the arrows. They can be renamed by clicking, and deleted by right-clicking and choosing "delete." They can be used in the script inside the C-shaped slot, and are assigned values when the reported script is run using the RUN or LAUNCH block.
(the () block►)
Reports the reporter or predicate block inserted. It starts out as a reporter, but turns predicate-shaped when one is inserted. If nothing is put in, it also reports itself: THE BLOCK. If THE SCRIPT is put in, it says [report [the script]]. It works very similarly to THE SCRIPT, and the same things happen when the ► is pressed. This block is equivalent to the Lisp lambda function.

Variables

[script variables ()►]
Even though it is a variables block, it is gray. It creates variables that can only be used in that script. They appear in the dropdown menu for the other variable blocks. However, the show variable and hide variable blocks do not work with these.

Lists

(list ()◄►)
Reports a list without having to create a new named list. Because of this, the other list blocks accept dropped reporters.
(() as text)
BYOB does not normally report a list as text, rather as a list as it is shown on the Stage. This block makes it text and works the same way as the Scratch block ().
(copy of ())
If a variable is set to a list, it will update with the list. Here is how to avoid that.

BYOB 3.1 Features

The main new feature in BYOB 3.1 is the promotion of sprites to first class status, along with the ability to create a true object hierarchy by cloning sprites; child sprites inherit some properties from their parent sprite.

There are four new blocks, along with changes to three other blocks.

The BYOB 3.1 manual is here.

Sensing

(object |dropdown|)
Reports a sprite, a list of all sprites, or the stage.
(attribute |dropdown|)
Reports any attribute of the sprite that calls it, e.g., (attribute draggable?) reports true if the padlock next to the sprite's name is unlocked, or false if locked. Inside a the block block, this block represents the attribute itself as a first class entity that can be given to the of, set, or delete blocks.

Also, the of block has an expanded range of inputs; any sprite property can be dropped onto the left pulldown, and any sprite onto the right pulldown.

Operators

(clone)
Reports a clone of the sprite that calls it. A clone isn't merely a copy; it shares some properties (the user can control exactly what is shared) with the original, so that a change to the parent is reflected in the child.

Also, the (is () a ()?) block has a new type, object, in the pulldown menu of types.

Variables

[delete ()]
Deletes the object, attribute, or variable given as input. Objects can be used directly; attributes and variables are enclosed in a the block block (or dropped with a grey border, since the input slot is of type Reporter). This replaces the "Delete a variable" button.

Also, the set block now allows an attribute to be dropped onto the pulldown list of variables.

History

Jens's first modification was "Chirp," a program that had improvements to Scratch. He then began to work on BYOB (a much bigger project), which has three versions: 1.0 (for Scratch 1.3), 2.0 (for Scratch 1.4), and version 3.1.1, which can be downloaded here.

Use in Scratch 2.0

Main article: Scratch 2.0

The Scratch Team plans to incorporate a function based on BYOB in the next version of Scratch, Scratch 2.0.

After we move to a web based Scratch we will start to add new features, and one will be the ability to "build your own block." You'll be able to make a single block that runs a bunch of scripts that you've created.

– Lightnin, Scratch Team at MIT

This was confirmed in the second Scratch 2.0 Progress Report. However, only command blocks can be created, not reporters.

Intellectual Precursors

Custom Blocks

The ability to write and invoke procedures, which is the core idea of BYOB, has been part of almost every programming language (with hardware support in every processor design at least to the extent of an instruction to save the return address somewhere before jumping to the procedure) in the history of computing. (In the original Fortran, the first general-purpose high level programming language, procedures were not reentrant, like Scratch scripts, which break off in the middle if the event that started the script happens again.)

File:Mapwithexample.png

File:Glide BYOB.png

Among languages intended primarily for children, by the way, there were heated debates between BASIC and Logo advocates because the latter included support for recursive procedures and the former did not, limiting itself instead to something pretty similar to the Scratch BROADCAST AND WAIT block. There's an irony in this, since the Scratch Team is a descendant of the old MIT Logo Lab. Seymour Papert, one of Logo's inventors and the founder of the MIT Logo Lab, argued for recursion as one of the mathematical big ideas that children should learn from programming computers.

First Class Data

The phrase "first class data" was coined by computer scientist Christopher Strachey, who argued in the 1960s that any data type that exists in a language at all should be first class. This means that data of that type

  • can be the value of a variable.
  • can be an input to a procedure (Scratch: block).
  • can be reported by a procedure.
  • can be a member of an aggregate (Scratch: list).
  • can exist without having a name.

It's easy to see why one might want lists of lists; every data structure (trees, heaps, hash tables, etc.) can be constructed out of lists of lists, but not straightforwardly with only lists of text strings. But why should procedures be first class? This was historically a counterintuitive idea, especially because a procedure can't be recursive unless it has a name by which to call itself.

The idea of first class procedures comes ultimately from the 1936 invention by mathematician Alonzo Church of lambda calculus, which is a formal study of the behavior of functions. In 1936 there were only a handful of experimental computers, and no symbolic programming languages, so the fact that lambda calculus turned out to be of practical use (it is the basis for much of the theory of programming languages today) was a great confirmation of the power of the idea.

Church demonstrated that the ability to create and call functions is universal — it's all you need to perform any computation that can be done at all. (He also proved that there are undecidable problems, which is the reason for the qualifying clause above.) In BYOB terms, this means you could have a programming language with nothing but THE BLOCK and CALL, and still be able to compute any function. (See this BYOB project description for an explanation of how to invent arithmetic from that starting point.) The Greek letter lambda (λ) is Church's name for THE BLOCK.

File:Compose.png

(Of course lambda doesn't solve the problem of input/output: capturing mouse clicks, drawing pictures on the screen, and so on. Although obviously of crucial practical importance, such input/output activities aren't central to the understanding of what a program or a programming language is.)

Church's work influenced actual programming language design by way of John McCarthy's 1958 invention of the Lisp programming language for artificial intelligence research. Lisp is a direct influence on Logo, and therefore an indirect influence on Scratch. The detailed design of first class procedures in BYOB was strongly influenced by Scheme, a Lisp dialect invented in the late 1970s by Gerald Jay Sussman and Guy Steele, which brought Lisp closer to its roots in lambda calculus by introducing lexical scoping rules.

Prototyping

The clone block reports a new object that inherits properties of the parent object. This allows users to create an object hierarchy, as in other OOP languages such as Smalltalk. But unlike Smalltalk, BYOB does not distinguish between classes and instances; every object can be viewed as an instance of its parent or as the class of its children. This form of inheritance is called "prototyping" because the user builds an example of a category of sprite rather than building the category as an abstract description. The best known prototyping languages are JavaScript and Self. The particular form of prototyping used in BYOB was inspired by the work of Henry Lieberman.

Future Versions

The developers are working on the next version — 4.0. The name will be changed to "Snap",
 
[1] because of the other meaning of the acronym BYOB. Some people think a warning is OK,
 
[2] but the Berkeley personnel experienced some resistance to the old name from potential users, and the developers didn't feel the name was worth fighting about.

Snap 4.0 will be written in JavaScript, using the HTML5 canvas element.

The current Snap 4.0 experimental version can be found here to try out.

Scratch Mod Design Aesthetics

It is traditional to measure the power of a Scratch modification in part by the number of blocks it adds to the language. BYOB has taken the opposite approach, trying to get a lot of expressive power out of a very small number of new blocks.

One reason for this is that an explicit goal of BYOB is to influence the design of Scratch 2.0, and it is hoped that the Scratch Team may be more amenable to changes with a "small footprint" — ones that will not intrude dramatically on the experience of the traditional Scratch programmer.

Alpha/Beta Testers

The certificate.
Bharvey put a "Certificate of Appreciation" on the BYOB website, consisting of 16 people who helped test BYOB3.

External Links

References

  1. http://scratch.mit.edu/forums/viewtopic.php?pid=719634#p719634
  2. http://scratch.mit.edu/forums/viewtopic.php?pid=719904#p719904