
Many are familiar with Scratch – a programming environment for children, where learning usually involves creating creative projects from simple to complex. However, the 'classic approach' to learning programming (variables → branching → loops → functions → structures → objects → …) is challenging in Scratch.
However, changing the sequence of learning concepts (let's call them concepts) of structural, object-oriented, and event-driven programming, hiding them behind colorful sprites and interactive animations, does not mean that these concepts shouldn't be emphasized. This is especially true if the goal is not only to develop creative abilities but also to teach programming. I tried to reflect this idea in my .
The first thing a novice scratcher encounters are sprites. Although there isn't strictly object-oriented programming in Scratch, sprites can be considered objects. At this stage, the learner sees that a program can have many objects, whose behavior is controlled by external scripts. Sprites receive commands or provide information about their state on demand, meaning programming boils down to managing objects.
The second concept that immediately falls on the young programmer's head in Scratch is the idea of multithreading. Each sprite can have several scripts that run simultaneously. Multiple sprites can also execute their programs concurrently. Moreover, organizing sequential execution turns out to be more complex.


Even in the first lesson, we cannot avoid introducing loops. Otherwise, the cat won't really get moving. At this point, the introduction must remain intuitive and superficial. We limit it to the loops 'forever' and 'repeat … times,' which are easier to understand. The conditional loop is covered in a lesson specifically dedicated to loops, which requires knowledge of logical expressions and variables.
Since Scratch is an event-driven environment, it is more convenient to study conditional operator blocks before variables. Conditions can be based on various events.

In my opinion, this sequence is better, as we introduce a minimum of concepts with each lesson. Moreover, these are not abstract concepts; we immediately see their practical use.
If we start by studying variables, it is difficult to demonstrate their purpose and benefits, since the conditional operator, data input, and random number generation have not yet been covered.
In Scratch, aside from lists, programmers encounter three data types: numbers, strings, and booleans. Notably, the type is tied to the value, not the variable. There's no need to convert strings to numbers and back. Strings are not enclosed in quotes.
A block that returns a boolean value and has a characteristic angular shape can be inserted into rounded fields. The opposite is not true: a regular variable cannot be placed where a boolean expression is expected.

Scratch is designed in such a way that critical errors do not occur during execution. Apparently, that is why, if you try to use a string in an arithmetic operation, it is replaced with zero (see the first screenshot).
A programmer must understand that the capabilities of programming languages are extended by libraries. While working in Scratch, students can add extensions that bring new commands into the environment.

Functions in Scratch are implemented in the 'More Blocks' section, where you create your own block that can be inserted into other scripts. On the other hand, you need to define the functionality of this block, that is, what it will do.

Scratch functions do not return values.
Thus, studying programming concepts in an event-driven environment leaves its mark. Essentially, we first learn more complex and abstract concepts, and only as we delve deeper into the process do we move on to elements of structured programming. Whether this is a plus or minus for a first encounter is a debatable question.
Source: habr.com
